[SOLVED]-Frame skip - how does it work

Posted By: BobbyT

[SOLVED]-Frame skip - how does it work - 07/16/17 21:20

Hi all,

I've been delving into multisymbol and multitimeframe development this week and wanted to ask a question about skipped frames.

Here is an excerpt from the log file where a position is placed on M5 then M15 somewhat close together:
Code:
[94010: Sun 10-05-02 23:59] +0 +0 0/0  1.0162/1.01631.0162/1.0162
Enter 1S USD/CAD  Entry 1.0140 TP 1.0040 at 23:59:00
(USD/CAD:M5:S) Short 1@1.01399 Entry stop
USD/CAD:Short:M5:366/0:Pd @1.01399:TP @1.00399:TZ@1.01599, myTP @1.00399

[94011: Mon 10-05-03 00:00] +0 +0 0/0  1.0162/1.01651.0162/1.0165
[USD/CAD:M5:S] Skipped: Frame
[94012: Mon 10-05-03 00:01] +0 +0 0/0  1.0165/1.01661.0163/1.0163
[USD/CAD:M5:S] Skipped: Frame
[94013: Mon 10-05-03 00:02] +0 +0 0/0  1.0163/1.01631.0161/1.0161
[USD/CAD:M5:S] Skipped: Frame
[94014: Mon 10-05-03 00:08] +0 +0 0/0  1.0161/1.01621.0161/1.0162
[USD/CAD:M5:S] Skipped: Frame
[94015: Mon 10-05-03 00:09] +0 +0 0/0  1.0162/1.01631.0162/1.0163
[94016: Mon 10-05-03 00:10] +0 +0 0/0  1.0163/1.01641.0162/1.0163
...
[94049: Mon 10-05-03 00:59] +0 +0 0/0  1.0175/1.01761.0175/1.0175
[94050: Mon 10-05-03 01:00] +0 +0 0/0  1.0175/1.01761.0175/1.0176
Enter 1S USD/CAD  Entry 1.0149 TP 1.0049 at 01:00:00
(USD/CAD:M15:S) Short 1@1.01493 Entry stop
USD/CAD:Short:M15:885/0:Pd @1.01493:TP @1.00493:TZ@1.01692, myTP @1.00492

[94051: Mon 10-05-03 01:01] +0 +0 0/0  1.0176/1.01761.0174/1.0174
[USD/CAD:M15:S] Skipped: Frame
[94052: Mon 10-05-03 01:02] +0 +0 0/0  1.0174/1.01751.0174/1.0175
[USD/CAD:M15:S] Skipped: Frame
[94053: Mon 10-05-03 01:03] +0 +0 0/0  1.0175/1.01751.0175/1.0175
[USD/CAD:M15:S] Skipped: Frame
[94054: Mon 10-05-03 01:05] +0 +0 0/0  1.0175/1.01791.0175/1.0178
[USD/CAD:M15:S] Skipped: Frame
[94055: Mon 10-05-03 01:06] +0 +0 0/0  1.0178/1.01781.0176/1.0177
[USD/CAD:M15:S] Skipped: Frame
[94056: Mon 10-05-03 01:08] +0 +0 0/0  1.0177/1.01771.0176/1.0176
[USD/CAD:M15:S] Skipped: Frame
[94057: Mon 10-05-03 01:09] +0 +0 0/0  1.0176/1.01761.0174/1.0175
[USD/CAD:M15:S] Skipped: Frame
[94058: Mon 10-05-03 01:10] +0 +0 0/0  1.0175/1.01751.0174/1.0175
[USD/CAD:M15:S] Skipped: Frame
[94059: Mon 10-05-03 01:11] +0 +0 0/0  1.0175/1.01751.0173/1.0173
[USD/CAD:M15:S] Skipped: Frame
[94060: Mon 10-05-03 01:12] +0 +0 0/0  1.0173/1.01741.0173/1.0174
[USD/CAD:M15:S] Skipped: Frame
[94061: Mon 10-05-03 01:13] +0 +0 0/0  1.0174/1.01741.0173/1.0173
[USD/CAD:M15:S] Skipped: Frame
[94062: Mon 10-05-03 01:14] +0 +0 0/0  1.0173/1.01751.0173/1.0175
[USD/CAD:M15:S] Skipped: Frame
[94063: Mon 10-05-03 01:15] +0 +0 0/0  1.0175/1.01761.0175/1.0175
[USD/CAD:M15:S] Skipped: Frame
[94064: Mon 10-05-03 01:16] +0 +0 0/0  1.0175/1.01751.0175/1.0175
[USD/CAD:M15:S] Skipped: Frame
[94065: Mon 10-05-03 01:17] +0 +0 0/0  1.0175/1.01761.0175/1.0176
[94066: Mon 10-05-03 01:18] +0 +0 0/0  1.0176/1.01771.0176/1.0176
[94067: Mon 10-05-03 01:19] +0 +0 0/0  1.0176/1.01771.0176/1.0177



