Condition triggered recently (few bars ago)?
Author: leeto
Creation Date: 6/21/2015 12:27 PM
profile picture

leeto

#1
Let say I would like to enter when RSI crosses up 20 level and as confirmation I would like that Stochastic indicator were crosses up 20 level RECENTLY too.

CODE:
Please log in to see this code.


So I have two problems in my code.

Problem 1#
The first problem I didn't know how to set the condition crossing up
I thought that the easiest way to make crossing up condition is to make sure that current stoRSI[bar] is the max value among ( let say ) 3 bars

CODE:
Please log in to see this code.


However, I failed to integrate this condition. Code just didn't compile. Please help .

Problem 2#
The second problem is that I don't know how o integrate RECENTLY condition for confrontational StochD indicator. By "recently" I mean few bars ago ( 2 bars ago and 3 bars ago and 4 bars ago and 5 bars ago ) . This is obvious that should be some variable fewBarsAgo or array which basically should be from 2 to 5 (for example). However, this is not obvious for me how to integrate this logic into code. Please help.
Many thanks in advance !
profile picture

Eugene

#2
It's sad to see that after an effort to safeguard you from falling into the pitfall of peeking, you keep ignoring our numerous advices and still use "bar" for anything than AtClose.

#1 - Syntax is incorrect. Check out the WealthScript Programming Guide > DataSeries > Accessing a Single Value from a DataSeries.

#2 - WealthScript Techniques | Setups, Triggers, Delays, and Timeouts
profile picture

leeto

#3
QUOTE:

It's sad to see that after an effort to safeguard you from falling into the pitfall of peeking, you keep ignoring our numerous advices and still use "bar" for anything than AtClose.


Sorry but the code from the wealth lab wiki with minor modification.

http://www2.wealth-lab.com/WL5WIKI/StochRSI.ashx

So do I correctly understand that in this wiki page there are mistakes ? If so I plea sorry for didn't review the code. I didn't expect that could be errors in wiki.


I suppose you are talking about this line ?

CODE:
Please log in to see this code.


should be

CODE:
Please log in to see this code.



profile picture

Eugene

#4
QUOTE:
Sorry but the code from the wealth lab wiki with minor modification.

Thanks for the heads-up. This was a bug in the Wiki example and I've just nailed it down.
profile picture

leeto

#5
QUOTE:
Thanks for the heads-up.

No thx you for your support ! Thanks you that you do care about my bar+1 error




QUOTE:
#1 - Syntax is incorrect. Check out the WealthScript Programming Guide > DataSeries > Accessing a Single Value from a DataSeries.


Seems I figure out syntax error for problem #1

should be

CODE:
Please log in to see this code.


instead of

CODE:
Please log in to see this code.

or
CODE:
Please log in to see this code.



Looks like it works !
profile picture

Eugene

#6
That's right. Glad you found the solution yourself.
profile picture

leeto

#7
QUOTE:
#2 - WealthScript Techniques | Setups, Triggers, Delays, and Timeouts



I catch the main idea describe in the article

http://www2.wealth-lab.com/WL5WIKI/kbSetupsTriggersDelaysTimeouts.ashx

However, after I analyzed some entries I figure out that the code didn't work well for me. For example, when I set up
CODE:
Please log in to see this code.
which basically should mean that SlowD (stochastic) and StocRSI should cross 20 level simultaneously, it turns out that there are a lot of entries that just ignore SlowD Stoc at all.

Could you take a look on my code that tell me what I do wrong. Many thanks in advance !

CODE:
Please log in to see this code.
profile picture

leeto

#8
I still hoping to receive an answer on my question...
profile picture

Eugene

#9
QUOTE:
I still hoping to receive an answer on my question...

Such attitude is not appreciated. Please keep from bumping up your posts and crossposting of sorts. As our manpower is limited, to properly serve our paying customers their issues have a higher priority over those of the free trial users. You have developed a good appetite for new questions every day but we can not allow one user to monopolize our attention. Your posts will get answered eventually. Thank you for your understanding.
profile picture

Eugene

#10
To start with, there's a logic error:

CODE:
Please log in to see this code.


This is assignment whereas what you intended to do was to test for equality.
profile picture

leeto

#11
Thanks you Eugene but I corrected the error but the code still does not work as it should, unfortunately .
profile picture

Eugene

#12
What makes you think so? Don't hesitate to provide more details.
profile picture

leeto

#13
Please take a look on the attachment. To avoid a silly mistake I post the code again. The code below produce the entry that I put in attachment.

CODE:
Please log in to see this code.
profile picture

leeto

#14
This is data for the stock (HCA). The stock that I took as an example.
profile picture

Eugene

#15
You will be surprised but even such simple app as MS Paint has a Text tool. Use that to type text. :)

If you're concerned with too many bars passing between the setup and trigger bars, then this should do the job:

CODE:
Please log in to see this code.
profile picture

leeto

#16
QUOTE:
You will be surprised but even such simple app as MS Paint has a Text tool. Use that to type text. :)

:)



QUOTE:
If you're concerned with too many bars passing between the setup and trigger bars, then this should do the job:

Thanks you Eugene ! Looks like the code works decently !
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).