DEFPARAM CumulateOrders = TRUE
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 083000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 170000
timeEnterAfter = time < noEntryAfterTime
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
timeframe(1 hour, UPDATEONCLOSE)
Atr = AverageTrueRange[14](close)
PerC = Atr * 100 / close
Atr1 = AverageTrueRange[14](close)
PerC1 = Atr * 100 / close
Change = ABS(close - close[10])
calc = ABS(close-close[1])
volat = summation[10](calc)
ER = Change / volat
vol1 = perc1 < v1
vol2 = perc > v2
noiseok = er > v3
Change = ABS(close - close[10])
calc = ABS(close-close[1])
volat = summation[10](calc)
km = Change / volat
trend1 = close > km
trend2 = close < km
timeframe(10 minute, default)
bearEngulf=(close[1] > open[1] and open > close and open >= close[1] and open[1] >= close and open - close > close[1] - open[1] )
startBreakeven = AverageTrueRange[14](close)*sb
PointsToKeep = AverageTrueRange[14](close)*pk
//reset the breakevenLevel when no trade are on market
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
//short entry
if bearEngulf and trend1 and vol1 and vol2 and noiseok AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry then
sellshort 1 contract at market
endif
IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
EXITSHORT AT breakevenLevel STOP
ENDIF
Hello
Can anyone help me discover the reason why this system executes trades in Back-Test mode but not in demo Pro-Order?
This system looks for Bearish Engulfing patterns on the 10 minute time frame and then executes orders on the one minute time-frame. If a bearish engulfing forms on the 10 minute time-frame an order is executed at the start of every minutes on the 1 minute time-frame. Multiple orders are therefore opened every minute within a single bullish engulfing in the 10 minute time-frame.
I’m sure there is a relatively simple reason but as I am very much a novice.
The code has not been commented on very well but I am sure some of the experts will quickly see what is going on with the system. It is a trend following system with a basic filter and one of the trailing stop losses created by Nicholas, I believe.
Thanks
J
What Instrument and Timeframe and I’ll try it on my Platform to see if I get same as you.
JSParticipant
Senior
Hi @borderlinejim
With the code I miss the values of the following variables: pk, sb, v1, v2 and v3
Did you launch it on a 10-min timeframe? Do you have sufficient amount of money on your demo account (free margin to execute 1 contract on gold).