Hi, if re-written my system but it’s very inconsistent since the code seems to be fine but when I backtest it, it doesn’t always go long/short when its mean’t to please help. Please check links for photos of the problem I’m having.
Photo link: https://gyazo.com/e844d6b20ad1b5dbc3afc38d2d19ba4f
Also I’m using spreadbetting and all the units seems to be in cents in instead of full numbers, anyway to change that? thanks
// Definition of code parameters
DEFPARAM CumulateOrders = false // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = Average[9](close)
c1 = (indicator1 CROSSES OVER open)
indicator2 = Average[9](close)
c2 = (indicator2 CROSSES UNDER close)
IF c1 AND c2 THEN
BUY 3 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = Average[9](close)
c3 = (indicator3 CROSSES UNDER open)
indicator4 = Average[9](close)
c4 = (indicator4 CROSSES OVER close)
IF c3 AND c4 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator5 = Average[9](close)
c5 = (indicator5 CROSSES UNDER open)
indicator6 = Average[9](close)
c6 = (indicator6 CROSSES OVER close)
IF c5 AND c6 THEN
SELLSHORt 3 PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator7 = Average[9](close)
c7 = (indicator7 CROSSES OVER close)
indicator8 = Average[9](close)
c8 = (indicator8 CROSSES UNDER close)
IF c7 AND c8 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
You have some conditions that do not suit the crosses over/under at the same time, that’s why there are some problems obviously.
If you want to test a simple cross of the price with a moving average, you should only code it like this:
indicator1 = Average[9](close)
//buy condition
cBuy = (close CROSSES OVER indicator1)
sell condition
cSell = (close CROSSES UNDER indicator1)
That’s all you need.
Hi, thank you for your help it’s helped me a lot. I have realized that the problem i was having is that I use heiken ashi candles but ProOrder uses regular candlesticks. How can I get my code to buy/sell according to Heiken Ashi candles instead of regular candlesticks? thank you
Here is Heiken Ashi candlestick Close code you need:
haclose=(open+close+low+high)/4
thank you you have been very helpful, but can you direct me where to put that code in order to make my system work? thank you
Add it at the beginning of your code and then replace of the “close” with “haclose”, that’s all.
thank you it works great apart from the it opens the new position at the close of the candle instead of the open. How can this be changed? thank you
Conditions are tested at the bar close and positions are next open candle. So I think what you observed here is the spread.
I don’t know if its the spread or not because spreads surely aren’t this big? https://gyazo.com/06c9d8fd6754e2460e60b97147677546