MetaStock™ Zone Tworzenie Sytemów Trader Shop Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

 

VIMA by R.G. Boomer
R.G. Boomers' variable-interval moving average, or VIMA, described elsewhere in this issue, can be implemented as a function-cum-indicator pair in TradeStation's EasyLanguage as shown here. The function VimaLength returns the recommended length for the simple average at the current bar, given the set of difference intervals to use, the amount of history to consider, and the lengths of the pair of bracketing averages.

The indicator VIMA provides the actual values of the inputs for the VimaLength function and plots the variable interval moving average based on the dynamically changing average length, or interval, from bar to bar. Default values for the inputs are included in the indicator and can be edited by the user at the time the indicator is applied to a chart.

Instead of an indicator, the VimaLength function could also be called by a user-created trading strategy with similar inputs. TradeStation's backtesting engine could then be used to not only quickly find the best pair of averages to use, but to optimize the other two inputs as well.

The code for both the function and the indicator will be available for download at www.tradestation.com. Look for the file VIMA.ELS.


Type : Function, Name : VIMALength

inputs:
MaxLength1(numericsimple),
{"interval" will vary from 2 days to (MaxLength1 + 1)
days; equivalently, Length1 below will vary from 1 day to MaxLength1 days}

Length2(numericsimple),
{number of historical RESULTS to consider for each max/min calculation;
actual number of historical data points used may be more than this}

ShortestVIMALength(numericsimple),
LongestVIMALength(numericsimple);

variables:
VIMAOsc( 0 ),
Length1( 0 ),
MaxDiff( 0 ),
MinDiff( 0 ),
NormDiff( 0 ),
VIMAOscMax( 0 ),
VIMAOscMin( 0 ),
VIMAOscNorm( 0 ),
VIMALengthRange(LongestVIMALength - ShortestVIMALength);

VIMAOsc = 0;
for Length1 = 1 to MaxLength1
begin
MaxDiff = Highest(Close - Close[Length1], Length2);
MinDiff = Lowest(Close - Close[Length1], Length2);
NormDiff = (Close - Close[Length1] - MinDiff) / (MaxDiff - MinDiff);
VIMAOsc = VIMAOsc + NormDiff;
end;

VIMAOscMax = Highest(VIMAOsc, Length2);
VIMAOscMin = Lowest(VIMAOsc, Length2);
VIMAOscNorm = (VIMAOsc - VIMAOscMin) / (VIMAOscMax - VIMAOscMin);
VIMALength = ShortestVIMALength + Round(VIMAOscNorm * VIMALengthRange, 0);

 


Type : Indicator, Name : VIMA

inputs:
MaxLength1( 3 ),
Length2( 20 ),
ShortestVIMALength( 3 ),
LongestVIMALength( 6 );

variables:
CurrentVIMALength( 0 );

CurrentVIMALength = VIMALength( MaxLength1, Length2,
ShortestVIMALength, LongestVIMALength);

Plot1(Average(Close, CurrentVIMALength));

 

t-i-VIMA.gif
--Ramesh Dhingra, Product Manager, EasyLanguage

TradeStation Technologies, Inc.
(formerly Omega Research, Inc.)

A wholly owned subsidiary of TradeStation Group, Inc.
http://www.TradeStation.com

Source / From: TOP
http://www.traders.com

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie niesie ze sob± ryzyko poważnych strat finansowych!