Hi,
Please forgive my ignorance as I’m a beginner to PRT coding.
I have a very basic code that looks at 4H charts.
-If the previous candle closes green then it enters a long.
-If the previous candle closes red then it enters a short.
I am trying to get it to close at the end of each candle, this seems to be working for my long positions but not my short.
Any advice would be greatly appreciated on why my code is not working properly.
Thank you in advance and happy trading!
Anton
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
// Definition of code parameters DEFPARAM CumulateOrders = False // Cumulating positions deactivated // Conditions to enter long positions c1 = (close >= close[1]) IF c1 THEN BUY 4 CONTRACT AT MARKET ENDIF SET STOP pLOSS 300 // Conditions to exit long positions c2 = (close CROSSES OVER close) IF Longonmarket then IF open<close Then SELL AT MARKET ENDIF ENDIF // Conditions to enter short positions c3 = (close < close[1]) IF c3 THEN SELLSHORT 4 CONTRACT AT MARKET ENDIF c4 = (close CROSSES OVER close) // Conditions to exit short positions IF Shortonmarket then IF open>close Then SELL AT MARKET ENDIF ENDIF // Stops and targets SET STOP pLOSS 300 |