Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Darvas Box for Amibroker (AFL)
What Does Darvas Box Theory Mean?
A trading strategy that was developed in 1956 by former ballroom dancer Nicolas Darvas. Darvas’ trading technique involved buying into stocks that were trading at new 52-week highs with correspondingly high volumes.
A Darvas box is created when the price of a stock rises above the previous 52-week high, but then falls back to a price not far from that high. If the price falls too much, it can be a signal of a false breakout, otherwise the lower price is used as the bottom of the box and the high as the top.
Screenshots
Similar Indicators / Formulas
Indicator / Formula
//////////begin///////// box1=0; box2=0; SetBarsRequired(10000,10000); procedure fillDarvas(start,end,swap,top, bottom ) { for ( j = start; j < end; j++) { if( box1[j] == swap) box1[j]= top ; else box1[j]= bottom; if(box2[j] == swap) box2[j]= bottom ; else box2[j]= top; } } BoxArr1 = 0; BoxArr2 = 0; StateArray = 0; DBuy = 0; DSell = 0; TopArray = 0; BotArray = 0; tick=0; BoxTop = High[0]; BoxBot = Low[0]; swap=0; state = 0; BoxStart = 0; for (i=0; i<BarCount; i++) { if (state==5) { TopArray[i]=BoxTop; BotArray[i]=BoxBot; if (Low[i]<(BoxBot*(1-tick/100)) || High[i]>(BoxTop*(1+tick/100))) { fillDarvas(BoxStart,i,swap,BoxTop,BoxBot); state = 1; swap = !swap; BoxTop = High[i]; BoxStart = i; } } else { if (High[i]<BoxTop) { if ((state<3) || (Low[i]>BoxBot)) { state++; } else { state=3; } if (state==3) BoxBot=Low[i]; } else { state=1; BoxTop=High[i]; } } StateArray[i] = state; } fillDarvas(BoxStart,BarCount,swap,BoxTop,BoxBot); Buyrule=H>Ref(box1,-1) AND H>Ref(box2,-1) AND Ref(statearray,-1)==5; Sellrule=L<Ref(box1,-1) AND L<Ref(box2,-1) AND Ref(statearray,-1)==5; _SECTION_BEGIN("Darvas box"); //Plot(C,"",1,64); //Plot( box2, "" , 1 + statearray , styleLine ); //Plot( box1, " Status = "+WriteVal(statearray,1.0) , 1 + statearray, styleLine ); Buy=Cover=H>Ref(box1,-1) AND H>Ref(box2,-1) AND Ref(statearray,-1)==5; Short=Sell=L<Ref(box1,-1) AND L<Ref(box2,-1) AND Ref(statearray,-1)==5; Plot(C,"",1,64); Plot( box1, " Status = "+WriteVal(statearray,1.0) , 1 + statearray, styleLine ); Plot( box2, "" , 1 + statearray , styleLine ); PlotShapes(shapeUpArrow*(Buy),colorGreen); PlotShapes(shapeDownArrow*(Sell),colorRed); Plot( Flip( Buy, Sell ), "Trade", colorPaleGreen, styleArea | styleOwnScale, 0, 1 ); Plot( Flip( Sell, Buy), "Short", colorPaleBlue, styleArea | styleOwnScale, 0, 1 ); _SECTION_END(); Buy = Buyrule; statopt = Optimize("statopt var", 3, 1, 5, 1 ); lossopt= Optimize("lossopt var", 5, 3, 10, 1 ); //statopt=5; //lossopt=7; topvalue=IIf(box1>box2,box1,box2); Sellrule2 = (((topvalue-Close)*100/topvalue) > lossopt) AND (statearray == statopt); Sell = Sellrule OR Sellrule2; Short = Sell; Cover = Buy;
0 comments
Leave Comment
Please login here to leave a comment.
Back