Darvas box 3bar or 20bar?

#1
Hi friends

here is a darvas box chart.
it uses 50ma for primary trend guidance


we can have 3 periods or 20 periods for darvas box -according to timeframe

please provide your valuable comments
regards
ford
 
Last edited:
#2
hello ford,

i m using Darvas box afl...(Kindly provide the above AFL CODE in the Picture)

Thanx you



Code below :-



/*
MS Darvas Box with Exploration
==============================


Translate from http://trader.online.pl/MSZ/e-w-Darvis_Box.html

- Improve scripting
* Allow Darvas Box Color/Style Changing
- Exploration
* Scan Price From .. To
*/
SetChartOptions( 0, chartShowArrows|chartShowDates );

_SECTION_BEGIN("Price Chart");

_N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
PriceStyle = GetPriceStyle();
PriceStyleOpt = ParamStyle("Price Style")|PriceStyle;

if (PriceStyle==styleCandle)
Plot( C, "", colorBlack, PriceStyleOpt);
else
Plot( C, "", IIf( Close >= Ref(C, -1), colorBlue, colorRed ), PriceStyleOpt);

_SECTION_END();

_SECTION_BEGIN("Darvas Box");

Periods= Param("Darvas Periods",5,5,260);

boxHigh = Ref(H,-3)>=Ref(HHV(H,Periods),-4) AND
Ref(H,-3)>Ref(H,-2) AND Ref(H,-3)>Ref(H,-1) AND Ref(H,-3)>H;

Topbox=ValueWhen(boxHigh, Ref(H,-3));
Botbox=ValueWhen(boxHigh,LLV(L,4));


/*=========================
- Allow color change
- Style change
==========================*/
Plot(TopBox, "Top", ParamColor("Box Top Color", colorRed), ParamStyle("Box Top Style"));
Plot(Botbox, "Bot", ParamColor("Box Bottom Color",colorBlue), ParamStyle("Box Bottom Style"));

_SECTION_END();

_SECTION_BEGIN("Exploration");

//== Price Increment Value - depend on different country
Inc = 0.1;


//== Set the Price Range for stock to scan
PriceFrom = Param("Price From:", 5, 0.1, 200, Inc);
PriceTo = Param("Price To:", 100, 0.1, 200, Inc);

/*
MAV - Moving Average of Volume
Buy - Default 20 days
Sell - default 10 days

Filter:
Buy: Today Buy Volume must be > N time of Buy MAV.
(Buy Up required Huge push force)
The previous Day High must be below the Darvas Top and Today must close above Darvas Top

Sell: Today Sell Volume must be > N time of Sell MAV
(Sell Down required small pull force)
The previous Day Low must be above the Darvas bottom and Today must close below Darvas Low

*/
Buy_MAPds = Param("Buy: MAV. Periods", 20, 1, 260);
Buy_VxMAV = Param("Buy: V > NxMAV", 2, 0, 20, 0.1);
Sell_MAPds = Param("Sell: MAV. Periods", 10, 1, 260);
Sell_VxMAV = Param("Sell: V > NxMAV", 1, 0, 20, 0.1);

BuyMAV = MA(V, Buy_MAPds);
SellMAV = MA(V, Sell_MAPds);

/* Rule to Filter
-
- The previous Day High must be inside the Darvas Top and Today must close above Darvas Top

*/
Buy = Ref(H, -1) <=TopBox AND C>TopBox AND (V>Buy_VxMAV*BuyMAV);
Sell = Ref(L, -1) >=Botbox AND C<Botbox AND (V>Sell_VxMAV*SellMAV);


Filter = (Buy OR Sell) AND (C>=PriceFrom AND C<=PriceTo);

AddTextColumn(FullName(), "Security", 1.0, colorDefault, colorDefault, 200);
AddTextColumn(WriteIf(Buy, "Buy", WriteIf(Sell, "Sell", "-")), "Trade", 1.0,
colorYellow,
IIf(Buy, colorGreen, IIf(Sell, colorRed, colorDefault)), 50);
AddColumn(C, "Price", 0.3, colorDefault, colorDefault, 60);
AddColumn(V, "Volume", 1.0, colorDefault, colorDefault,80);

_SECTION_END();

_SECTION_BEGIN("Moving Averages");
//-- Author: KelvinHand
//TP - Typical Price (H+L+C)/2
//MP - Median Price (H+L)/2
//WP - Weight Price (H+L+C+C)/4


MAType = ParamList("Type", "SMA,EMA,WMA,TSF,DEMA,TEMA,LinearReg,Wilders");
Periods = Param("Periods", 20, 1, 500 );
iPrice = ParamList("Price", "C,O,H,L,MP,TP,WP");

Shift = Param("Shift", 0, -50, 50 );

cColor = ParamColor("Color", ColorCycle);
iStyle = ParamStyle("Style", styleLine, maskAll);


switch (iPrice)
{
case "O" : p = Open; break;
case "H" : p = High; break;
case "L" : p = Low; break;
case "MP" : p = (H+L)/2; break;
case "TP" : p = (H+L+C)/3; break;
case "WP" : p = (H+L+C+C)/4; break;
default: p = Close; break;
}


switch (MAType)
{
case "EMA": iMA = EMA( P, Periods ); break;
case "WMA": iMA = WMA( P, Periods ); break;
case "DEMA": iMA = DEMA( P, Periods ); break;
case "TEMA": iMA = TEMA( P, Periods ); break;
case "Wilders": iMA = Wilders( P, Periods ); break;
case "TSF": iMA = TSF( P, Periods ); break;
case "LinearReg": iMA = LinearReg( P, Periods ); break;


default: iMA = MA( P, Periods ); break;
}

ShortName = MAType+Periods+iPrice;
if (Shift !=0)
ShortName = ShortName + "x"+Shift;

Plot( iMA, ShortName, cColor, iStyle, 0, 0, Shift);
_SECTION_END();
 
#3
hi
basically it is the samething.
periods is changed from 5 to 3 or 20.

what you are using th best afl for darvas box.
only problem is it doesnt have dynamic stoploss

regards
ford
 

Similar threads