Happy bro, satish bro, anant bro and HappyLife thanx for your help, my code is working now,
Happy_Singh that line u shared above seemed to have fixed the problem.
I have another problem now, Buy is getting generated multiple times, I only want it to generate once after firstbarofdayhigh is broken.
So I am sharing this code with everyone, the code is very basic, but for new guys like me it took me 3 days to fix it.
// This Code is not 100% error free
// This Code is made on ORB concept of break of 15 min candle high, it works fine on 3 min 5 min but has problems on 1 min as Opening values are lost.
//OBJECTIVE /OUTCOME of this code
//Compare Price of 2 Candles AND Compare it with opening candle High AND then take subsequent action
// If Price breaks high of opening candle in second candle code should check and exit, after that no need to keep comparing
// If price does not break high in 2nd candle or subsequent n candles. it should keep check until a breakout and then break/exit
newday = Day() != Ref( Day(), -1 );
firstbarOfDayOpen = ValueWhen( newday, Open );
firstbarOfDayHigh = ValueWhen( newday, High );
firstbarOfDayLow = ValueWhen( newday, Low );
firstbarOfDayClose = ValueWhen( newday, Close );
GfxTextOut( "First Bar High Value is " + firstbarofDayHigh, 20, 20 );
GfxTextOut( "First Bar Low Value is " + firstbarofDayLow, 20, 40 );
z=0;
if (z<1)
{
if (High[BarCount-1]> SelectedValue(FIRstbarofdayhigh))
{
GfxTextOut( "Higer Bar is Current Bar " + H[BarCount-1], 20, 60 );
y=High[BarCount-1];
GfxTextOut( "Sunny Your Trade Executed @ " + y, 20, 80 );
z=1;
}
if (High[BarCount-1]< SelectedValue(FIRstbarofdayhigh))
{
GfxTextOut( "Sunny is Waiting for a trade " + H[BarCount-1], 20, 80 );
}
}