Tomasz and Barry thanx for help. I ll look into it.


  ----- Original Message ----- 
  From: Barry Scarborough 
  To: [email protected] 
  Sent: 3. rujan 2008 20:55
  Subject: [amibroker] Re: 3 in 1 trading system


  I don't think you need the for loop or iif(...).
  you can use logic statements something like this:

  buy = sell = short = cover = False;

  // LONGS
  buy = di AND uptrend AND !dwtrend;
  Sell= u1 and uptrend AND !dwtrend;

  // SHORTS
  Short = u1 AND dwtrend AND !uptrend;
  Cover = d1 AND dwtrend AND !uptrend;

  // BOTH
  Buy = Cover = di AND uptrend AND dwtrend;
  Sell= Short = u1 AND uptrend AND dwtrend;

  Barry

  --- In [email protected], "DrazenStricek12" <[EMAIL PROTECTED]> 
  wrote:
  >
  > 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;
  > }
  >



   

  __________ NOD32 3412 (20080903) Information __________

  This message was checked by NOD32 antivirus system.
  http://www.eset.com

Reply via email to