_SECTION_BEGIN("st gap buy sell");
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
SetBarsRequired(sbrAll,sbrAll);
xx=BarIndex();x=xx;Lx=LastValue(x);
rightStrength=Optimize("R_S",Param("R_S",3,1,50,1) ,1,50,1);
leftStrength=Optimize("L_S",Param("L_S",3,1,50,1), 1,50,1);
function pkID(rightStrength,leftStrength)
{
pk=H>Ref(HHV(H,leftStrength),-1) AND H>=Ref(HHV(H,rightStrength),rightStrength);
return pk;
}
function trID(rightStrength,leftStrength)
{
tr=L<Ref(LLV(L,leftStrength),-1) AND L<=Ref(LLV(L,rightStrength),rightStrength);
return tr;
}
pk=pkID(rightStrength,leftStrength);
tr=trID(rightStrength,leftStrength);
SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0 ,chartShowDates);
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey)));
pkHigh1=Ref(ValueWhen(pk,H,1),-(rightStrength+1));
trLow1=Ref(ValueWhen(Tr,L,1),-(rightStrength+1));
pkHigh0=ValueWhen(pk,H,0);
trLow0=ValueWhen(Tr,L,0);
//Plot(pkHigh1,"",colorBlue,24,Null,Null,0,2,1);
//Plot(trLow1,"",colorRed,24,Null,Null,0,2,1);
Buy = Cross(C,pkhigh1) ;
sell = cross(trlow1,c) ;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Buy[BarCount-1]=Null;
Sell[BarCount-1]=Null;
Cover=Buy;
Short=Sell;
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorWhite, colorWhite ),0, IIf( Buy, Low, High ) );
_SECTION_END();
Comments
Post a Comment