Hi all,
I am not sure the coding gives me what I thought it was.
In summary, I expect the code to provide me with the high and low between 0745am and 0759am -minute bar. It would then trigger a buy or sell if the market hits 5 points below those bars’ high or low.
For example: On November 23rd the high and low of the DAX between 07:45am and 07:59am was 15,961.4 and 15948.4. This would mean a buy is triggered at 15,966.4 (15,961.4 + 5 points) and a sell would be triggered at 15943.4 (15948.4 – 5 points).
The trade triggered a sell at 15946.4 which is 3 points less than it should do and at no point did it reach 15943.4 to trigger a sell but the system triggered a sell at 08:01 at 15946.4 and proceeded to lose 20 points. I note that all the entries happen at the start of a new bar so I believe it will only ever trigger at the close of previous bar but I don’t understand why it triggered in the first place if the buy/sell at high/low + 5 is working properly.
Any help is greatly appreciated and thanks for all the assistance provided so far 🙂
DEFPARAM cumulateOrders = false
//—————————————-
timeframe (1 minute)
OTD = Barindex – TradeIndex(1) > IntradayBarIndex //one trade X day
startHour = 080000
cTime = time >= startHour
//——————————————————
if openTime = 074500 then
myHighest = high
myLowest = low
endif
if openTime >= 074500 and openTime <=075959 then
myHighest = max (myHighest,high)
myLowest = min (myLowest,low)
endif
//————————————————————-
if not onMarket and cTime and OTD then
IF close > myHighest THEN
buy 1 contract at myHighest + (5*pointSize) limit
ELSIF close < myHighest THEN
buy 1 contract at myHighest + (5*pointSize) stop
ENDIF
IF close > myLowest THEN
sellShort 1 contract at myLowest – (5*pointSize) stop
ELSIF close < myLowest THEN
sellShort 1 contract at myLowest – (5*pointSize) limit
ENDIF
endif
//—————————————————————-
SET STOP pLOSS 20
set target pProfit 40