MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

A B C D E F G H I J K L M N O P R S T U V W Y Z #

MACD MS Look Ahead
How to create a BarsFuture(), i.e. a BarsSince() that finds the next true bar instead
of the last true bar? After creating a binary wave, I would like to find the distance (in bars) to the _next_ true value relative to the current bar (which could be anywhere from 3 to hundreds of bars away), any idea how to do that?

I want to use it in further calculations to create an indicator, not a predictive one of course, but to describe the price data.

Failed attempts so far:
Ref() - needs a constant
Nested If()'s - Can't get any accuracy since using 100's of if()'s is not workable
Ref(), LastValue() & PREV - looked very promising by I haven't managed to get it to work.

Any and all help greatly appreciated!



Change your thinking and count from the second event back to the first instead of forward from the first to the second. The results will be the same.

IMO this is akin to the different perspective between "set-up today and buy tomorrow", and "set-up yesterday and buy today". The reality doesn't change but your one's perspective does. One is in the present looking into the future and the other is in the present looking into the past. It just so happens that the MetaStock tools are better suited to a "in the present looking backward" perspective.

Just my opinion. I don't want to start a philosophical discussion but rather to point out that a little lateral thinking goes a long way in solving MetaStock problems


> to point out that a little lateral thinking goes a long way

I'm almost horizontal, and I _still_ don't get it!-)

I'm sure I'm missing something obvious, but:

I'm not calculating the distance between two events, but instead from the _current bar_ until the next event. Knowing this distance, I then plan to calculate & plot a value _at each_ current bar, and this value will change for every bar since distance (and price) changes at each bar. If I 'wait' with the calculation until the next event, I can only plot a value at that event, but not at the dozens of bars between events.

Is this even possible in MS? Or is it just impossible to make me get it?-)


This is from another group. See if it gives you any ideas.


a user asked if the tommorows close could calculated which would cause the MACD to cross the 0 line, or the trigger line. we worked it out and got:

MACD MS Look Ahead I


{C required for trigger line crossover}

{C required for 0 value MACD}




It seems that the formula below for predicting the closing price needed for the signal line to cross the MACD is not as accurate as it could be. The reason, at least with my version of MS (7.03), is that the MACD in MetaStock is based on EMA's that are slightly off the assumed 12/26 periods. The MACD EMA's are calculated using proportions of 0.075 and 0.15 instead of 2/13 and 2/27. The latter is what the code you posted uses for the 'top' variable, hence the small errors that occur when tested against the MS canned MACD.

I've taken the liberty of revamping the code so that the predictive prices work for my version of MS.



MACD MS Look Ahead II

x:=0.15; y:=0.075;
a:=a*(1-x); b:=b*(1-y); top:=b-a;
{C required for signal/MACD crossover}



Thanks!! You never cease to amaze me. I appreciate the explanation as well.


Hi Preston

> Thanks!! You never cease to amaze me. I appreciate the explanation as well.
> Preston

There was nothing amazing about reading the maual. That's what alerted me to the cause of the problem. The problem itself came to my notice because I suggested the code to somone in another group as a solution to their problem. It was only when they reported back that the results were not accurate that I looked a little deeper.



Source / From: TOP

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 i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!