It seems that all of the criteria is working properly, except for the one that checks for the price.
That is:
if (High[0] >= rangeHigh + pipBuffer)
{}
// Setting overnight range
if (ToTime(Time[0]) == ToTime(endRangeHr,endRangeMin,00))
{
startRange = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 2, 0, 0);
theHigh = HighestBar(High, CurrentBar - Bars.GetBar(startRange));
rangeHigh = High[theHigh];
theLow = LowestBar(Low, CurrentBar - Bars.GetBar(startRange));
rangeLow = Low[theLow];
//DrawText("RangeHigh" + CurrentBar, true, rangeHigh, rangeHigh + 1 * TickSize, Color.Blue);
}
// Reset Flag
if (Time[0] > startRange)
{
restrictTrade = false;
}
if (direction == TrendDirection.NoTrend)
{
if (LongEntryOCO == null
&& ShortEntryOCO == null
&& ToTime(Time[0]) >= ToTime(endRangeHr, endRangeMin, 00)
&& ToTime(Time[0]) < ToTime(removeOrderHr, removeOrderMin,00)
&& High[0] >= rangeHigh + pipBuffer
&& restrictTrade == false)
{
LongEntryOCO = EnterLong(positionSize, "BreakoutLongOCO");
Print("***On " + Time[0] + ", the Range High + Pip Buffer is " + (rangeHigh + pipBuffer));
//Print("On " + Time[0] + ", the Entry Order is " + LongEntryOCO);
restrictTrade = true;
}
Could you please point me in the right direction for what is going on?
Thank you very much for your help.

Comment