Act by the end of Timeframe?

 

Hi,

Could you help me, I want my system react only on prices at the end of given Timeframe i.e each 5min or 1 hour, but not by each tick?

MA is calculating ok, but I want signals were given by the same timeframe.

Appreciate,

Pavel

 

this code says... if the current time is more than 15 minutes after the open of the bar and less than 5 minutes before the end of the bar... (on a 1 hour time frame)

         if((TimeCurrent()>Time[0]+60*15) && (TimeCurrent()<Time[0]+60*55)) {} else return(0);  //dont trade on the first/last 5 min of the bar 
 
Puzzle:

Hi,

Could you help me, I want my system react only on prices at the end of given Timeframe i.e each 5min or 1 hour, but not by each tick?


So you don't want to calculate/process for each tick but just once at the end of a bar on your chosen timeframe ? it can't be done . . . at least not reliably done.

I am currently using GBPUSD tick data from Dukascopy for my Unit testing in the Strategy Tester, I have noticed that there are occasions where there are missing M1 bars, why? because there ere no ticks during that minute. So, if for example you tried to do your calculations/processing on the last minute of the current bar then there is a chance that it wouldn't happen due to a lack of ticks during that minute.

Can't you use the start of the next bar to trigger your code ? it is very easy to do and is reliable . . .

Reason: