[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Why wont this code allow short trades???



PureBytes Links

Trading Reference Links

I tried to make this help file code work on the short side, but it 
never even enters into a single trade. I did set the backtest 
positions to short. Could someone please just take a quick look at 
this small piece of code and maybe you can see why it wont trade 
short. I believe it is something simple but I can't seem to find 
it.Thank you.
---------------------------
Short = Cross( MA( C, 10 ), MA( C, 5 ) ); 
Cover = 0 ; 
priceatshort=0;
Lowsinceshort=0;
exit = 0; 

for( i = 0; i < BarCount; i++ ) 
{ 
   if( priceatshort == 0 AND Short[ i ] ) 
    { 
       priceatshort = ShortPrice[ i ]; 
    } 
   if( priceatshort > 0 ) 
    { 
       Lowsinceshort= Min( Low[ i ], Lowsinceshort); 
      //PT1
      if( exit == 0 AND Low[ i ] <= ( 1 - FirstProfitTarget * 0.01 ) 
* priceatshort) 
       { 
         exit = 1; 
		  ShortPrice[i] = ( 1 - FirstProfitTarget * 0.01 ) * 
priceatshort;  
         Short[ i ] = sigScaleOut; 
       }