Hi, I have written a basic ema cross over system and the system will buy/sell when I don’t want it too and I can’t see whats wrong with my code. Please take a look any help is welcome, thanks. Screenshot of issue: https://gyazo.com/4c337115afa8ec5e7a11c2b030a30ae4
defparam preloadbars = 15
defparam CUMULATEORDERS = false
indicator1 = ExponentialAverage[20](close)
indicator2 = ExponentialAverage[50](close)
//buy condition
cBuy = (close CROSSES OVER indicator1)
//sell condition
cSell = (indicator2 CROSSES Over indicator1)
If cbuy then
buy 5 perpoint at market
endif
If csell then
sell at market
endif
if csell then
sellshort 5 perpoint at market
endif
if cbuy then
exitshort at market
endif
Maybe if you change to:
cBuy = (indicator1 CROSSES OVER indicator2)
cSell = (indicator1 CROSSES UNDER indicator2)
Hi, that then changes the system to something I don’t want but thanks
Ok. You can´t use (close) as a parameter
I think you can, as it seems to recognize it fine.
Hi jbyrne,
the trade appears corect to me because “close” crosses under the EMA20 and then crosses over right after the next bar. The system enters the Position when the next bar opens.
Maybe you can see it more clear when switching from candlesticks to a line. It appears to be a problem with a choppy signal.