// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Cancel all pending orders and close all positions at the “FLATAFTER” time
DEFPARAM FLATAFTER = 234500
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions to enter long positions
indicator1 = SuperTrend[1.6,4]
c1 = (close > indicator1)
indicator2 = SuperTrend[1.3,2]
c2 = (close > indicator2)
c3 = (close > close[1])
IF (c1 AND c2 AND c3) AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = SuperTrend[1.6,4]
c4 = (close CROSSES UNDER indicator3)
indicator4 = SuperTrend[1.3,2]
c5 = (close CROSSES UNDER indicator4)
IF c4 AND c5 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator5 = SuperTrend[1.6,4]
c6 = (close <= indicator5)
indicator6 = SuperTrend[1.3,2]
c7 = (close <= indicator6)
c8 = (close < close[1])
IF (c6 AND c7 AND c8) AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
indicator7 = SuperTrend[1.6,4]
c9 = (close CROSSES OVER indicator7)
indicator8 = SuperTrend[1.3,2]
c10 = (close CROSSES OVER indicator8)
IF c9 AND c10 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pTRAILING 30
SET TARGET pPROFIT 120
Zero bars, over zero bars. This won’t work.
I am running it on test mode since 25 August with 2 consecutive wins fro Japan 225 and Wall Street. Any comments to optimized the code will be highly appreciated.
Hi LancerX, thanks for sharing your code. @despair was pointing the fact that you have backtested the strategy without the tick by tick mode which is the best way to validate the results. Did you tried with tick mode?