As you can see the strategy is using M1 bars.

What is the deal with the Skipped: Frame messages? The ones following M15 trades are of particular concern. Do they mean that the strategy ignores the shorter timeframe bars if they fall within a higher timeframe bar? Put differently, if a trade is placed on M15 at 8:00, does it then not look for trades on M5 @ 8:05, 8:10 and 8:15? If so, how can I address this? I tried syncTimeFrame evey time TimeFrame was set but I get an error saying there aren't enough bars so I'm assuming my implementation was wrong.

Cheers,
BobbyT

Posted By: jcl

Re: Frame skip - how does it work - 07/17/17 08:57

You've disabled the trading on that bar, probably with TimeFrame. The purpose of TimeFrame is trading on a greater time frame than the bar period. If you don't want that, set Timeframe back to 1 when trading.
Posted By: BobbyT

Re: Frame skip - how does it work - 07/17/17 15:49

OK, I think I get it. Just to clarify though. BarPeriod can be thought of as the 'trading timeframe' where all trade based activities (entry, exit, pendings etc) are carried out. TimeFrame can be thought of as our 'indicator/signal timeframe' where data is retrieved about the market that is from a time period different to BarPeriod.

So any strategy should essentially flow like this:
run()
BarPeriod = 60;
TimeFrame = 4;
GetSignalInformation()...
TimeFrame = 1;
EnterTrades();

Correct?

Cheers,
BobbyT
Posted By: BobbyT

Re: Frame skip - how does it work - 07/17/17 17:55

Solved! The above works as intended laugh

EDIT: quick question though if I may. For intraday timeframes, is it best to set TimeFrame = 1 or TimeFrame = frameSync(1) after building the indicator/signal series?
Also, I am now getting multiple trades on a single bar on the higher timeframe. Say a signal arrives on M15 @ 8:00, we celebrate and open a trade from TimeFrame = 1 (ie BarPeriod). However, as BarPeriod = 5, at both 8:05 and 8:10 more trades are opened as we are still inside the 8:00 M15 candle.
I see that TradesPerBar is a thing but do we have a TradesPerCandle equivalent? I can't find one so I'm guessing no. How then can we limit trades by candle instead of bar.
Posted By: BobbyT

Re: Frame skip - how does it work - 07/18/17 01:04

Solved:
Code:
bool TradedThisCandle(int tf)
{
	int n = 0;
	
	for(all_trades){
		if(strstr(TradeAsset, Asset))	{	//trade belong to current asset 
			if(strstr(TradeAlgo, Algo)){	//trade belongs to current algo
				if(Bar-TradeBarOpen < tf){ //enumerate trades that were opened in the last 
				n += 1; 	
				}
			}	
		}
	} //end for(all_trades)
	
	if(n > 0) {
		printf("#nAlready traded this candle");
		return true;
	}
	else {
		printf("#nWe have not traded this candle yet");
		return false;
	}
}



Still curious about frameSync() though laugh

Cheers,
BobbyT
© 2024 lite-C Forums