PureBytes Links
Trading Reference Links
|
sorry forgot to add an alternative try reducing the number of bars you loop through to just those needed to display what is on the screen
-- Cheers Graham AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements http://www.aflwriting.com
On 12/03/07, Lal <klal25@xxxxxxxxxxx> wrote:
Graham, Thank you for the suggestion. That does solve the problem. The retracements levels displayed now remain despite scrolling or clicking on the chart.
One other thing that bothered me was the slow execution of the code. Grateful for any pointers on speeding it up. Cheers, Lal
----- Original Message ---- From: Graham <kavemanperth@xxxxxxxxx> To:
amibroker@xxxxxxxxxxxxxxx Sent: Sunday, 11 March, 2007 8:50:44 PM Subject: Re: [amibroker]
Retracements levels and Plottext
I have not gone through the code in detail but you should add this to it because you are using loop
setbarsrequired( 10000,10000) ;
-- Cheers Graham AB-Write >< Professional AFL Writing Service Yes, I write AFL code to your requirements
http://www.aflwriti ng.com
On 11/03/07, Lal <
klal25@xxxxxx co.uk> wrote:Hi,
I'm trying to compute and display retracement levels after a peak has formed. The code I have developed works fine only once after I apply the indicator. Clicking anywhere on the graph causes the computed levels to disappear! Obviously, I am doing something wrong, only can't figure
out what. Would be grateful for any helpful hints.
Attached is a screenshot showing how the graph looks immediately after the first application of the indicator.
Cheers, Lal
_SECTION_BEGIN("Retracements");
Level = Param("Pivot Level", 9, 2, 100, 1);
Plot(C, "Retracements", colorBlack, styleBar);
My_Peak[0] = 0; My_Trough[0] = 0;
for( i = Level+1; i < BarCount-Level; i++ )
{ // There shouldn't be a higher high for the next few bars R_Higher_high[ 0] = 0; // Higher High found on the right of current bar L_Higher_high[
0] = 0; // Higher High found on the left of current bar
R_Lower_Low[ 0] = 0; // Lower Low found on the right of current bar L_Lower_Low[ 0] = 0; // Lower Low found on the left of current bar
// | | | | C | | | |
// ----> for (j = i; j <= i+Level; j++) { if(High[j] > High[i]) { R_Higher_high[ 0] = R_Higher_high[ 0] + 1; }
if(Low[j] < Low[i]) { R_Lower_Low[ 0] = R_Lower_Low[ 0] + 1;
} }
// There should be no higher high for previous few bars // | | | | C | | | | // <---- for(k = i; k >= (i-Level); k--) { if(High[k] > High[i]) {
L_Higher_high[ 0] = L_higher_high[ 0] + 1; }
if(Low[k] < Low[i]) { L_Lower_Low[ 0] = L_Lower_Low[ 0] + 1; } }
// If we've detected a higher high on either // side of current bar,
// we do NOT have a valid
peak if(NOT L_Higher_High[ 0] AND NOT r_Higher_High[ 0]) { My_peak[i] = 1; // Mark current bar as a valid pivot/peak PlotText("P", i, H[i] + 20, colorRed); }
// If we've detected a lower low on either
// side of current bar, // we do NOT have a valid trough if(NOT L_Lower_Low[ 0] AND NOT R_Lower_Low[ 0]) { My_Trough[i] = 1; // Mark current bar as a valid pivot/peak PlotText("T", i, L[i] - 30, colorBlue);
}
L_higher_high[ 0] = 0; R_Higher_High[ 0] = 0; L_Lower_Low[ 0] = 0; R_Lower_Low[ 0] = 0; }
// Find Co-ordinates to draw lines // Peak to Peak AND Trough to Trough Y0 = ValueWhen(My_ Peak, H, 2);
X0 = ValueWhen(My_ Peak, BarIndex(), 2);
Y1 = ValueWhen(My_ Peak, H, 1); X1 = ValueWhen(My_ Peak, BarIndex(), 1);
NullY0 = IsNull(y0); NullY1 = IsNull(y1);
TY0 = ValueWhen(My_ Trough, L, 2);
TX0 = ValueWhen(My_ Trough, BarIndex(), 2);
TY1 =
ValueWhen(My_ Trough, L, 1); TX1 = ValueWhen(My_ Trough, BarIndex(), 1);
NullTY0 = IsNull(Ty0); NullTY1 = IsNull(Ty1);
// Work out retracement levels after a peak P1 = ValueWhen(My_ Peak, H, 1);
P1_B = ValueWhen(My_ Peak, BarIndex(), 1);
T1 = ValueWhen(My_ Trough, L, 2); T1_B = ValueWhen(My_ Trough, BarIndex(), 2);
T2 = ValueWhen(My_ Trough, L, 1); T2_B = ValueWhen(My_ Trough, BarIndex(), 1);
Cond1 = P1_B > T1_B AND P1_B < T2_B; T1P1_Swing = P1 - T1; P1T2_Swing = P1 - T2; Swing_Extent = P1T2_Swing / T1P1_Swing; PlotNow = ValueWhen(Cond1, BarIndex()); Ext = ValueWhen(Cond1, Swing_Extent, 1);
// Test End
for( i = BarCount-1; i > 10; i--) { if ( !Nully0[i]) { // Line to conncect peaks Line1 = LineArray( x0[i], y0[i], x1[i], y1[i], 0, True); Plot(Line1, "", colorWhite, styleDashed+ styleNoRescale+ styleNoLabel) ;
}
if (
!NullTy0[i]) { // Line to connect troughs Line2 = LineArray( tx0[i], ty0[i], tx1[i], ty1[i], 0, True); Plot(Line2, "", colorWhite, styleLine+styleNoRe scale+styleNoLab el); }
if (PlotNow[i])
{ // Show retracement extent after a peak PlotText("" + WriteVal(Ext[ i], 1.2), T2_B[i], T2[i]-60, colorBlack);
} } _SECTION_END( );
What kind of emailer are you? Find out today - get a free analysis of your email personality. Take the quiz at the
Yahoo! Mail Championship.
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the
Yahoo! Mail Championships. Plus: play games and win prizes.
__._,_.___
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
SPONSORED LINKS
__,_._,___
|