Dear Representative,
I'm attempting to use a monthly $SPX MACD crossover to trade (daily) either symbol IJH or AOA.
When I have $SPX displayed in the current pane and execute 'Explore', the monthly MACD & Signal display as I'd expect.
However, if I have IJH or AOA displayed in the current pane and execute 'Explore', I get different values for MACD & Signal.
I have researched the community forums and cannot seem to figure out what I'm doing wrong.
My intent with this code is to trade AOA or IJH daily based on the monthly MACD crossover.
I appreciate any advice you can provide.
I'm running AmiBroker ver. 6.30.05 on Windows 10 Pro, version 1809
//MACDMo.afl
//** Monthly SPX MACD signal **//
//** Hold 158 calendar days **//
//** Don's MACDMo.ini **//
//** Trade IJH, AOA, FBALX, or equivalent **//
SetTradeDelays (0,0,0,0);
TimeFrameSet (inMonthly );
SetForeign("$SPX",True,True);
MACD_Monthly = (MACD());
Signal_Monthly = (Signal());
TimeFrameRestore ();
mACD_Monthly = TimeFrameExpand(MACD_Monthly, inMonthly); signal_Monthly = TimeFrameExpand(Signal_Monthly, inMonthly);
BuySig = Cross( MACD_Monthly, Signal_Monthly ); SellSig = Cross( Signal_Monthly, MACD_Monthly );
Filter = 1;
AddColumn( MACD_Monthly, "SPX MACD" );
AddColumn( Signal_Monthly, "SPX Signal" ); AddColumn( BuySig, "BUY" ); AddColumn( SellSig, "SELL" );
RestorePriceArrays();
BuyPrice = C;
SellPrice = C;
OnBuy = Flip(BuySig,SellSig);
OnSell = Flip(SellSig,BuySig);
Buy = Sell = inPosition = Bcounter = 0;
sCounter = 1;
for( i = 0; i < BarCount; i++)
{
if( (NOT inPosition) AND sCounter >=109 AND OnBuy[ i ])
{
Buy[ i ] = 1;
inPosition = 1;
Bcounter = 0;
}
if( inPosition AND BCounter >=109 AND OnSell[ i ])
{
Sell[ i ] = 1;
inPosition = 0;
Scounter = 0;}
if( inPosition ) Bcounter++;
if( NOT inPosition ) Scounter++;
}