|
Hello,
AFL offers actually superset of capabilities
of "general purpose"
language like Pascal as it allows both "normal"
(i.e. scalar)
constructs like Pascal AND array based operations
(not available in Pascal).
It is UP TO YOU which one you use. There are NO
limitations and
of course in your case j variabel CAN be used as
moving average period.
The only problem is YOUR SKILL, not the
language.
Correct way to code thing like this
"// this checks whether the price is above its moving av 52 bars ago and if so checks whether the close crossed mov av during the last 52 bars for a range of moving av periods and return the moing av period value when it crosses" is ( I am showing ONE OF MANY possible ways to
code this,
specifially I am showing the way how to code it
WITHOUT REF() statement
just to show you how you can use subscript
operator (as in Pascal))
// this checks
whether the price is above its moving av 52 bars ago
//AND if so checks whether the Close crossed mov av during the last 52 //bars for a range of moving av periods AND return the moing av period //value when it crosses function CheckMACross( period, Lookback ) { result = False; Cma = MA( C, period ); bar = BarCount - 1 - Lookback; if( Close[ bar ] < Cma[ bar ] ) { while( bar < BarCount ) { if( Close[ bar ] > Cma[ bar ] ) { result = True; } } } return result; } function WCBelowMALine() { found = False; for ( period = 52; j < 3 AND NOT found; j--) { found = CheckMACross( j, 52 ); } return result; } Best regards, Tomasz Janeczko amibroker.com
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 other support material please check also: http://www.amibroker.com/support.html YAHOO! GROUPS LINKS
|
- Re: [amibroker] How to code For loops without refering to ... Tomasz Janeczko
