TimeFrame Problem

 

Hi,

I am facing a problem of Timeframe for iMA. See below:-

int timeframe=30;
int period=10;

double MA =iMA(NULL,timeframe,period,0,MODE_SMA,PRICE_OPEN,0);


//inserted into open sell position
if(MA*(1+Percent/100)) trade=true;

//inserted into open buy position

if(MA*(1-Percent/100)) trade=true;

The code works fine in timeframe 30 and when I change it to TF other than 30, it doesn't open position on M1, M5, however just open sell on M15.

Any idea?

 

Ok...

An "if()" statement looks for something that is true or false...

if(something is true) do some task.

What is there that is true or false about if(MA*(1+Percent/100)) or if(MA*(1-Percent/100)) ?

 
I don't know much about coding, but didn't you already define the timeframe above as 30 minutes? If that remains in the code, won't it only work on the 30 min chart irregardless!? DK
Reason: