Conditions on two different time frames

Posted By: deweymcg

Conditions on two different time frames - 05/13/13 22:13

Sorry to be such a newb. I am trying to write a script that will first check the Daily Close from yesterday and see if it is above both the EAM 50 and EMA 20. If it is in between, do nothing. If it is above, then look at the 1 hour time frame and enter a long if the Williams%R goes below -80. If it is below the EMA's then go short if on the 1 hour time frame the Williams%R goes above -20.

I will add a few more conditions once I get this part figured out. I keep getting errors and am not sure where I am screwing up:

function run()
{
BarPeriod = 60;


TimeFrame = 24;

vars DailyClose = series(priceClose(1));
vars EMA50 = series(EMA(DailyClose,50));
vars EMA20 = series(EMA(DailyClose,20));

TimeFrame = 1;

Stop = 6.5*ATR(30);
TakeProfit = 9*ATR(30);


if ((DailyClose > EMA50) and (DailyClose > EMA20)
and (WillR(14) < -80))

enterLong();


else if ((DailyClose < EMA50) and (DailyClose < EMA20)
and (WillR(14) > -20))

enterShort();

}

Please have a look and point me in the right direction.
Posted By: TankWolf

Re: Conditions on two different time frames - 05/14/13 00:31

Originally Posted By: "Code"

function run()
{
BarPeriod = 60;
LookBack = 100;

TimeFrame = 24;
vars DailyClose = series(priceClose());
vars EMA50 = series(EMA(DailyClose,50));
vars EMA20 = series(EMA(DailyClose,20));

TimeFrame = 1;
Stop = 6.5*ATR(30);
TakeProfit = 9*ATR(30);

if ((*DailyClose > *EMA50) and (*DailyClose > *EMA20)
and (WillR(14) < -80))
enterLong();
else if ((*DailyClose < *EMA50) and (*DailyClose < *EMA20)
and (WillR(14) > -20))
enterShort();
}


For comparing a variable that is the target of the pointer, add a '*' to the pointer name, just as in the pointer definition. This way the variable can be directly read.

Hope this helps.
Posted By: deweymcg

Re: Conditions on two different time frames - 05/14/13 00:46

Thanks!
© 2024 lite-C Forums