[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] coding Ensign's volatility stop - help



PureBytes Links

Trading Reference Links

Did you look at code on AB-TS board where you originally posted this?

Bill
----- Original Message ----- 
From: "vizend" <glorx-yahoo_amibroker_group@xxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, January 26, 2007 12:56 PM
Subject: [amibroker] coding Ensign's volatility stop - help


> Hey all,
> 
> I'm trying to implement the volatility stop study from Ensignsoftware:
> http://charts.dacharts.com/2007-01-22/opm8-33.png
> 
> The idea is that if price close above the VS_upper line then only the
> VS_lower line should be drawn. Similarly, if price closes below the
> VS_lower line then only VS_upper should be drawn. Here I've colored
> them orange (VS_lower) and blue (VS_upper) to tell them apart for
> debugging.
> 
> This is the working code, but there is one thing I still can not get
> to work.
> 
> ATRxMultiplier = Prec(EMA(ATR(1), 9) * 2.5, 1);  // 9 per. EMA of
> ATR_Ensign, x multiplier, 2 sigdigs
> VS_lower = HHV(Close, 9) - ATRxMultiplier;  // for longs, VS line is
> below price
> VS_upper = LLV(Close, 9) + ATRxMultiplier;  // for shorts, VS line is
> above price
> downwave = ExRem(C <= VS_lower, C >= VS_upper); // = 1 on ARRAY1 true,
> then 0 until ARRAY2 true.
> upwave = ExRem(C >= VS_upper, C <= VS_lower);
> in_downwave = Flip(downwave, upwave);  // = 1 on ARRAY1 true, 0 on
> ARRAY2 true, then 1 on ARRAY1 true...
> in_upwave = Flip(upwave, downwave);
>   //VS_lower = HHV( C, BarsSince( in_downwave )) - ATRxMultiplier;
>   //VS_upper = LLV( C, BarsSince( in_upwave )) + ATRxMultiplier;
> Plot(VS_lower, "VS_lower", in_upwave * colorOrange, styleThick);
> Plot(VS_upper, "VS_upper", in_downwave * colorBlue, stylethick);
> Plot(C, "price_dv", colorWhite, styleBar);
> 
> 
> The lower volatility stop line, VS_lower is supposed to be this (it's
> commented out):
> VS_lower = HHV( C, BarsSince( start_of_upwave )) - ATRxMultiplier;
> 
> which means that it's using the highest close from the point where
> price closed above the upper volatility stop line, VS_upper.
> 
> Same thing for VS_upper, which should be:
> VS_upper = LLV( C, BarsSince( start_of_downwave )) + ATRxMultiplier;
> 
> The problem is that when I enable these 2 changes my VS lines look all
> weird.  However, if I look at what the values are supposed to be in
> the Interpretation window they're correct.  For some reason they're
> not being plotted correctly.  Here's what I used to compare:
> 
> printf("VS_upper_should_be: %g\n", LLV( C, BarsSince(
> start_of_downwave )) + ATRxMultiplier);
> printf("VS_lower_should_be: %g\n", HHV( C, BarsSince( start_of_upwave
> )) - ATRxMultiplier);
> printf("VS_upper: %g\n", VS_upper);
> printf("VS_lower: %g\n", VS_lower);
> 
> It's kind of a conceptual problem because how do I plot a line which
> starts being drawn when another is crossed?  Thanks for your help.
> 
> opm8
> 
> PS: I posted this already to the amibroker-ts yahoo group but that one
> is completely dead with next to no activity.
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.17.12/655 - Release Date: 1/28/2007 1:12 PM
> 
>
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.12/655 - Release Date: 1/28/2007 1:12 PM