Combination of PDH and PDL with IBH and IBL

Hi guys,
I have to implement a simple system.
I have to generate signal for IB break when market opens beyond the yesterday range.
I have implemented the IBH, IBL, PDH, PDL values.

_SECTION_BEGIN("IB High Low");
tn = TimeNum();

// define start/end hours in TimeNum format
StartTime = 091500;
Endtime = 100000;

// these conditions are true when TimeNum of the bar equals startime/endtime
StartBar = tn == StartTime;
EndBar = tn == Endtime;

// on the end bar we read the value of highest high or lowest low since the start bar
IBH = ValueWhen( EndBar, HighestSince( StartBar, High ) );
IBL = ValueWhen( EndBar, LowestSince( StartBar, Low ) );

PDH = TimeFrameGetPrice("H",inDaily,-1);
PDL = TimeFrameGetPrice("L",inDaily,-1);
CDO = ValueWhen(Day()!=Ref(Day(),-1),O);  /*current day open. All values are successfully captured till here. */

Openn = IIf( ( CDO > PDH OR CDO < PDL) , 1, 0 );
{
GfxTextOut( "Openn : " + Openn, 10,120);
}

/*Signal generation part below*/

Buy = Cross(H,IBH);  
Sell = Cross(IBL,L);

Short = Sell;
Cover = Buy;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Cover=ExRem(Cover,Sell);
Sell=ExRem(Sell,Cover);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

Filter = Buy OR Sell;

_SECTION_END();

I have to generate a signal when current day IBH or IBH breaks only when current day open is beyond yesterday's range.
i.e. values used will be IBH, IBL, CDO, PDH and PDL.

I know it is very simple but I am not getting the function to combine this condition.
Kind support is much appreciated.
Thank you for the cooperation.

-Nandkishor

@Spectra,

Posting questions now requires that you have registered your forum ID on the AmiBroker site. This will give you a special badge.

Please search "verified badge" and follow the steps.

As a hopefully helpful hint to your problem...

Cond1 =  Cross(H,IBH);
Cond2 = CDO > PDH;
Buy =  Cond1 and Cond2;

Hi Spectra,
Thanks for the help.
I have tried this but it is showing multiple BUY, SELL signals and signal at start of the day.

image

How to remove multiple BUY, SELLS.
What function has to be used if I have to close the trade at 14:30.

I am using following -

Buy = Cross(H,IBH) AND CDO > PDH;  
Sell = Cross(IBL,L) AND CDO < PDL;


Short = Sell;
Cover = Buy;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Cover = ExRem(Cover,Short);
Short = ExRem(Short,Cover);


PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

Filter = Buy OR Sell;

Thanks a lot once again for the help.

@Spectra, please do the "verified badge" search and follow those steps first.

1 Like