I have something like this. But it dossent take a single trade.
DefParam CumulateOrders=False
// Variables to store the low and high price of the first candle
If OpenTime = 091500 then
LowCandle = Low
HighCandle = High
CandleRange = HighCandle – LowCandle // Calculate the range of the 09:15 candle
EndIf
// Execute buy order if the current price touches or goes below the LowCandle
// AND the time is between 09:15 and 12:00
If Time >= 091500 and Time <= 120000 then
If Low <= LowCandle then
// Place buy order
Buy 1 contract at Market
// Assuming we’re using a platform that allows capturing the last trade price
LastTradePrice = Close // or the appropriate function to get the entry price
// Set stop loss at the distance of the candle range below the entry price
SET STOP LOSS (LastTradePrice – CandleRange) // Correctly set the stop loss
// Set take profit at the high of the 09:15 candle
SET TARGET PROFIT (HighCandle) // Correctly set the take profit
EndIf
EndIf