Foreign Moving Average

Hello,
Trying to learn....Foreign( "^aord", "Close" )> MA(Foreign( "^aord.au", "Close" ),30);
The above line of code is trying to say the Australian All Ordinaries index must be above the 30MA of the All Ordinaries Index..as it is I get no result in the back test...
Any help appreciated to correct the problem...full code below

maxpos = 10; // maximum number of open positions
SetOption("InitialEquity", 100000 ); // set initial equity = 100K
SetOption( "MaxOpenPositions", maxpos );
SetPositionSize( 100 / maxpos, spsPercentOfEquity );


Buy = C > ma(C,10) AND C > 1 AND C*V>25000 AND MA(v,50)>100000 AND
EMA(0.4*ROC(C,65)+ 0.3*ROC(C,130) +0.3*ROC(C,260),30)>10 AND **Foreign( "^aord", "Close" )> MA(Foreign( "^aord.au", "Close" ),30);**

ApplyStop(stopTypetrailing, 
         stopModePercent, 
         //Optimize( "max. loss stop level", 20, 8, 24, 1 ), 
         23,
         True );
Sell=0;
Short=0;
Cover=0;

Does these symbols in your database start with a caret sign (^)? They need to be exactly same. Otherwise, this should work:

maxpos = 10; // maximum number of open positions
SetOption( "InitialEquity", 100000 ); // set initial equity = 100K
SetOption( "MaxOpenPositions", maxpos );
SetPositionSize( 100 / maxpos, spsPercentOfEquity );

Buy = C > ma( C, 10 ) AND C > 1 AND C * V > 25000 AND MA( v, 50 ) > 100000 AND
     EMA( 0.4 * ROC( C, 65 ) + 0.3 * ROC( C, 130 ) + 0.3 * ROC( C, 260 ), 30 ) > 10 AND Foreign( "^aord", "C" ) > MA( Foreign( "^aord.au", "C" ), 30 );

ApplyStop( stopTypetrailing,
           stopModePercent,
           //Optimize( "max. loss stop level", 20, 8, 24, 1 ),
           23,
           True );
Sell = 0;
Short = 0;
Cover = 0;

BTW whether you used those asterisks (*) in your code just to highlight, I have only removed them!

The solution and proper code are given in the Knowledge Base:

http://www.amibroker.com/kb/2014/09/20/broad-market-timing-in-system-formulas/

And obviously you need to get the symbols right.

Proper symbol for ASX All Ordinaries (used by Yahoo Finance) is:

^AORD

(https://finance.yahoo.com/quote/^AORD?p=^AORD&.tsrc=fin-srch).

So Foreign( "^aord.au", "C" ) is incorrect.

It should be Foreign( "^AORD", "C" )

1 Like

Note that index symbology differs between data vendors.

Since 1980, the Australian Stock Exchange has used XAO.

Norgate Data uses $XAO (or $XAO.au if you have both US and Australian stocks installed). Premium Data uses XAO.

1 Like