hi,
the low of the candle has not cross under the ema 37 line but still entered a long position. any reason why?
//conditions to go long
longc1 = ema37 - ema50 > 0.0002
longc2 = high[1] < high[2] and high[2] < high[3]
longc3 = (low[1] crosses under ema37) or (low[1] crosses under ema50)
longc4 = (close[1] > ema50) and (close[2] > ema50) and (close[3] > ema50)
longconditions = longc1 and longc2 and longc3 and longc4
//long entry trigger
buyentry = close >= high[1]
if not onmarket and longconditions and buyentry then
buy 1 contracts at market
endif
thank you
i thought it may be because of the spread but i tried changing it to 0 to some other number but the results are still the same.
//indicators
ema37 = ExponentialAverage[37](close)
ema50 = ExponentialAverage[50](close)
//conditions to go long
longc1 = ema37 - ema50 > 0.0002
longc2 = high[1] < high[2] and high[2] < high[3]
longc3 = (low[1] crosses under ema37) or (low[1] crosses under ema50)
longc4 = (close[1] > ema50) and (close[2] > ema50) and (close[3] > ema50)
longconditions = longc1 and longc2 and longc3 and longc4
//long entry trigger
buyentry = close >= high[1]
if not onmarket and longconditions and buyentry then
buy 1 contracts at market
endif
forgot the indicators
Line 4 is logically wrong, it can’t test a cross under between the previous LOW and current EMA’s.
Replace it by:
longc3 = (low crosses under ema37) or (low crosses under ema50)
Do not use 0.0002, rather 2*PipSize.
but one of the conditions is if the previous low crosses under those ema or value of it less than the ema. i do not want the lastest candle.
when i try to replace line 7 with
longc3 = (low[1] < ema37) or (low[1] < ema50)
results are the same.
got it
i did this
longc3 = (low[1] crosses under ema37[1]) or (low[1] crosses under ema50[1])