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

Re: divergence in price-indicator (How)



PureBytes Links

Trading Reference Links

Hi, dimitri,

perhaps I am "blind" , but the code for trendlines is written with 
lasvalue

pS = troughBars( s1, per, 1 ) == 0;
endt= lastvalue(ValueWhen( pS, x, 1 ));
startt=lastvalue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = lastvalue(ValueWhen( pS, s1, 1 ) );
startS = lastvalue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS; 

> Stephane,
> Trendlines work for the whole range.
> [Did you see the recent Hang Seng Index example ?]
> Simply remove the Lastvalue, whereever it is and that s it.
> From any trendline equation you can get the slope.
> A positive divergence is when the slope of support of C is negative 
> and the slope of support of RSI is positive.
> Then you may explore, scan, optimize and backtest.
> Dimitris Tsokakis
> [without & Co ] 
> --- In amibroker@xxxx, "nenapacwanfr" <nenapacwanfr@xxxx> wrote:
> > hello,
> > 
> > it is a good subject
> > dimitri & Co have given various example with trendlines, but it 
> works 
> > only with lastvalue
> > and we can't backtest it.
> > of course we can visualize them with the simulator.
> > 
> > one caveat of divergence is that we know it too late...
> > 
> > stephane
> > 
> > 
> > 
> > > How to program in AFL a divergence between the price and and 
> > > indicator such as RSI? Thanks