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

[amibroker] Re: About 'for' and 'if' (with curly-braces) in Guru. Do they work ?



PureBytes Links

Trading Reference Links

  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: 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. 
> 
> 
> 
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online-No late fees! Try Netflix for FREE!
http://us.click.yahoo.com/YKLNcC/oEZFAA/i5gGAA/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 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/