In the strategy for Intraday trades below, I need only one trade active in a day. For eg. If the buy trade is active, then short trade for that day shouldn't be triggered. Similarly, if the short trade has been triggered first in the day, then the buy condition shouldn't be triggered until the day changes.
NewDay = Day()!= Ref(Day(), -1); highestoftheday = HighestSince(newday,HaHigh,1); Lowestoftheday = LowestSince(newday,HaLow,1); ORBH = ValueWhen(afterbreakout0,highestoftheday,1); ORBL = ValueWhen(afterbreakout0,lowestoftheday,1); Plot(ORBH,"",colorlightBlue,styleDots); Plot(ORBL,"",colorOrange,styleDots); ///schematics for long trades HiClose_Cross = Cross(HaClose, ORBH); HiClose_Cross_Value_T = ValueWhen(HiClose_Cross, HaHigh); HiClose_Cross_Value = HiClose_Cross_Value_T + 2; High_Trigger = Cross(HaHigh, HiClose_Cross_Value); High_Trigger_Value = ValueWhen(High_Trigger, HaHigh); ///schematics for Short trades LoClose_Cross = Cross(ORBL, HaClose); LoClose_Cross_Value_T = ValueWhen(LoCLose_Cross, Halow); LoClose_Cross_Value = LoClose_Cross_Value_T - 2; Low_Trigger = Cross(LoClose_Cross_Value, HaLow); Low_Trigger_Value = ValueWhen(Low_Trigger, HaLow); dn = DateNum(); //newDay = dn != Ref( dn,-1); RawBuy = (newDay == 0); RawShort = (newDay ==0); allowtrades = Exrem(newDay, Ref(RawBuy OR RawShort, -1)); ///Trade Activation Buy = RawBuy AND High_Trigger AND TimeNum() > First_Trade_Time AND TimeNum() < No_Trade_Time; Buy = Buy AND Sum(Buy, BarsSince(newDay)+1) <= N; Short = IIf(tradecount == 0, RawShort AND Low_Trigger AND TimeNum() > First_Trade_Time AND TimeNum() < No_Trade_Time, Null); Short = Short AND Sum(Short, BarsSince(newDay)+1) <= N; ///Trade CLosure Sell = 0; Sell = TimeNum() == 150000; Cover = 0; Cover = TimeNum() == 150000;