Hi,
Does anybody have basic code pattern they are willing to share for a higher timeframe determining direction for lower timeframe?

I have the Black Book script examples for trading with different assets, algos, and timeframes but I'm trying to figure out the easiest way to keep track of higher timeframe dummy trades to only take trades on lower timeframe in that direction.

I've spent many days on this and just think I'm out of my league.

I thought about having multiple Zorro instances running with a master script where the higher timeframe systems share positions with the lower timeframe systems.

That may be way overengineering and stretch my abilities a bit but it seems like it would be the most flexible way to pull this off.

Maybe my whole approach is just not based in reality. Maybe I need a for(opentrades) loop inside the higher time frame function.

I tried to call the lower time frame function from inside the higher timeframe function but that caused issues with optimizing the htf parameters.

It seems like using the Phantom trades might be a good way to do this. Am I way off base here?

It seems like the LotsPhantom is always 0 with this code and I'm not sure if you can just turn the Phantom flag on and off like this.

I'd appreciate any insights into this.

Code
 
function tradeCorrelationHTF()
{
        // PHANTOM set on always before calling this function and turned off after
	TimeFrame = frameSync(4);   // for 60 minute timeframe
        // Trade logic
        enterLong();
}

function tradeCorrelation()
{
	TimeFrame = 1;
        // Trade logic
	if(LotsPhantom > 0)
		enterLong();
}

function run()
{
	set(PARAMETERS+FACTORS+LOGFILE+PLOTNOW);
	BarPeriod = 15;
	while(asset(loop("EUR/USD","USD/JPY")))
	{
		while(algo(loop("CO","TC")))
		{
			if(Algo = "TC")
				tradeCorrelation();
			else if(Algo = "CO"){
                                // TrainMode PHANTOM Exclude phantom trades. Otherwise phantom trades are treated as normal trades in the training process. 
                                // Guessing that I should not set this - I should not exclude phantom trades from training because they 
				// setf(TrainMode,PHANTOM);

                                // TradeMode TR_PHANTOM Enter trades in phantom mode. The trades are simulated and not sent to the broker API. 
				setf(TradeMode,TR_PHANTOM);

				tradeCorrelationHTF();

                                // Turn Phantom off for lower timeframes to actually trade
				resf(TrainMode,PHANTOM);
				resf(TradeMode,TR_PHANTOM);
		}
	}
}


Thanks!