PureBytes Links
Trading Reference Links
|
Thanks for your help :-)
Now, my code looks like :
function comment(indicator)
{
"\nComment...\n";
return WriteIf(1==1, "TrueText", "FalseText");
}
Plot(MACD(),"MACD",colorBlue);
"---------";
comment(MACD());
"---------";
And the result is correct since I see :
-----------
TrueText
-----------
So, what I can conclude is :
- there is no need to have a Title and, anyway, that's good since I
already use it for other reasons (see below)
- I've tried a procedure instead of a function and it works exactly
the same ! Without the return WriteIf... no display, with it... it
works (yes, you can apparently return something from a procedure ;-))
BUT.... let me once more precise what I have in mind:
- I already have plenty of coded indicators.
- I'd like to write a generic divergence analysis method that would
search for divergence between any indicator and the price (a
check_divergence(indicator, price) function or procedure)
- then I would have just to add a #include "check_divergence" and a
call to this function to add a generic commentary regarding
divergences to any indicator.
My first intent was then to directly print the result from the
function itself. Now I know that I must "return" the result to have
it displayed, so I guess that I have to concatenate all my results
and my function should look like :
function Comment(ind)
{
cond1=...;
res = WriteIf(cond1, "Cond1", "Not Cond1");
cond2=...;
res = res + "\n" + WriteIf(cond2, "Cond2", "Not Cond2");
return res;
}
Anyway, I would like to understand better why I have to return the
result to see it displayed, it doesn't look very logical to me !??!
And... you know... I always prefer to understand the "why" than just
to do it "because" ;-p
Thanks !
--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS"
<TSOKAKIS@xxxx> wrote:
> Now the question is more clear.
> Let us consider a simplified divergence condition div.
>
> function Comment(ind)
> {
> div=ind>Ref(ind,-1) AND C<Ref(C,-1);
> t=WriteVal(ind)+WriteIf(div,"[div]"," ");
> return t;
> }
> Title="MACD= "+Comment(MACD())+", STOCHD= "+Comment(StochD())
> +",RSI="+Comment(RSI());
>
> Replace div with your condition and add as many indicators you
wish.
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "kelek_94" <casalis@xxxx> wrote:
> > 1. Yes, it works in the main line code; this is why, as you
said, I
> > suspect that "printing" from a function doesn't work ^^
> >
> > 2. No, I don't use any include (yet ;-))
> >
> > 3. My idea is to create functions that implement kinds of
general
> > commentaries. For example, I can have a generic check_divergence
> > function that will compare price evolution with regards to any
> > indicator evolution. It'll then print some information regarding
> > this divergence. So, one string is not enough; I would have
really
> > need to print from a function :/
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "hairy_mug" <WSCHWARZ@xxxx>
wrote:
> > > 1. does it work in the main line code?
> > > if so, might not be able to be used in a function?
> > >
> > > 2.Is the function in a separate "#include" file?
> > > If so, add a space in the file name;
> > > "check" it; (it will fail)
> > > Then take the space out and hit "check" again...
> > > This has the effect of re-compiling the included script.
> > > I edit all my function files outside of AB and have do this
every
> > > time the function file is edited.
> > > >> I would love to know a better way to re-compile.
> > >
> > > 3. try coding it with the "IIF" fuction to create the string...
> > >
> > >
> > > Walt
> > >
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "kelek_94" <casalis@xxxx>
wrote:
> > > > Thanks Graham,
> > > >
> > > > but... ;-) that's not at all the problem :/
> > > >
> > > > Even with a "real" condition nothing is displayed at all :/
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx>
> > wrote:
> > > > > You neeed something to be one for the statement to work
> > > > > WriteIf(indicator==1, "TrueText", "FalseText");
> > > > >
> > > > > Cheers,
> > > > > Graham
> > > > > http://e-wire.net.au/~eb_kavan/
> > > > >
> > > > > -----Original Message-----
> > > > > From: kelek_94 [mailto:casalis@x...]
> > > > > Sent: Saturday, May 22, 2004 7:11 PM
> > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > > Subject: [amibroker] writeif in functions ?
> > > > >
> > > > > Here is a very short piece of code in which I'm trying to
> > display
> > > > > information in the interpretation window from a function.
> > > > >
> > > > > function comment(indicator)
> > > > > {
> > > > > "\nComment...\n";
> > > > >
> > > > > WriteIf(1, "TrueText", "FalseText");
> > > > > WriteVal(indicator);
> > > > > }
> > > > >
> > > > > Plot(MACD(),"MACD",colorBlue);
> > > > >
> > > > > "---------";
> > > > > comment(MACD());
> > > > > "---------";
> > > > >
> > > > > Unfortunately, the result is just :
> > > > >
> > > > > Date: 21/05/2004
> > > > >
> > > > > ---------
> > > > > ---------
> > > > >
> > > > > Is there something wrong with this idea of printing text
from
> > a
> > > > > function ?
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Send BUG REPORTS to bugs@xxxx
> > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > -----------------------------------------
> > > > > 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
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
---------------------------------------------------------------------~->
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:
http://docs.yahoo.com/info/terms/
|