Hello,
Im building system:
1. that goes long only ie. buys down bar in uptrend
2. that goes short only ie. shorts up bar in downtrend
3. goes long and short when both trends are present
The problem is that it signals error because IF loop has to be numeric and not
aray.
Could anyone point me to where I can find solution for this problem ?
It goes like this
// CODE BEGINN ********** 3 in 1 EOD system
p=20;
uptrend=RSI(p) >55;
dwtrend=RSI(p) < 45;
DIR=IIf( uptrend,5 ,IIf( dwtrend,4 ,7)); // direction up down both
u1=C >O;// trigger
d1=C < O;
if( dir==5)
{
// LONGS
Buy=d1* dir==5;
Sell=u1*dir==5;
Short=0;
Cover=0;
}
if( dir==4)
{
// SHORTS
Buy=0;
Sell=0;
Short=u1*dir==4;
Cover=d1*dir==4;
}
if( dir==7)
{
// BOTH
Buy=d1* dir==7;
Sell=u1*dir==7;
Short=u1*dir==7;
Cover=d1*dir==7;
} else;
//
// *****************END CODE
I tried this combination but it is not working:
p=20;
uptrend=RSI(p) >55;
dwtrend=RSI(p) < 45;
DIR=IIf( uptrend,5 ,IIf( dwtrend,4 ,7)); // direction up down both
u1=C >O;// trigger
d1=C < O;
for(i=1;i<BarCount;i++)
{
if (dir[i]==5)
Buy=d1* dir==5;
Sell=u1*dir==5;
Short=0;
Cover=0;
if (dir[i]==4)
Buy=0;
Sell=0;
Short=u1*dir==4;
Cover=d1*dir==4;
if (dir[i]==7)
// BOTH
Buy=d1* dir==7;
Sell=u1*dir==7;
Short=u1*dir==7;
Cover=d1*dir==7;
}