Quantcast
Channel: Market Calls
Viewing all articles
Browse latest Browse all 2070

Kase Dev Stops V1 – Amibroker AFL Code

$
0
0

What is a Kase Dev Stops?

Kase Dev Stops is a volatility based stop and Dev Stops refers to the Standard Deviation based Stops and uses ATR based volatility. Kase DevStops provide a statistically sound basis upon which to place stop-loss and stop and-reverse orders.

“A STOP THAT IS GOING TO PERFORM OPTIMALLY MUST CONSIDER THE VARIABILITY OF RANGE.”

CYNTHIA KASE
//Kase Dev Stop V1 - translated from Tradingview Pinescript
//Credits : https://www.tradingview.com/script/wF0Cm55t-Kase-Dev-Stops/
//Coder : Rajandran R
//Website : www.algomojo.com / www.marketcalls.in
//Date : 5th Mar 2022

_SECTION_BEGIN("Kase Dev Stop v1");

Length = param("Length",30,5,100,5);
Length1 = param("Length1",20,5,100,5);

inpStdDev1    = 0.0;         // Deviation 1
inpStdDev2    = 1.0;         // Deviation 2
inpStdDev3    = 2.0;         // Deviation 3
inpStdDev4    = 3.0;         // Deviation 4

RWH = (high - Ref(Low,-Length)) / (atr(Length) * sqrt(Length));
RWL = (Ref(high,-Length) - low) / (atr(Length) * sqrt(Length));

Pk = wma((RWH-RWL),3);

trendcolor = IIf(pk>0,colorGreen,colorRed);

AVTR = ma(hhv(high,2) - llv(low,2), Length1);
SD = stdev(hhv(high,2) - llv(low,2),Length1);

val0 = IIf(pk>0, hhv(high-AVTR-inpStdDev1*SD,Length1), llv(low+AVTR+inpStdDev1*SD,Length1));
val1 = IIf(pk>0, hhv(high-AVTR-inpStdDev2*SD,Length1), llv(low+AVTR+inpStdDev2*SD,Length1));
val2 = IIf(pk>0, hhv(high-AVTR-inpStdDev3*SD,Length1), llv(low+AVTR+inpStdDev3*SD,Length1));
val3 = IIf(pk>0, hhv(high-AVTR-inpStdDev4*SD,Length1), llv(low+AVTR+inpStdDev4*SD,Length1));




Plot(val0,"Val0",trendcolor,styleDots);
Plot(val1,"Val1",trendcolor,styleDots);
Plot(val2,"Val2",trendcolor,styleDots);
Plot(val3,"Val3",trendcolor,styleLine);

SetChartOptions(0, chartShowArrows | chartShowDates); //x-Axis will be plottted
//plot the candles
Plot(Close,"Close",colorDefault,styleCandle | styleNoTitle);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));


Buy = pk>0 AND Close>val0;
Sell = (pk<0 AND Close<val0) OR (pk>0 AND Close<val3);

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

Short = (pk<0 AND Close<val0);
Cover = (pk>0 AND Close>val0) OR (pk<0 AND Close>val3);

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

//Non Repainting  - Signals happens only after the close of the current
Buy = Ref(Buy,-1);
Sell = Ref(Sell,-1);
Short = Ref(Short,-1);
Cover = Ref(Cover,-1);

BuyPrice = ValueWhen(Buy,Open);
SellPrice = ValueWhen(Sell,Open);
ShortPrice = ValueWhen(Short,Open);
CoverPrice = ValueWhen(Cover,Open);

SetPositionSize(1*RoundLotSize,spsShares);
//SetPositionSize(200000,spsValue);

/* Plot Buy and Sell Signal Arrows */
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);

PlotShapes(Sell * shapestar, colorBrightGreen, 0, High, 12);
PlotShapes(Cover * shapestar, colorRed, 0, Low, -12);




_SECTION_END();

Nifty Futures Hourly Long Only Trading System – Equity Curve

Nifty Futures Hourly Long Only Trading System – Drawdown

The post Kase Dev Stops V1 – Amibroker AFL Code appeared first on Marketcalls.


Viewing all articles
Browse latest Browse all 2070

Trending Articles