I a struggling with the fact that the stochastic does not always give a signal. I don’t understand why. Here is the simple code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
atr2=averagetruerange[14]
IFNOTONMARKETTHEN
c2=Stochastic[5,3](close[1])<20
IF(c2)THEN
BUY1CONTRACTATMARKET
SET STOPLOSSatr2*5.5
SET TARGETPROFITatr2*2.5
ENDIF
ENDIF
signal=c2
graphsignal
It says buy when the stochastic is below 20. The thing is that sometimes it provides this signal, but sometimes not. I don’t know why. See attachment. I should expect that at 10.35 hrs, 14.20 hrs and 16.45 hrs it would provide a buy signal.
Your attachment is empty. If you want to add picture, just upload them in any supported format such as .png .jpg, etc..
The problem in your code is that your are only storing value of the stochastic condition into your c2 variable when you are not on market. You should test your condition outside the “onmarket” conditional block.
Thank you for your quick reply. Ok, so I should not use the onmarket conditional block. That indeed seems to be the issue here. And use DEFPARAM Cumulateorders = False.
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