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

[amibroker] Re: RSI - calculating an exit


  • Date: Thu, 25 Feb 2010 13:54:49 -0000
  • From: "cvanhaesendonck" <carl.van@xxxxxxxxxx>
  • Subject: [amibroker] Re: RSI - calculating an exit

PureBytes Links

Trading Reference Links

Your findings works very well - thanks!

Carl

--- In amibroker@xxxxxxxxxxxxxxx, "ricko8294_98" <ricko@xxx> wrote:
>
> 
> 
> Here is some code I found somewhere and saved.
> 
> /*
> As an example, to calculate tomorrow's close to give an RSI(14) of 25%:
> nextClose = NextRSI(BarCount- 1, 14, -1, 25);
> or to calculate tomorrow's RSI for a close of $1.20:
> nrsi = NextRSI(BarCount- 1, 14, 1.20, -1);
> */
> 
> 
> function NextRSI( bar, period, nextClose, nrsi )
> {
>     if ( bar >= period + 1 )
>     {
>         clb = Close[bar];
> 
>         if ( clb == Close[bar-1] )
>             Close[bar] = Close[bar] + 0.0001; // To avoid "0/0" term
> 
>         rsiArr = RSI( period );
> 
>         rval = 0;
> 
>         rs = 100 / ( 100 - rsiArr[bar] ) - 1;
> 
>         rsp = 100 / ( 100 - rsiArr[bar-1] ) - 1;
> 
>         cgn = Close[bar] - Close[bar-1] ;
> 
>         cls = -cgn;
> 
>         if ( cgn < 0 )
>             cgn = 0;
> 
>         if ( cls < 0 )
>             cls = 0;
> 
>         alp = 0;
> 
>         if ( rsp - rs )
>             alp = ( cls * rs - cgn ) / ( ( period - 1 ) * ( rsp - rs ) );
> 
>         agp = rsp * alp;
> 
>         als = ( alp * ( period - 1 ) + cls ) / period;
> 
>         agn = ( agp * ( period - 1 ) + cgn ) / period;
> 
>         if ( nextClose >= 0 )
>         {
>             cgn = nextClose - Close[bar];
>             cls = -cgn;
> 
>             if ( cgn < 0 )
>                 cgn = 0;
> 
>             if ( cls < 0 )
>                 cls = 0;
> 
>             rsx = ( agn * ( period - 1 ) + cgn ) / ( als * ( period - 1 ) + cls );
> 
>             rval = 100 - ( 100 / ( 1 + rsx ) );
>         }
>         else
>         {
>             rsn = 100 / ( 100 - nrsi ) - 1;
> 
>             if ( nrsi < rsiArr[bar] )
>                 rval = Close[bar] - ( agn * ( period - 1 ) ) / rsn + als *
>                        ( period - 1 );
>             else
>                 rval = Close[bar] + als * ( period - 1 ) * rsn - agn *
>                        ( period - 1 );
>         }
> 
>         Close[bar] = clb; // Restore close array
>     }
> 
>     return rval;
> }
> 
> nextClose = NextRSI(BarCount- 1, 14, -1, 65); 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@> wrote:
> >
> > That sounds like a job for Fred's "Price Predictor" code ( thanks Fred! ). I 
> > have attached it below, you will probably just need to plug your own values 
> > into the Calc and Goal statements.
> > 
> > Steve
> > _________________________________
> > 
> > You supply:
> > 
> > - The array in the first statement ( Assumedly Price )
> > - The Indicator in the Calc = statement
> > - The Goal in the Goal = statement
> > 
> > ... It will return in Explore the value needed in the array in the
> > next bar to have the indicator meet the goal in the next bar.
> > 
> > This is set up for use with a typical MACD but can be easily modified
> > for use with any indicator you can design.
> > 
> > P0   = Close;
> > 
> > Acc  = 0.00001;
> > 
> > LVBI = LastValue(BarIndex());
> > Mult = 1;
> > 
> > for (i = 0; i < 10; i++)
> > {
> >     If (P0[LVBI] >= 1)
> >         i = 99;
> >     else
> >     {
> >         P0 = P0 * 10;
> >         Mult = Mult * 10;
> >     }
> > }
> > 
> > P1   = Ref(P0, 1);
> > UpDn = 100 * P1[LVBI];
> > 
> > for (i = 0; i < 200; i++)
> > {
> >     Calc = EMA(P1,12)-EMA(P1,26);
> >     Goal = EMA(EMA(P1,12)-EMA(P1,26),9);
> > 
> >     if (Calc[LVBI] < Goal[LVBI])
> >         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[LVBI] - Calc[LVBI]) / Goal[LVBI]);
> > 
> > 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 / Mult,           "Calc Ind Val",  1.9);
> > AddColumn(j,                     "Iterations",    1.0);
> > AddColumn(Accuracy,              "Accuray (%)",   1.9);
> > AddColumn(Ref(P1, -1) / Mult,    "Current Array", 1.9);
> > AddColumn(P1 / Mult,             "Needed Array",  1.9);
> > 
> > 
> > ----- Original Message ----- 
> > From: "droskill" <droskill@>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Tuesday, June 10, 2008 1:22 PM
> > Subject: [amibroker] RSI - calculating an exit
> > 
> > 
> > > Let's say that I've got a defined RSI level for an exit - and I'd like
> > > to calculate a target based on that so I can have a stop order in the
> > > market at a specific target.  Is there anyway for me to calculate what
> > > the price would be on a given RSI level?
> > >
> > > Thanks!
> > >
> > >
> > > ------------------------------------
> > >
> > > 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
> > >
> > >
> > >
> > >
> >
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/