I have been trying to add signals to the Range High and Low that I've plotted. I want the respective Buy and sell signals whenever the price crosses above or below the N days High Low. Here I have used the cross function but have also tried the same using comparison operators on close and RH/RL. None of them is working. the code does not give any errors but it does not plot any signals on chart either. What am I doing wrong here?
/*
Objective:
1. add chart settings
2. add price
3. consider range high and low of previous 4 days
4. add lines to the highest and lowest points.
5. add signals when price crosses above or below the lines
*/
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates); //Enables the X-axis to the chart
Plot(Close,"Price",colorDefault,styleCandle);
_SECTION_END();
_SECTION_BEGIN("RHRL");
RH = Plot(Ref(HHV(High, 4),-1),"RH", colorred);
RL = Plot(Ref(LLV(Low, 4), -1),"RL", colorGreen);
Buy = Cross(Close,RH);
Sell = Cross(RL, Close);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, H, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,H, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, L, Offset=-40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,L, Offset=-45);
_SECTION_END();