TMF function that works in different timeframes

Posted By: nanotir

TMF function that works in different timeframes - 09/22/16 09:14

Right now TMF works either each tick or each candle defined by the BarPeriod, depending on the setup of the return value.
It would be nice if the TMF could work something in between. There is no point to setup the barperiod on h1 if the strategy works on D1 just to get the tmf function to work each hour.
I know one can use th TimeFrame function but the barperiod defines the plots instead so something like BarPeriodTMF = 60; and return 20 for this case would be useful.
Posted By: Sphin

Re: TMF function that works in different timeframes - 09/22/16 22:05

I might missunderstand you but within a TMF you can check time (day, hour, minute, second) so where is the problem to do an action each hour on a daily BarPeriod?
Posted By: nanotir

Re: TMF function that works in different timeframes - 09/23/16 07:19

Maybe it is me who do not understand the function.
For me the return value defines if TMF acts each tick or each candle, so how can I have 3 conditions inside the tmf function for M1, h1 and D1 for example?
Posted By: Sphin

Re: TMF function that works in different timeframes - 09/23/16 17:27

You can influence the behaviour of the TMF with the return values but you don't have to. Normally in trading the TMF runs every tick and therefore you can check your conditions each moment you like.

Code:
int DoTrade() {

  if(TradeIsNewBar) 
    // this condition is checked only once per bar
 
  if(hour() % 2 == 0 && ...)
    // this condition is checked only in even hours

  if(hour() == ... && minute() == ... && ...)
    // this is checked e.g. at a special hour/minute combination

return 0;
}

Posted By: nanotir

Re: TMF function that works in different timeframes - 09/28/16 08:07

Ok thanks

i did not think about it

i will leave this thread since it maybe useful for someone
© 2024 lite-C Forums