I am trying to create multi time frame indicators.
My results do not look correct.
Printout in debugView is rather strange. After the initial step before any timeframe compression the value for Close and MACD are correct. After the first compression values for Close and MACD seem strange. Value for close is essentially a constant. The resulting indicator therefor is almost identical for all symbols.
Attached my code and Debug View printout for 1st symbol. Other symbols have the same pattern of a constant value for Close.
Appriciate all help.
If anyone is using this technique for trading, I would like to communicate with you for strategies.
//File: Create MT Indicators
//
//version 1.0
//June 3, 2025
//
//
Pgm_name = "MTF Composite Indicators";
//
//This program reads the components of of a given list and generates MTF MACD and saves it in ATC
//As a second step, It combines all the individual MTF MACD equity indicators for all the symbols in the index
// -------------------------------------------------------------------------------------------------------------------------------------
//
// Source List:
// - Multiple - See list below
//
//Target ATCs:
// - Indivudual symbols: "~MT_MACD" + symbol","C")
// - Composite Indicator:"~SMT_MACD" + WL Name", "C")
//
//
//
// ===================================================================================================================================
// ===================================================================================================================================
//
//
//
//
#pragma maxthreads 1 // May be necessary to limit threads so AB sends data to Debug View at a slower pace.
/*
AB = CreateObject("Broker.Application");
doc = AB.ActiveDocument;
doc.Interval = in1minute;
*/
//
bi = BarIndex();
ai = bi - bi[0];
//
//
//
//
// ========================================================================================================================================
// ========================================================================================================================================
// Process Data from All Markets List and add to the various target Lists
// ========================================================================================================================================
// ========================================================================================================================================
//
// Process program
_trace( "MTF-A1 symbol - Start program");
// The loop identifies Watch List number, adds symbol to list.
SourceListName = "AK-HighPriced-Issues"; // Watclist
SourceListNum = CategoryFind( SourceListName, CategoryWatchlist ); // Get List Number
SourceList = CategoryGetSymbols( Categorywatchlist, SourceListNum, 0 ) ; // Source List of symbols
Num_Symbols = StrCount( sourceList, "," ) + 1;
_trace( "MTF-B1 status " + writeval(status("action"),1.0) + " List_Num " + Writeval( SourceListNum, 1.0 ) + " Source_Name "
+ SourceListName + " numsymbols " + Writeval( Num_Symbols, 1.0 ) + " Source_List " + StrLeft(SourceList,50));
// Extraxt symbol and process in multi Time Frame
for( j = 0; ( sym = StrExtract( SourceList, j ) ) != ""; j++ )
{
//
_trace( "MTF-B2 - j " + writeval(j,1.0) + " symbol " + sym);
// Control Time Frame - Loop through chosen time frames
MDresult = 0;
MDCount = 0;
SymMD = 0;
SetForeign( sym );
_trace( "MTF-B3 status " + writeval(status("action"),1.0) + " - symbol " + sym + " close " + writeval( lastvalue(close), 1.2));
//
// Calculate MACD at multiple time Frames
for( jj = 1; jj <= 301; jj = jj + 5 )
//for( jj = 1; jj <= 301; jj++ )
{
TimeFrameSet( jj * in1Minute );
// MACD Parameters
Close_val= Close; // Placed here as a diagnostic
MACD1 = MACD( 12, 26 );
_trace( "MTF-B41 status " + writeval(status("action"),1.0) + " - symbol " + sym + " jj " + writeval( jj, 1, 0 )+ " close " + writeval( lastvalue(Close_val), 1.2) + " MACD1 " + writeval( lastvalue(MACD1), 1.2));
Timeframerestore();
//
_trace( "MTF-B42 - status " + writeval(status("action"),1.0) + " symbol " + sym + " jj " + writeval( jj, 1, 0 )+ " close " + writeval( lastvalue(Close_val), 1.2) + " MACD1 " + writeval( lastvalue(MACD1), 1.2));
//
X = IIf( TimeFrameExpand( MACD1, jj * in1Minute ) > 0, 1, -1 );
CV= TimeFrameExpand( Close, jj * in1Minute ); // Used as a diagnostic
MDresult = MDresult + X;
MDCount++;
//
_trace( "MTF-B43 - status " + writeval(status("action"),1.0) + " symbol " + sym + " jj " + writeval( jj, 1, 0 ) + " close " + writeval( lastvalue(CV), 1.1) + " MACD1 " + writeval( lastvalue(MACD1), 1.2) + " MD Count "
+ writeval( MDcount, 1.2) + " MDresult " + writeval( MDresult, 1.2 )+ " MTMACD " + writeval( MDresult / MDcount, 1.2 ));
//
//
} // end jj loop
//
RestorePriceArrays();
//
_trace( "MTF-B5 - status " + writeval(status("action"),1.0) + " symbol " + sym + " j " + writeval( j, 1, 0 ) + " Count " + writeval( lastvalue(MDcount), 1.2 )
+ " Result " + writeval( lastvalue(MDresult), 1.2 ) + " MACD Composit " + writeval( lastvalue(MDresult / MDcount), 1.2 ));
// Single Issue MT-MACD
AddtoComposite( MDresult / MDcount, "~MTMACD-" + sym, "C", atcFlagDefaults );
//AddtoComposite( MDresult / MDcount, "~MTMACD-" + sym, "C", atcFlagDefaults );
//
// Create sum of single issue MTMAACD to create multi Issue MT-MACD (SMTMACD)
//SymMD = SymMD + MDresult;
//
} // end j loop
//
// Multiple Issue STMACD for ETFs
SymMD = SymMD + MDresult;
AddtoComposite( SymMD / Num_Symbols, "~SMTMACD-" + SourceListName, "C", atcFlagDefaults );
//
_trace( "MTF-B6 - end list " + SourceListName + " SymMD " + writeval( lastvalue(SymMD), 1.0 ) + " Num symbols " + writeval( Num_Symbols, 1.0 ));
// ===================================================================================================================" );
//
Buy = Sell = 0;
//