I’m a bit new to coding so please bear with my silly questions?
I am trying to develop an entry using the Stochastic indicator, but am struggling to set up a couple of conditions.
I want to enter LONG when:
The Stoch %K has been below 20% i.e. oversold
Then it Crosses Over Stoch %D
And then moves above 25%
I am struggling to code the sequencing i.e. has been below 20% but now has crossed over and is above 25% – I guess the main thing I want to know is about setting a condition (trading below 20%) and the the code remembering it for the next phase of the filter?
Any help would be most grateful – I’ve attached my attempt at this part of the code and a marked up screen shot
Firstly, you want to code a strategy, but you posted on the wrong forum (ProBuilder, reserved to indicators/oscillators). I’ll move it to ProOrder.
At line 7 you are assigning PERIOD a logical value, true (1) or false (0). In both case it’s < 20 so C1 at line 7 will ALWAYS be true! (it will be replaced by new lines 11-13). It must be changed to check K has crossed over D:
1
c1=indicator1CROSSES OVERindicator2
Line 10 looks good, it just makes sure the prise is going north.
Line 11 needs to be changed and made of three lines to make sure it has both crossed over 20 and 25 at the same time or it just crossed over 25 and the previous candle had crossed over 20:
1
2
3
c3a=(indicator1CROSSES OVER20)
c3b=(indicator1CROSSES OVER25)
c3=(c3a[1]ORc3a)ANDc3b
Finally, line 13 cannot be written like that, did you ever test this piece of code? NO, otherwise you’d have been warned about this syntax error. IF and ENDIF cannot be on the same line AND the action to be taken must be in between:
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue