Summarizing my understanding of the trading rules.
- Identify the bar with Lowest OBV for the day.
- Mark High and Low of the corresponding bar
- Calculate the 36 period EMA
- Long if Price is above marked High of the bar with lowest OBV and also 36EMA
- Short if Price is below marked Low of the bar with lowest OBV and also 36EMA
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_BEGIN("VKSLline V 1.01");
n=Day() != Ref(Day(), -1);
Period= Param("Periods", 36,1,50,1);
Period= Optimize("Periods", Period,1,50,1);
a=LowestSince(n,OBV());
hh=ValueWhen(OBV()==a,H);
ll=ValueWhen(OBV()==a,L);
Sig = OBV()==a;
hr = ValueWhen(OBV()==a,Hour());
mn = ValueWhen(OBV()==a,Minute());
e36 = EMA(C,Period);
res=Max(e36,hh);
sup=Min(e36,ll);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);
col = IIf(avn==1,colorGreen,colorRed);
Buy = Cross(C,Ref(Res,-1));
Short = Cross(Ref(Sup,-1),C);
Buy=ExRem(Buy,Short);
Short=ExRem(Short,Buy);
Sell= Short ;
Cover= Buy ;
Plot(tsl,"\nVKSL ",col,styleThick);
Plot(e36, "", colorDarkGrey);
//y=5;
//PlotOHLC(y,Y+10,y,y,"",col,styleOwnScale|styleNoLabel|styleCloud,0,200,0);
PlotShapes( IIf( Sig, shapeSmallCircle, shapeNone ), colorWhite, 0, L, Offset = -35 );
PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorGreen, 0, L, Offset = -20 );
PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorLime, 0, L, Offset = -30 );
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, 0, L, Offset = -25 );
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorRed, 0, H, Offset = -25 );
PlotShapes( IIf( Short, shapeSquare, shapeNone ), colorRed, 0, H, Offset = 20 );
PlotShapes( IIf( Short, shapeSquare, shapeNone ), colorOrange, 0, H, Offset = 30 );
PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), colorWhite, 0, H, Offset = -25 );
PlotShapes( IIf( Cover, shapeUpArrow, shapeNone ), colorBlue, 0, L, Offset = -25 );
_SECTION_END();