Thanks Reberto for your comment
My idea is to implement a code to identify the highest high of uptrend and lowest low of down trend of previous 15 hours ( starting from 01:00 am t0 04:00 pm) . No entry positions before 4 pm.
after 4 pm it allowed to enter position after it already calculated the highest high and lowest low , the entry position conditions are :
buy when the current price = lowest low
sell when the current price = highest high
this is my code , run in 1 hour time frame
// Reset for a new day
if intradaybarindex = 0 then
HighestHigh = 0
LowestLow = 0
endif
// the caculation of highest high price and lowest low price would be during stratitime = 01:00 am to endtime 4:00pm
startime = 010000
endtime = 160000
// allow the code to enter a position until 10:00 pm
lasttime = 220000
// start to caculate the highest high and lowest low of the previous 15 bars when reach bar index 15 of 1 hour timeframe
// calculate the last 15 hours , at 4pm
c1 = intradaybarindex = 15 // this number to be change according to time frame e.g 30 min time frame (for previous 15 hours should be (30 bars)
// Calculate highest high and lowest low of the last 15 hours , at 4:00 pm
IF c1 then
HighestHigh = highest[15](close)
LowestLow = lowest[15](close)
ENDIF
// Conditions to enter long positions
// enter long position after 4pm , and if the current price equal to lowestlow
IF NOT LongOnMarket AND Time > endtime AND Time < lasttime AND close= LowestLow THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
// Conditions to exit long positions
If LongOnMarket AND close= HighestHigh THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
// enter shortposition after 4pm , and if the current price equal to highesthigh
IF NOT ShortOnMarket AND Time > endtime AND Time < lasttime AND close = HighestHigh THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Conditions to exit short positions
IF ShortOnMarket AND close = LowestLow THEN
EXITSHORT AT MARKET
ENDIF
(close) keyword gave me the closing price of candle , while I want the current price to compare it with the value of highest and lowest.
which keyword should I use instead?