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

[amibroker] Re: AmiBroker 4.31.0 BETA Examples



PureBytes Links

Trading Reference Links




Tomasz AB is the 
best.  This example of Jason's does run and produce results so AB does 
evaluate the if expression but the results are strange and do not agree with the 
IIF function results.  see attached gif.  Would you explain what is 
happening?  I know you believe it is incorrect expression but there is no 
error generated by AB.
thanks
tom
<FONT face="Courier New" 
size=3> 
"Tomasz Janeczko" 
<<A 
href=""><FONT 
face="Courier New" size=3>amibroker@xxxx<FONT face="Courier New" 
size=3>> wrote:> Hello,> > About new if-else> 
if-else statement changes flow of execution (opposite to IIF function that 
evaluates all arguments).> and you can not really write> > 
if (H >Ref(H,-1))> > because it has no meaning. It would 
translate to > "If high array is higher than high array shifted one bar" 
(see tutorial below)> flow control statement has to get SINGLE 
boolean value to make decision which> execution path should be taken. 
> If you write H (or High) it means ARRAY (entire array) > if you 
write H[ i ] - it means i-th element of the array. The subscript operator [ 
] > allows you to access individual array elements.> > 
Instead you should write:> > for( i = 1; i < BarCount; i++ 
)> {> if ( H[ i ] > H[ i - 1 ] )> x[ i ] = H[ i 
];> else> x[ i ] = L[ i ];> }> > > 
this will translate to correct one> "for EVERY BAR 'i' assign i-th 
element of high array to the i-th element of x array if> i-th element 
of high array is higher than the previous element, otherwise assign i-th 
of> low array to the i-th element of x array"> > As you can 
see in many cases old-style AFL provides much more compact> form. I 
always tried to explain this advantage of AFL but only a few realised 
that.> New control statements should be used where it is better to use 
them.> As I tried to explain during last years in 80% of cases 
'old-style' AFL provides> the shortest formula. Only remaining 20% of 
cases needed script.> Those 'script-only' cases now can be coded in 
native AFL thanks to new for/while/if-else> statements. And this is 
correct usage of them - TO REPLACE SCRIPT PARTS.> 







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.



Attachment:
iffquestion.gif

Attachment: Description: "Description: GIF image"