I used this code (which is the same as my second one I posted mith the addition of MyHI to make Entry fixed for the 1-minute bars), in addition I added some debugging instructions, Graph & GraphOnPrice, on the 1-min chart:
DEFPARAM CUMULATEORDERS = FALSE
Timeframe (2 minutes, updateonclose)
td1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= 000000 AND OpenTime <= 235900 //Monday
td2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= 000000 AND OpenTime <= 235900 //Tuesday
td3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= 000000 AND OpenTime <= 235900 //Wednesday
td4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= 000000 AND OpenTime <= 235900 //Thursday
td5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= 000000 AND OpenTime <= 235900 //Friday
td = td1 or td2 or td3 or td4 or td5
TIMEFRAME(2mn, updateonclose)
BBlow = low < Bollingerdown[20](close)
IF BBlow AND Not OnMarket THEN
MySL = range + 1*pipsize
MyTP = 1*MySL
MyHI = High + 1*pipsize
ENDIF
Risk = 10
TIMEFRAME(default)
IF NOT ShortOnMarket AND BBlow and td THEN
Set stop loss MySL
Buy (Risk / range) CONTRACTS AT MyHI Stop
SET TARGET PROFIT MyTP
ENDIF
//
graph BBlow
Graphonprice positionprice + MySL coloured(255,0,0,255) AS "SL"
Graphonprice positionprice - MyTP coloured(0,0,255,255) AS "TP"
graphonprice MyHI coloured(0,255,0,255) AS "Entry"
I also used this indicator on the 2-min chart to have the signals as a histogram:
RETURN low < Bollingerdown[20](close)
As you can see from pic BB1, the signal (on Dax €5, today at 14:02 Utc +2 is plotted correctly (there was a signal even the previous candle, but the entry price was never reached), the 1-minute bar at 14:03 (the second 1-minute bar only can see the signal, as it’s generated when the 2-minut bar closes, unless there’s a previous adjacent signal) places the pending order, which is immediately executed.
As you can see from pic BB2, another signal was plotted on the 2-min bar today at 09:18 Utc+2. The second pending order was placed at 09:20 (the first 1-minute bar AFTER the 2-min bar) and it entered at 09:21.
Being based on signals showing on the 2-min TF, the pending orders on the 1-min bar can be placed:
- on the second (or last) 1-min bar of the 2-min bar, since signals are only updated when the 2-minute bar closes
- on the first 1-min bar of the 2-min bar AFTER the 2-min bar that originated the signal, for the opposite reason, since the signals show on the last 1-min bar of the 2-min bar, the first 1-min bar of each 2-min bar still has the PREVIOUS 2-min bar VALID.
If you remove UPDATEONCLOSE, you can see the difference.
If there’s still something incorrectct, please:
- post the code you used
- post the name of the instrumend traded
- post the date and hour of both the 2-min and 1-min candles involved
so that we can replicate any issue.