PureBytes Links
Trading Reference Links
|
Thanks Graham for your reply. I changed the loop to just using IIF
and now it behaves as it should. One thing that puzzles me is why
does it work (meaning that the plotted lines do not change when
scrolling thru time) using the IIF statement but will change using
the loop? I thought that the IFF statement was the same as loops. The
manual states:
IIF can be re-implemented using new if-else flow control statements.
The code below shows this and explains what IIF in fact does
internally.
function _IIF( ConditionArray, TrueArray, FalseArray )
{
for( i = 0; i < BarCount; i++ )
{
if( ConditionArray[ i ] )
{
result[ i ] = TrueArray[ i ];
}
else
{
result[ i ] = FalseArray[ i ];
}
}
}
I would like a lesson here in the usage of loops vs IIF
Thanks
Ron
--- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxx> wrote:
>
> You do not need to use loop for this, just IIF statements
>
> but you have used scalar variables as the results (not array
values),
> therefore loop only returns the last calculated value from the loop
>
> --
> Cheers
> Graham Kav
> AFL Writing Service
> http://www.aflwriting.com
>
>
> On 18/08/07, booker_1324 <booker_1324@xxx> wrote:
> > Hello,
> >
> > Could someone please look at my sample code and tell me what I am
> > doing wrong. When plotted with an Interpretation window on, and
> > clicking on the candles, the values for LoRange and HiRange
between
> > the Interpretion window and the chart title are sometimes
different
> > on some candles. Also scrolling thru time will change the plotted
> > lines. It's probably something simple that I have overlooked and I
> > would appreciate it if someone would take the time to point out my
> > erroneous code. Life would be so much simpler if I could write
code
> > like Tomasz.
> >
> > Thanks
> > Ron
> >
> >
> >
> >
> >
> >
> >
> >
> > mov2 = EMA(Close,2);
> > mov4 = EMA(Close,4);
> > mov8 = EMA(Close,8);
> > mov17 = EMA(Close,17);
> > mov34 = EMA(Close,34);
> > mov72 = EMA(Close,72);
> > mov144 = EMA(Close,144);
> >
> > MaxH2=HHV(H,2);
> > MinL2=LLV(L,2);
> > MaxH4=HHV(H,4);
> > MinL4=LLV(L,4);
> > MaxH8=HHV(H,8);
> > MinL8=LLV(L,8);
> > MaxH17=HHV(H,17);
> > MinL17=LLV(L,17);
> > MaxH34=HHV(H,34);
> > MinL34=LLV(L,34);
> > MaxH72=HHV(H,72);
> > MinL72=LLV(L,72);
> > MaxH144=HHV(H,144);
> > MinL144=LLV(L,144);
> >
> >
> > mov2up = mov2 < mov4 AND mov4 < mov8 AND mov8 < mov17 AND mov17 <
> > mov34 AND mov34 < mov72 AND mov72 < mov144;
> > mov4up_2 = mov2 > mov4 AND mov4 < mov8;
> > mov8up_2 = mov4 > mov8 AND mov8 < mov17;
> > mov8up_3 = mov2 > mov4 AND mov4 > mov8 AND mov8 < mov17;
> > mov17up_2 = mov8 > mov17 AND mov17 < mov34;
> > mov17up_3 = mov4 > mov8 AND mov8 > mov17 AND mov17 < mov34;
> > mov34up_2 = mov17 > mov34 AND mov34 < mov72;
> > mov34up_3 = mov8 > mov17 AND mov17 > mov34 AND mov34 < mov72;
> > mov72up_2 = mov34 > mov72 AND mov72 < mov144;
> > mov72up_3 = mov17 > mov34 AND mov34 > mov72 AND mov72 < mov144;
> > mov144up_2 = mov72 > mov144;
> > mov144up_3 = mov34 > mov72 AND mov72 > mov144;
> >
> > mov2down = mov2 > mov4 AND mov4 > mov8 AND mov8 > mov17 AND mov17
>
> > mov34 AND mov34 > mov72 AND mov72 > mov144;
> > mov4down_2 = mov2 < mov4 AND mov4 > mov8;
> > mov8down_2 = mov4 < mov8 AND mov8 > mov17;
> > mov8down_3 = mov2 < mov4 AND mov4 < mov8 AND mov8 > mov17;
> > mov17down_2 = mov8 < mov17 AND mov17 > mov34;
> > mov17down_3 = mov4 < mov8 AND mov8 < mov17 AND mov17 > mov34;
> > mov34down_2 = mov17 < mov34 AND mov34 > mov72;
> > mov34down_3 = mov8 < mov17 AND mov17 < mov34 AND mov34 > mov72;
> > mov72down_2 = mov34 < mov72 AND mov72 > mov144;
> > mov72down_3 = mov17 < mov34 AND mov34 < mov72 AND mov72 > mov144;
> > mov144down_2 = mov72 < mov144;
> > mov144down_3 = mov34 < mov72 AND mov72 < mov144;
> >
> >
> > for( i = 0; i < BarCount; i++ )
> > {
> > if (mov2up[i])
> > Lo = MinL2;
> > if (mov4up_2[i])
> > Lo = MinL4;
> > if (mov8up_2[i])
> > Lo = MinL8;
> > if (mov8up_3[i])
> > Lo = MinL8;
> > if (mov17up_2[i])
> > Lo = MinL17;
> > if (mov17up_3[i])
> > Lo = MinL17;
> > if (mov34up_2[i])
> > Lo = MinL34;
> > if (mov34up_3[i])
> > Lo = MinL34;
> > if (mov72up_2[i])
> > Lo = MinL72;
> > if (mov72up_3[i])
> > Lo = MinL72;
> > if (mov144up_2[i])
> > Lo = MinL144;
> > if (mov144up_3[i])
> > Lo = MinL144;
> >
> >
> > if (mov2down[i])
> > Hi = MaxH2;
> > if (mov4down_2[i])
> > Hi = MaxH4;
> > if (mov8down_2[i])
> > Hi = MaxH8;
> > if (mov8down_3[i])
> > Hi = MaxH8;
> > if (mov17down_2[i])
> > Hi = MaxH17;
> > if (mov17down_3[i])
> > Hi = MaxH17;
> > if (mov34down_2[i])
> > Hi = MaxH34;
> > if (mov34down_3[i])
> > Hi = MaxH34;
> > if (mov72down_2[i])
> > Hi = MaxH72;
> > if (mov72down_3[i])
> > Hi = MaxH72;
> > if (mov144down_2[i])
> > Hi = MaxH144;
> > if (mov144down_3[i])
> > Hi = MaxH144;
> > }
> >
> >
> > "LoRange: " + Lo + "\nHiRange: " + Hi;
> > Plot( C, _DEFAULT_NAME(), colorWhite, 64);
> > Plot(Hi, "HiRange", colorRed, styleLine);
> > Plot(Lo, "LoRange", colorGreen, styleLine);
> >
> >
> >
> > Please note that this group is for discussion between users only.
> >
> > To get support from AmiBroker please send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|