PureBytes Links
Trading Reference Links
|
Sorry for the delay responding, I suspect we're in very different
timezones.
Try substituting this for loop, including the extended = 0, for the
earlier one. It counts backward from
right edge and only extends the first support line it detects. I
modified things to plot the extended part of
the line after the Cat3Sup is detected in white. It's not terribly
elegant, but it works.
You'll notice that when you scroll the price chart the support line at
right edge that gets extended changes to the
last visible support line. I believe that's because barcount, when
used in an indicator, always represents the last
visible bar . When you backtest, I don't think barcount will shift
like that, it will be the number of bars of data
you have. You'll be OK on the right edge, but backtesting could be a
problem.
I'll think about that. Maybe someone in the group has already solved
a similar problem (or can correct me
if I'm wrong about barcount).
extended = 0;
for<FONT
face=Arial size=2> ( i = BarCount - 1 ; i >= 6 ; i-- ) {
<FONT face=Arial
size=2>
if ( x0[i] != x0[i-<FONT
color=#ff00ff>1] ) { <FONT face=Arial
size=2>// new Cat3Sup detected
<FONT face=Arial
size=2>
<FONT face=Arial
size=2> if<FONT face=Arial
size=2> ( NOT extended ) { <FONT face=Arial
size=2>// Haven't extended one yet
extended
= 1;
m =
(y1[i] - y0[i])/(x1[i] - x0[i]);
Line =
LineArray( x0[i], y0[i], x1[i] + <FONT
color=#ff00ff>3, y1[i] + (3 * m),<FONT
color=#ff00ff>0,True);
<FONT
color=#0000ff> Plot(Line,<FONT
color=#ff00ff>"Cat3Sup
Line",colorDefault,styleLine);
<FONT face=Arial
size=2> // draw the line after the
detection in a different color and extend it.
x2 = i;
y2 = (i - x1[i] + 3) * m;
Line2=
LineArray( x1[i] + 3,
y1[i] + (3 * m),x2,y2,<FONT
color=#ff00ff>1,True);
<FONT
color=#0000ff> Plot(Line2,<FONT
color=#ff00ff>"Cat3Sup
Line",colorWhite,styleLine);
}
else {
// Old Cat3Sup lines, don't
extend
Line =
LineArray( x0[i], y0[i], x1[i], y1[i],<FONT
color=#ff00ff>0,True);
<FONT
color=#0000ff> Plot(Line,<FONT
color=#ff00ff>"Cat3Sup Line"<FONT
face=Arial>,colorDefault,styleLine);<FONT
size=1>
}
}
}
<BLOCKQUOTE dir=ltr
>
----- Original Message -----
<DIV
>From:
Gordon
Sutherland
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Saturday, May 22, 2004 8:15
PM
Subject: RE: [amibroker] Re: Help with
Line Array Coding for Clayburg
<SPAN
>Hi Bob,
<SPAN
>
<SPAN
>Thanks very much for helping me to get
my ‘Clayburg’ S & R & Trendlines working when Plotted. I have never
done any script writing to date so I guess I have a whole new learning curve
ahead!
<SPAN
>
<SPAN
>One further point if I may, the trading
system I am working on will use these Support and Resistance Lines as Triggers
for entries and exits (after the Dual Oscillators have fired as per John
Clayburg’s trading method). In order to System Test, I would want AB to only
analyze the last Plot as extended and not previous extended plot lines. In the
code so far written, is there any way that I can suppress all extensions other
than the last one - mainly for System Testing but also for Charting
clarity.
<SPAN
>
<SPAN
>Once again thank you for your invaluable
help.
<SPAN
>
<SPAN
>Regards,
<SPAN
><FONT
color=green>Gordon
Sutherland
<SPAN
>
<SPAN
>-----Original
Message-----From: Bob
Johnson [mailto:bjohnson314@xxxxxxxxx] <SPAN
>Sent: Sunday, 23 May 2004 2:26
a.m.To:
amibroker@xxxxxxxxxxxxxxx<SPAN
>Subject: Re: [amibroker] Re: Help with
Line Array Coding for Clayburg
<FONT face="Times New Roman"
size=3>
<FONT face=Arial color=black
size=2>Try
putting your LineArray & Plot calls in a for loop after you've calculated
the x,y arrays and after you've plotted the price
histogram.
<FONT face=Arial color=black
size=2>I've
changed the 'extend' so it's dependent on how close to the right edge
you are.
<FONT face=Arial color=black
size=2>If you
have 'extend' = 1 all the time the indicator becomes unreadable because
old plot lines extend far above & below the price
chart.
<FONT face="Times New Roman"
color=green size=3><SPAN
>
<FONT face=Arial color=black
size=2>/* JOHN
CLAYBURG BASED SUPPORT/RESISTANCE LINES
<FONT face=Arial color=black
size=2>
Coded by GBS May 2004
<FONT face=Arial color=black
size=2>/*
CATEGORY 3 SUPPORT BREAKOUT TRIGGER FOR SHORTS: */
<FONT face="Times New Roman"
color=maroon size=3><SPAN
>
<FONT face=Arial color=black
size=2>LL_3_6
= Ref(L,-6) > Ref(<SPAN
>L,-3);
<FONT face=Arial color=black
size=2>LL_3_5
= Ref(L,-5) > Ref(<SPAN
>L,-3);
<FONT face=Arial color=black
size=2>LL_3_4
= Ref(L,-4) > Ref(<SPAN
>L,-3);
<FONT face=Arial color=black
size=2>LL_3_2
= Ref(L,-2) > Ref(<SPAN
>L,-3);
<FONT face=Arial color=black
size=2>LL_3_1
= Ref(L,-1) > Ref(<SPAN
>L,-3);
<FONT face=Arial color=black
size=2>LL_3_0
= L > Ref(<SPAN
>L,-3);
<FONT face="Times New Roman"
color=maroon size=3><SPAN
>
<FONT face=Arial color=black
size=2>Cat3Sup
= LL_3_6 AND LL_3_5 <SPAN
>AND LL_3_4 <SPAN
>AND LL_3_2 <SPAN
>AND LL_3_1 <SPAN
>AND LL_3_0;
<FONT face=Arial color=black
size=2><SPAN
>
<FONT face=Arial color=black
size=2>/*
SUPPORT LINE ("SC") */
<FONT face="Times New Roman"
color=maroon size=3><SPAN
>
<FONT face=Arial color=black
size=2>Cat3 =
ValueWhen(Cat3Sup,BarIndex(),1)-3;
<FONT face=Arial color=black
size=2><SPAN
>y0=ValueWhen(Cat3Sup,Ref(<SPAN
>L,-3),2);
<FONT face=Arial color=black
size=2><SPAN
>y1=ValueWhen(Cat3Sup,Ref(<SPAN
>L,-3),1);
<FONT face=Arial color=black
size=2><SPAN
>x0=ValueWhen(Cat3Sup,BarIndex(),2)-3;
<FONT face=Arial color=black
size=2><SPAN
>x1=ValueWhen(Cat3Sup,BarIndex(),1)-3;
<FONT face="Times New Roman"
color=maroon size=3><SPAN
>
<FONT face=Arial color=black
size=2><SPAN
>Plot(y0, "Trendline
Bot y0", colorDefault,<SPAN
>styleNoLine+<SPAN
>styleOwnScale);
<FONT face=Arial color=black
size=2><SPAN
>Plot(y1, "Trendline
Bot y1", colorBlue,<SPAN
>styleNoLine+<SPAN
>styleOwnScale);
<FONT face=Arial color=black
size=2><SPAN
>Plot(x0,"x0",<SPAN
>colorDefault,<SPAN
>styleNoLine+<SPAN
>styleOwnScale); <FONT
face=Arial color=green size=2><SPAN
>//test only to check
for correct bar value
<FONT face=Arial color=black
size=2><SPAN
>Plot(x1,"x1",<SPAN
>colorDarkGrey,<SPAN
>styleNoLine+<SPAN
>styleOwnScale); <FONT
face=Arial color=green size=2><SPAN
>//test only to check
for correct bar value
<FONT face=Arial color=black
size=2><SPAN
>Plot(BarIndex(),"BarIndex()",<SPAN
>colorDefault,<SPAN
>styleNoLine+<SPAN
>styleOwnScale); <FONT
face=Arial color=green size=2><SPAN
>//test only to check
for correct bar value
<FONT face="Times New Roman"
color=maroon size=3><SPAN
>
<FONT face=Arial color=black
size=2><SPAN
>Plot(<SPAN
>C,"C", <SPAN
>colorRed, <SPAN
>styleCandle);
<FONT face="Times New Roman"
color=maroon size=3><SPAN
>
<FONT face=Arial
color=black size=2><SPAN
>for<FONT
face=Arial color=black size=2><SPAN
> ( i = 7 ; i <
<SPAN
>BarCount ; i++ )
{
<FONT face=Arial
color=black size=2><SPAN
> if ( x0[i] !=
x0[i-1] ) {
<FONT face=Arial
color=black size=2><SPAN
> if ( i
> BarCount - 50 )
<FONT face=Arial
color=black size=2><SPAN
>
extend = 1;
<FONT face=Arial
color=black size=2><SPAN
>
else
<FONT face=Arial
color=black size=2><SPAN
>
extend = 0;
<FONT face=Arial
color=black size=2><SPAN
>
Line = LineArray( x0[i], y0[i], x1[i], y1[i],extend,True);
<FONT face=Arial
color=black size=2><SPAN
>
Plot(Line,"Cat3Sup
Line",colorDefault,styleLine);
<FONT face=Arial
color=black size=2><SPAN
>
}
<FONT face=Arial
color=black size=2><SPAN
>}
<SPAN
>----- Original Message -----
<BLOCKQUOTE
>
<FONT
face=Arial size=2><SPAN
>From:<FONT
face=Arial size=2> <A
title=gosuth@xxxxxxxxxx href="">Gordon
Sutherland
<FONT face=Arial
size=2><SPAN
>To:<FONT
face=Arial size=2> <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
<FONT face=Arial
size=2><SPAN
>Sent:<FONT
face=Arial size=2>
Saturday, May 22, 2004 2:27 AM
<FONT face=Arial
size=2><SPAN
>Subject:<FONT
face=Arial size=2> RE:
[amibroker] Re: Help with Line Array Coding for
Clayburg
<FONT face="Times New Roman"
size=3>
<FONT face="Times New Roman"
color=black size=3>Hi
Graham,
<FONT face="Times New Roman"
size=3>
<FONT face="Times New Roman"
color=black size=3>Thanks for
prompt response.
<FONT face="Times New Roman"
size=3>
<FONT face="Times New Roman"
color=black size=3>I have
changed my code as per your suggestions with the caveat that I have changed
the “+3” to “-3” because you are computing from the start rather than the
end of the data. The values for the four co-ordinates seem to be correct
when I plot them before applying the LineArray function. However, when I
activate the LineArray function (‘Line’) then a warning
pops-up “Error 2. Bad Argument(s)”. I have the QuickAFL™ switched on but it
makes no difference if I turn this feature off!
<FONT face="Times New Roman"
size=3>
<FONT face="Times New Roman"
color=black size=3>The revised
code is submitted below. I would appreciate any help as to what I am doing
wrong that will not accept the code for AutoPlot.
<FONT face="Times New Roman"
size=3>
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>/* JOHN CLAYBURG BASED
SUPPORT/RESISTANCE LINES
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>
Coded by GBS May 2004
<FONT face="Times New Roman"
size=3>
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>/* CATEGORY 3 SUPPORT
BREAKOUT TRIGGER FOR SHORTS: */
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>LL_3_6 = Ref(L,-6) >
Ref(L,-3);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>LL_3_5 = Ref(L,-5) >
Ref(L,-3);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>LL_3_4 = Ref(L,-4) >
Ref(L,-3);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>LL_3_2 = Ref(L,-2) >
Ref(L,-3);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>LL_3_1 = Ref(L,-1) >
Ref(L,-3);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>LL_3_0
= L >
Ref(L,-3);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>Cat3Sup = LL_3_6 AND
LL_3_5 AND LL_3_4 AND LL_3_2 AND LL_3_1 AND LL_3_0;
<FONT face="Times New Roman"
size=3>
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>/* SUPPORT LINE
("SC") */
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>Cat3 =
ValueWhen(Cat3Sup,BarIndex(),1)-3;
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>y0=ValueWhen(Cat3Sup,Ref(L,-3),2);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>y1=ValueWhen(Cat3Sup,Ref(L,-3),1);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>x0=ValueWhen(Cat3Sup,BarIndex(),2)-3;
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>x1=ValueWhen(Cat3Sup,BarIndex(),1)-3;
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>//Line = LineArray( x0,
y0, x1, y1, 1); // Warning comes up "Error 2 - Bad
Argument(s)"
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>//Plot(Line,"Cat3Sup
Line",colorDefault,1);// Dependent on "Line = LineArray..." not
working
<FONT face="Times New Roman"
size=3>
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>Plot(C,"C", colorRed,
styleCandle);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>Plot(y0, "Trendline Bot
y0", colorDefault,16);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>Plot(y1, "Trendline Bot
y1", colorBlue,1+4);
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>Plot(x0,"x0",colorDefault,16);
//test only to check for correct bar value
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>Plot(x1,"x1",colorDarkGrey,16);
//test only to check for correct bar value
<FONT face="Courier New"
size=2><SPAN lang=EN-NZ
>Plot(BarIndex(),"BarIndex()",colorDefault,16);
//test only to check for correct bar value
<FONT face="Times New Roman"
size=3>
<FONT
face="Times New Roman" color=green size=3><SPAN
>Regards,
<FONT
face="Times New Roman" color=green size=3><SPAN
>Gordon
Sutherland
<FONT face="Times New Roman"
size=3>
<SPAN
>-----Original
Message-----From: Graham
[mailto:gkavanagh@xxxxxxxxxxxxx] <SPAN
>Sent: Saturday, 22 May 2004 4:27
p.m.To:
amibroker@xxxxxxxxxxxxxxx<SPAN
>Subject: RE: [amibroker] Re: Help with
Line Array Coding for Clayburg
<FONT face="Times New Roman"
size=3>
<P class=MsoNormal
><FONT
face="Courier New" size=2>Tired to sort out
what you were doing, does this help you at least<FONT
face="Courier New" size=2><SPAN
><FONT
face="Courier New">alternative way of doing it?<FONT
face="Courier New">Cat3 =
Valuewhen(Cat3Sup,barindex(),1)+3;<FONT
face="Courier New">x0 =
Valuewhen(Cat3Sup,barindex(),2)+3;<FONT
face="Courier New">Cheers,<FONT
face="Courier New">Graham<A
href="">http://e-wire.net.au/~eb_kavan/
-----Original
Message-----From: Gordon
Sutherland [mailto:gosuth@xxxxxxxxxx] <FONT
face="Courier New">Sent: Saturday, May 22, 2004 12:09
PMTo:
amibroker@xxxxxxxxxxxxxxx<FONT
face="Courier New">Subject: [amibroker] Re: Help with Line Array Coding for
Clayburg<FONT
face="Courier New">Hi,<FONT
face="Courier New"> I am
new to AB (Std Version 4.56 Beta) and I am working on porting my
customindicators and systems
over from my previous software (AIQ and MetaStock).<FONT
face="Courier New">Not being very good at programming at the best of times,
I have spentseveral hours
trying to get the coding right to Plot custom Trendlines
usingJohn Clayburg’s Category 3
Support/Resistance Lines. For the Line Array<FONT
face="Courier New">function in AB I have gotten as far as getting the
y0/y1/x1 co-ordinatescoding
sorted but the final hurdle of ‘x0’ has got be beat. Any help with
mycoding would be greatly
appreciated. The code I have written so far is:<FONT
face="Courier New"> /*
JOHN CLAYBURG BASED CATEGORY 3 SUPPORT/RESISTANCE
LINES<FONT
face="Courier New"> as discussed in his book
"Four Steps To Trading Success" /*
<FONT
face="Courier New">/* CATEGORY 3 SUPPORT LINE:
*/LL_3_6 = Ref(L,-6) >
Ref(L,-3);LL_3_5 = Ref(L,-5)
> Ref(L,-3);LL_3_4 =
Ref(L,-4) > Ref(L,-3); <FONT
face="Courier New">LL_3_2 = Ref(L,-2) >
Ref(L,-3);LL_3_1 = Ref(L,-1)
> Ref(L,-3);LL_3_0
= L >
Ref(L,-3);Cat3Sup = LL_3_6 AND
LL_3_5 AND LL_3_4 AND LL_3_2 AND LL_3_1 AND LL_3_0;<FONT
face="Courier New"> /*
SUPPORT LINE ("SC") */<FONT
face="Courier New">Cat3 = BarsSince(Cat3Sup)+3;<FONT
face="Courier New">//Fx0 = BarCount - 1 - Cat3 -
ValueWhen(Cat3Sup,BarsSince(Cat3Sup)+3,2); //<FONT
face="Courier New">NOT WORKING CORRECTLY<FONT
face="Courier New">Fx1 = BarCount - 1 - Cat3; /* This gives me my x0
co-ordinate */<FONT
face="Courier New">y0=ValueWhen(Cat3Sup,Ref(L,-3),2);
<FONT
face="Courier New">y1=ValueWhen(Cat3Sup,Ref(L,-3),1);
//x0=BarCount - 1 -
ValueWhen(Cat3Sup,Cat3,2); // NOT WORKING CORRECTLY<FONT
face="Courier New">x1=BarCount - 1 - Cat3;<FONT
face="Courier New">//Line = LineArray( x0, y0, x1, y1, 1 ); // Pending
sorting the x0 codingout
Plot(C,"C", colorRed,
styleCandle); Plot(y0,
"Trendline Bot y0", colorDefault,16);<FONT
face="Courier New">Plot(y1, "Trendline Bot y1",
colorBlue,1+4);<FONT
face="Courier New">//Plot(???,"",colorDefault,16); // Dependent
on sorting Coding onco-ordinate
x0<FONT
face="Courier New">//Plot(Cat3,"",colorDarkGrey,16); // Working
OK<FONT
face="Courier New"> <FONT
face="Courier New">TIA,<FONT
face="Courier New"> <FONT
face="Courier New">Regards,<FONT
face="Courier New">Gordon Sutherland<FONT
face="Courier New">Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">Check group FAQ at:<FONT
face="Courier New"><A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups
Sponsor<FONT
face="Courier New">ADVERTISEMENT<FONT
face="Courier New">Yahoo! Groups Links<FONT
face="Courier New">• To visit your group on the web, go
to:<A
href="">http://groups.yahoo.com/group/amibroker/<FONT
face="Courier New"> • To
unsubscribe from this group, send an email to:<FONT
face="Courier New">amibroker-unsubscribe@xxxxxxxxxxxxxxx<FONT
face="Courier New"> •
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
<FONT face="Courier New"
size=2>Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<SPAN
><FONT
face="Courier New">Send SUGGESTIONS to
suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">Check group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
<P class=MsoNormal
><FONT
face="Times New Roman" size=3><SPAN
><FONT face="Courier New"
size=2>Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<SPAN
><FONT
face="Courier New">Send SUGGESTIONS to
suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">Check group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
<FONT face="Times New Roman"
size=3><FONT
face="Courier New" size=2>Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<SPAN
><FONT
face="Courier New">Send SUGGESTIONS to
suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">Check group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|