PureBytes Links
Trading Reference Links
|
Dear Tomasz,
I chequed the
pk = PeakBars( h, 1, 1 ) == 0;
barno = cum(1);
barsbetweenpeaks = ValueWhen( pk, barno, 1 ) - ValueWhen( pk, barno,
2 );
graph1=barsbetweenpeaks;
filter=graph1<=0;
and gave no result.
The respective
perchg = 1;
X=CUM(1);
startvalue = lastvalue( PEAK( H, perchg, 1 ) );
endvalue = lastvalue( PEAK( H, perchg, 2 ) );
startbar = lastvalue( valuewhen( H == startvalue, x, 1 ) );
endbar = lastvalue( valuewhen( H == endvalue, x, 1 ) );
GRAPH3=STARTBAR-ENDBAR;
filter=graph3<=0;
had many cases with negative results in the database.
Shall we use the new formula in general?
Best Regards
Dimitris Tsokakis
--- In amibroker@xxxx, "Dimitris Tsokakis" <TSOKAKIS@xxxx> wrote:
> I just noticed that the "trendline formula" is not always correct.
> s11=h;
> x=cum(1);
> endvalue1 = lastvalue( peak( s11, 1, 1 ) );
> startvalue1 = lastvalue( peak( s11, 1, 2 ) );
> endbar1 = lastvalue( valuewhen( s11 == endvalue1, x, 1 ) );
> startbar1 = lastvalue( valuewhen( s11 == startvalue1, x, 1 ) );
> graph2=endbar1-startbar1;
> Some times may give negative graph2, as if the previous peak
> was AFTER the last, which is a bit impossible.
> This may happen, if a high after the last peak is, by coincidence,
> equal to the first peak.
> In att. gif, the high at A is 2.33 and graph2=4 days from peak to
peak.
> If you plot above, you will read graph2=-3, simply because the
> high at C is EXACTLY 2.33 and the VALUEWHEN function will read
> this and not the expected from point A.
> So, some formulas need to be revised.
> I will revert with details.
> Dimitris Tsokakis
|