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

[amibroker] Re: help needed - afl for PDI and MDI crossover



PureBytes Links

Trading Reference Links

--- In amibroker@xxxxxxxxxxxxxxx, "Prashant Nayak" <pnayak@xxx> wrote:
>
Hi,

The MDI, PDI Cross should be something like this,

P = PDI(14);
M = MDI(14);
A = Cross(P,M);

Hopefully this can help.



> Hi Friends,
> 
> Like RSI forecaster can anybody help me make an afl for PDI and MDI 
> crossover. I give below the RSI forecaster afl. 
> 
> // An all purpose routine to find the price
> // necessary to move an indicator to a GOAL.
> //
> // This should work for virtually any indicator,
> // built in or otherwise. It's demonstrated
> // here using RSI & BBand's ...
> //
> // Note: It will appear to use future quotes
> // because of the down shifting of the
> // price array, but obviously it can't
> // "know" tomorrows price. There's
> // probably a way to rectify this but
> // I was more concerned with the rest
> // of the process.
> //
> // The maximum iterations have arbitrarily been
> // set to 200 which is undoubtedly overkill
> // as I've yet to see anything take 200 even
> // when tolerance was set to 0 on datastreams
> // with very high prices.
> //
> // For real usage the saving of i in j and the
> // accuracy calculation can be tossed as they
> // were only put in for demonstration purposes
> //
> // ***********************************************
> //
> // This Routine requires the following things
> //
> // P0 = A price array or synthetic
> //
> // Goal = The goal value of the indicator
> //
> // Acc = An accuracy level for the calculations
> //
> // Set this to the order of magnitude
> // that you want. For example if you want
> // accuracy in calculated price to within
> // 0.01 then set it 0.01. It can even
> // be set to 0 which will force AB to
> // calculate until it can't find any
> // further improvements (Usually between
> // 150-170 iterations) but this is semi
> // useless as improvements relative to
> // price granularity have long since
> // been gone by.
> //
> // The lower you set it the longer it
> // will take but it's pretty quick
> // (Usually between 15-30 iterations)
> // unless you set it at 0.
> //
> // ***********************************************
> //
> // Note: Some goals are virtually unattainable on
> // the next bar, especially on the downside
> // as they would require a negative price
> // which is what this routine will show if
> // that is what is required.
> //
> // ***********************************************
> 
> P0 = C;
> x=EMA(RSI(14),3);
> Acc = 0.0001;
> 
> LVBI = LastValue(BarIndex());
> Mult = 1;
> 
> // ***********************************************
> // Shift Price up by n orders of magnitude to make
> // it >= 1. This is useful to increase
> // accuracy on very low priced datastreams
> // such as the JY.
> // ***********************************************
> for (i = 0; i < 10; i++)
> {
> if (P0[LVBI] >= 1)
> i = 99;
> else
> Mult = Mult * 10;
> }
> // ***********************************************
> 
> P1 = Ref(P0, 1) * Mult;
> UpDn = 100 * P1[LVBI];
> 
> for (i = 0; i < 200; i++)
> {
> 
> Calc = P1;
> Calc = RSIa(P1, 14);
> 
> Goal = 89.66;
> 
> if (Calc[LVBI] < Goal)
> P1[LVBI] = P1[LVBI] + UpDn;
> else
> P1[LVBI] = P1[LVBI] - UpDn;
> UpDn = UpDn / 2;
> if (UpDn <= Acc)
> {
> j = i;
> i = 99999;
> }
> }
> 
> Accuracy = 100 * (abs(Goal - Calc) / Goal);
> 
> Filter = BarIndex() == LVBI;
> 
> AddColumn(Mult,
> "Multiplier", 1.0);
> AddColumn(Calc[LVBI - 1] / Mult, "Curr Ind Val", 1.9);
> AddColumn(Goal / Mult, "Goal Ind Val", 1.9);
> AddColumn(Calc[LVBI] / Mult, "Calc Ind Val", 1.9);
> AddColumn(j,
> "Iterations", 1.0);
> AddColumn(Accuracy, "Accuray (%)", 1.9);
> AddColumn(Ref(P1, -1) / Mult, "Todays Price", 1.9);
> AddColumn(P1 / Mult, "Goal
> Price", 1.9);
> 
> Appreciate feedback and help.
> 
> pras
>




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/4It09A/fOaOAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/