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

[amibroker] RE: Thank you it works: How do I subtract the difference between two horizontal study lines? (in AFL)



PureBytes Links

Trading Reference Links










<span
>Thank you so much . . . very nice to have
your help on this one . . . .

<span
> 

<span
>Thank you 

<span
> 

<span
>Thank you 

<span
> 

<span
>Thank you 

<span
> 

<span
>Bruce

<span
>-----Original Message-----
From: Tomasz Janeczko
[mailto:amibroker@xxxxxx] 
Sent: <st1:date
Month="10" Day="15" Year="2003"><span
 >Wednesday, October 15, 2003<font
size=2 face=Tahoma> <st1:time
Hour="1" Minute="40">1:40 AM<span
>
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] How do I
subtract the difference between two horizontal study lines? (in AFL)

<span
> 



<span
>Bruce,





<span
> 





<span
>The code I have given (and also Jayson's code) works
correcly *IF* you draw the study lines





<font size=2
face="Times New Roman">on DEFAULT PRICE chart
and label them correctly<span
>.





<span
> 





<span
>This is so because Study by default refers to built-in
price chart id which is zero





<span
><a
href="">http://www.amibroker.com/guide/afl/afl_view.php?name=STUDY





<span
> 





<span
>You are apparently using the formula NOT on the
default price chart. But you did not mention it.





<span
> 





<span
>In that case you have to refer to given pane Chart ID
which is displayed in the Indicator Builder.





<span
> 





<span
>As an alernative you can use GetChartID function to
retrieve current chart ID automatically





<span
><a
href="">http://www.amibroker.com/guide/afl/afl_view.php?name=GETCHARTID





<span
> 





<span
>The version that works on any chart (not only built-in
price chart) would look like this:





<span
>x=<span
>ValueWhen<span
>(NOT <font
color=blue>IsNull( <span
>Study(<span
>"re",<span
>GetChartID())),<span
>Study(<span
>"re"<font size=1
face="Courier New">,<font
color=blue>GetChartID()<font
size=1>));

<span
>y=<span
>ValueWhen<span
>(NOT <font
color=blue>IsNull( <span
>Study(<span
>"su",<span
>GetChartID())),<span
>Study(<span
>"su",<span
>GetChartID()));

<span
>Title = <font
size=1 color=blue>WriteVal<font
size=1>(x)<font size=1
face="Courier New"> + <font
color=fuchsia>":" + <font
size=1 color=blue>WriteVal<font
size=1>(y)<font size=1
face="Courier New"> + <font
color=fuchsia>":" + <font
size=1 color=blue>WriteVal<font
size=1>(x-y);





<span
> 





<span
>Best regards,
Tomasz Janeczko
amibroker.com







<span
>----- Original Message ----- 





<font size=2
face=Arial>From:<font
size=2 face=Arial> <a
href="" title="bdnutter@xxxxxxxxxxx">Bruce Nutter






<span
>To:<font
size=2 face=Arial> <a
href="" title="amibroker@xxxxxxxxxxxxxxx">amibroker@xxxxxxxxxxxxxxx






<span
>Sent:<font
size=2 face=Arial> <st1:date
Month="10" Day="15" Year="2003">Wednesday, October 15, 2003<font
size=2 face=Arial> <st1:time
Hour="3" Minute="7">3:07 AM<span
>





<span
>Subject:<font
size=2 face=Arial> RE:
[amibroker] How do I subtract the difference between two horizontal study lines?
(in AFL)





<span
> 



<font size=3 color=black
face="Times New Roman">Gurus, Jason
& Tomasz,

<font size=3 color=black
face="Times New Roman">My result of
Tomasz$B!F(Bs example code (shown below) with horizontal study lines labeled
$B!H(Bre$B!I(B and $B!H(Bsu$B!I(B is as follows:

<font size=3 color=black
face="Times New Roman"> 

<font size=3
 color=black face="Times New Roman">{EMPTY}<font
color=black>

<font size=3
 color=black face="Times New Roman">{EMPTY}<font
color=black>

<font size=3
 color=black face="Times New Roman">{EMPTY}<font
color=black>

<font size=3 color=black
face="Times New Roman"> 

<font size=3 color=black
face="Times New Roman">Please
advise,

<font size=3 color=black
face="Times New Roman">Bruce

<span
>-----Original Message-----
From: Tomasz Janeczko
[mailto:amibroker@xxxxxx] 
Sent: <st1:date
Month="10" Day="14" Year="2003"><span
 >Tuesday, October 14, 2003<font
size=2 face=Tahoma> <st1:time
Hour="14" Minute="27">2:27 PM<span
>
To: <a
href="">amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] How do I
subtract the difference between two horizontal study lines? (in AFL)

<span
> 



<span
>Bruce,





<span
> 





<span
>Please use this code:





<span
> 





<font
size=1 color=black face="Courier New">x=<font size=1 color=blue
face="Courier New">ValueWhen<span
>(NOT IsNull( <font
size=1 color=blue face="Courier New">Study<font size=1 color=black
face="Courier New">(<span
>"re"<font
size=1 color=black face="Courier New">)),<font size=1 color=blue
face="Courier New">Study<span
>(<font
size=1 color=fuchsia face="Courier New">"re"<font
size=1 color=black face="Courier New">));

<font
size=1 color=black face="Courier New">y=<font size=1 color=blue
face="Courier New">ValueWhen<span
>(NOT IsNull( <font
size=1 color=blue face="Courier New">Study<font size=1 color=black
face="Courier New">(<span
>"su"<font
size=1 color=black face="Courier New">)),<font size=1 color=blue
face="Courier New">Study<span
>(<font
size=1 color=fuchsia face="Courier New">"su"<font
size=1 color=black face="Courier New">));

<font
size=1 color=blue face="Courier New">WriteVal<font size=1 color=black
face="Courier New">(x);

<font
size=1 color=blue face="Courier New">WriteVal<font size=1 color=black
face="Courier New">(y);

<font
size=1 color=blue face="Courier New">WriteVal<font size=1 color=black
face="Courier New">(x-y);

<font
size=3 face="Times New Roman"> <font
size=1 color=black face="Courier New">





<span
>Hope this helps.





<span
> 





<span
>Best regards,
Tomasz Janeczko
amibroker.com







<span
>----- Original Message ----- 





<font
size=2 face=Arial>From: <a href=""
title="bdnutter@xxxxxxxxxxx">Bruce Nutter 





<span
>To:<font
size=2 face=Arial> <a
href="" title="amibroker@xxxxxxxxxxxxxxx">amibroker@xxxxxxxxxxxxxxx






<span
>Sent:<font
size=2 face=Arial> <st1:date
Month="10" Day="14" Year="2003">Tuesday, October 14, 2003<font
size=2 face=Arial> <st1:time
Hour="22" Minute="9">10:09 PM<span
>





<span
>Subject:<font
size=2 face=Arial> RE:
[amibroker] How do I subtract the difference between two horizontal study
lines? (in AFL)





<span
> 



<font
size=1 color=black face="Courier New">Gurus and Jayson

<font
size=1 color=black face="Courier New">I tried this code so I could see the difference
between the two horizontal lines. But the results I get in the interpretation
window is shown below. Could some guru please tell me why this does not work.
(For those of you who might ask yes the labels of my horizontal study lines are
$B!H(Bre$B!I(B and $B!H(Bsu$B!I(B)

<b
><span
>Formula code:

<font
size=1 color=black face="Courier New">x=<font size=1 color=blue
face="Courier New">LastValue<span
>(<font
size=1 color=blue face="Courier New">Study<font size=1 color=black
face="Courier New">(<span
>"re"<font
size=1 color=black face="Courier New">));

<font
size=1 color=black face="Courier New">y=<font size=1 color=blue
face="Courier New">LastValue<span
>(<font
size=1 color=blue face="Courier New">Study<font size=1 color=black
face="Courier New">(<span
>"su"<font
size=1 color=black face="Courier New">));

<font
size=1 color=blue face="Courier New">WriteVal<font size=1 color=black
face="Courier New">(x);

<font
size=1 color=blue face="Courier New">WriteVal<font size=1 color=black
face="Courier New">(y);

<font
size=1 color=blue face="Courier New">WriteVal<font size=1 color=black
face="Courier New">(x-y);

<b
><span
>Interpretation window
result:

<font
size=1 color=black face="Courier New">0

<font
size=1 color=black face="Courier New">0

<font
size=1 color=black face="Courier New">0

<font
size=1 color=black face="Courier New"> 

<font
size=1 color=black face="Courier New"> 

<font size=3 color=black
face="Times New Roman">Bruce

<font size=3 color=black
face="Times New Roman"> 

<span
>-----Original Message-----
From: Jayson
[mailto:jcasavant@xxxxxxxxxxx] 
Sent: <st1:date
Month="10" Day="14" Year="2003"><span
 >Tuesday, October 14, 2003<font
size=2 face=Tahoma> <st1:time
Hour="9" Minute="49">9:49 AM<span
>
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] How do I subtract
the difference between two horizontal study lines? (in AFL)

<span
> 



<font size=2 color=blue
face=Arial>Brian,





<font size=2 color=blue
face=Arial>have a
look in the help files for Study(). You can name your trend line than call its
value in a code.





<span
> 





<font size=2 color=blue
face=Arial>for instance
in this exploration I have named 2 study lines and called the last value of
each and subtracted one from the other....





<span
> 





<span
> 





<font size=2 color=blue
face=Arial>Filter=C>0;<font
size=2 color="#282828">





<font size=2 color=blue
face=Arial>x=<font
size=2 color=blue>LastValue(Study("s1"))<font
size=2 color=blue face=Arial>;<span
>





<font size=2 color=blue
face=Arial>y=<font
size=2 color=blue>LastValue(Study("s<font
size=2 color=blue face=Arial>2")<span
>);<font
size=2 color="#282828" face=Arial>





<font size=2 color=blue
face=Arial>AddColumn<font
size=2 color="#282828" face=Arial>(x,<span
>""<font
size=2 color="#282828" face=Arial>);<span
>





<font size=2 color=blue
face=Arial>AddColumn<font
size=2 color="#282828" face=Arial>(y,<span
>""<font
size=2 color="#282828" face=Arial>);





<font size=2 color=blue
face=Arial>AddColumn<font
size=2 color="#282828" face=Arial>(x-y,<span
>""<font
size=2 color="#282828" face=Arial>);





<span
> 





<span
> 





<font size=2 color=blue
face=Arial>Regards, 





<font size=2 color=blue
face=Arial>Jayson




-----Original Message-----
From: Bruce Nutter
[mailto:bdnutter@xxxxxxxxxxx]
Sent: <st1:date
Month="10" Day="14" Year="2003"><span
 >Tuesday, October 14, 2003<font
size=2 face=Tahoma> <st1:time
Hour="12" Minute="26">12:26 PM<span
>
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] How do I
subtract the difference between two horizontal study lines? (in AFL)

<font size=3 color=black
face="Times New Roman">Gurus,

<font size=3 color=black
face="Times New Roman">Does anybody
know how to subtract between two horizontal study lines in AFL code? I have to
study lines that I move around to calculate entry and exit points. What I'd
like to do is to show that vertical distance between these two horizontal lines
in the interpretation window. Would one of you gurus please let me know how to
do this?

<font size=3 color=black
face="Times New Roman">Bruce

<span
>
Send
BUG REPORTS to bugs@xxxxxxxxxxxxx<font size=2
face="Courier New">
Send 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


Your use of
Yahoo! Groups is subject to the Yahoo!
Terms of Service. 




<span
>Send BUG REPORTS to bugs@xxxxxxxxxxxxx<font
size=2 face="Courier New">
Send 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


Your use of
Yahoo! Groups is subject to the Yahoo!
Terms of Service. 

<span
> 

<span
>

Send
BUG REPORTS to bugs@xxxxxxxxxxxxx<font size=2
face="Courier New">
Send 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


Your use of
Yahoo! Groups is subject to the Yahoo!
Terms of Service. 



<span
>



<span
>Send BUG REPORTS to bugs@xxxxxxxxxxxxx<font
size=2 face="Courier New">
Send 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


Your use of
Yahoo! Groups is subject to the Yahoo!
Terms of Service. 

<span
> 

<span
>

Send
BUG REPORTS to bugs@xxxxxxxxxxxxx<font size=2
face="Courier New">
Send 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


Your use of
Yahoo! Groups is subject to the Yahoo!
Terms of Service. 



<span
>



<font size=2
face="Courier New">Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<span
>
Send 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


Your use of
Yahoo! Groups is subject to the Yahoo!
Terms of Service. 










Yahoo! Groups Sponsor


  ADVERTISEMENT 









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



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.