EBParticipant
Senior
Hi,
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:
atr2 = averagetruerange[14]
IF NOT ONMARKET THEN
c2 = Stochastic[5,3](close[1]) < 20
IF (c2) THEN
BUY 1 CONTRACT AT MARKET
SET STOP LOSS atr2*5.5
SET TARGET PROFIT atr2*2.5
ENDIF
ENDIF
signal = c2
graph signal
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.
Can anybody tell me why this is not the case?
Thank you,
Edward
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.
EBParticipant
Senior
Hi Nicolas,
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.
Edward