PureBytes Links
Trading Reference Links
|
Salil,
I already wrote an answer to this e-mail but apparently you
didn't read it.
Once again, for/if/while work in Guru commentary without any
single problem.
Example:
1. if-else
if( Name() ==
"MSFT" ){
text = "Microsoft selected"<FONT
size=1>;
}else{
text = "Other ticker selected"<FONT
size=1>;
}text; // this prints
text
2. Outputing 10 times "hello world":
_N( output =
""
);<FONT face="Courier New"
size=1>
for( i = <FONT face="Courier New" color=#ff00ff
size=1>0; i < <FONT
face="Courier New" color=#ff00ff size=1>10<FONT face="Courier New"
size=1>; i++ )
{
output = output + "Hello
world\n";
}
output; // this displays
text
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Salil V
Gangal
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Monday, April 21, 2003 3:26
PM
Subject: [amibroker] Do 'for' and 'if'
work in 'Guru' or not ?
Hi John,
I am considering some very simple/mock (trivial) examples to check
if the new looping and selection in AFL works in 'Guru' or not.
Based on the documentation my impression is that this is an addition to the
language AFL, so I thought it should work wherever
AFL works.
So what I am asking is this ===>
Have you ever seen the new 'for' / 'if' / 'while' work, within 'Guru
Commentary' ? Are there any examples that demonstrate their
use within 'Guru' ?
Take some simple/mock (trivial) example - Say you want to
output string "Hello World!" 10 times in Guru. How can you do it by using
'for' statement in 'Guru' ?
Another simple/mock (trivial) example - Say you have two variables -
variable A (varA) and variable B (varB). Can you output the string
"var A is greater than varB" or "varA is not greater than varB" depending upon
their values by using multi-stament 'if'. How can you do it in 'Guru'
? (The multi-stament 'if' means a 'group' of staments is executed when a
certain condition is true and this group of statements is not executed
when that certain condition is false. The way to form this
group of statements is by enclosing them within a pair ot opening/closing
curly braces. And of course it is possible for one to have just a single
statement within a group, so enclosing a single statement within a pair or
opening/closing curly braces to form a group is or should be okay.)
Regards,
- Salil V Gangalnirvana1x
<nirvanaiam@xxxxxxxxxxxx> wrote:
<BLOCKQUOTE
>
Hi salil.I am not to sure what you are asking.This will work
in the commentary and IB to show if on the last bar the rsi is
greater than 60.It will show the text answer in the title bar of
the IB or wioll show this in the indicator builder.I am unsure
of what you are asking about the curly braces as i am not to sure how to
use these except if you next more than 1 if statements, similar to the
example TJ posted if ( i > 0 )
{
/* With braces */ if ( j > i
) x =
j;}else x = i;The curly
brackets in the formula below are not needed.////START of
FORMULA.rsi14 = RSI(14);for( i = 0; i <
BarCount; i++ ) varA=rsi14[i];varB = 60;if ( VarA >
varB ) Answer = "varA is greater than
varB";else { Answer= "varA is NOT greater than
varB";}
Plot(RSI14,"answer",colorBlue,styleLine);Title = Answer
;John.--- In amibroker@xxxxxxxxxxxxxxx, Salil V
Gangal <salil_gangal@xxxx> wrote:> Nirvanaiam, I
tried. However you have commented out 'for', so it did not
work. I wanted to find out if 'for' worked and if multi-statement
'if' using curly-braces worked in Guru or not. It looks as if the 'for'
and 'if' with curly-braces for multiple statements is working as
expected in the Indicator Builder, but it does not work in Guru.
(I'll give a small code below that works in Indicator Builder.)
Have you seen 'for' and 'if' with curly-braces for multi-statement
working in Guru ? Please give an example if you've seen these work
in Guru ... Regards,- Salil V Gangal Example that works in Indicator
Builder > rsi14 = RSI(14);> >
Plot(rsi14,"",colorBlue,styleLine);> > Title = " ";>
> varA = 10;> > varB = 20;> > if ( varA
> varB ) {> > for( i = 0; i < 3;
i++ ) {> > Title = Title +
" varA is greater than varB ";> >
}> > }> > else {>
> for( i = 0; i < 3; i++ ) {>
> Title = Title + " varA is not
greater than varB ";> > }>
> }> > nirvana1x <nirvanaiam@xxxx>
wrote:Try this > > > > /*> > **
File: loop_test.afl> > ** Title: Testing the Loop>
> ** Date: April 19, 2003> > ** Author: Salil V
Gangal> > */ > > "First Stamentnt";>
> //for ( i = 1; i < 10; i++ ) > > " Hello World!
";> > > > varA = 10;> varb = 20;>
> if ( varA >= varB ) > > Va=" varA is greater than
varB ";> > > > else > > Va= " varA
is not greater than varB ";> > > Va;> //"Last
Statement";> > > > > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx, Salil
V Gangal <salil_gangal@xxxx> > wrote:> > Friends,
I've got following code in Guru. Any idea why it does not >
produce the expected O/P? I'm attaching a screen-shot that shows
the > version I'm using. Regards,- Salil V Gangal > >
/*> > > > ** File: loop_test.afl> > >
> ** Title: Testing the Loop> > > > ** Date: April
19, 2003> > > > ** Author: Salil V Gangal> >
> > */ > > > > "First Stamentnt";> >
> > for ( i = 0; i < 10; i++ ) {> > > > "
Hello World! ";> > > > }> > > > varA
= 10;> > > > varB = 20;> > > > if (
varA > varB ) {> > > > " varA is greater than varB
";> > > > }> > > > else {>
> > > " varA is not greater than varB ";> > >
> }> > > > "Last Statement";> > >
> > > > > --------------------------------->
> Do you Yahoo!?> > The New Yahoo! Search - Faster. Easier.
Bingo.> > > Yahoo! Groups Sponsor> Send BUG
REPORTS to bugs@xxxx> Send SUGGESTIONS to suggest@xxxx>
-----------------------------------------> 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. > > > >
---------------------------------> Do you Yahoo!?> The New
Yahoo! Search - Faster. Easier. Bingo.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
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Do you Yahoo!?<A
href="">The New
Yahoo! Search - Faster. Easier. Bingo. 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
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Yahoo! Groups Sponsor
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.
|