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

[amibroker] DebugView and _Trace?



PureBytes Links

Trading Reference Links

I got the scaling out code from the help files working on the long 
side and now am tring to convert it to work on shorting. I have 
shortened the code to what is below just to get it to generate a 
trade. As it stands right now, at every short signal Cross of the 
MAs I get an immediate cover in the AA>SCAN. 

I read on the board here of the _Trace function and debugView. I 
downloaded DebugView and printed the _trace help file, but I still 
lack the knowledge to make debugView see my code. Does anyone know 
of an artical or help file describing the process of hooking up 
debugView to AmiBroker? I just can't seem to see why this code wont 
generate a short signal when it will for the buy side. 

I appreciate all the help this board gives. Thank You!

OT

--------------------------------------------------
FirstProfitTarget = .05; // profit 
TrailingStop = .1; // also in percent 
priceatshort=0;
Lowsinceshort=0;
exit = 0; 

Short = Cross( MA( C, 50 ), MA( C, 10 ) ); 
Cover = 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; 
       } 

       //Trail Stop Loss
      if( High[ i ] >= ( 1 + TrailingStop * 0.01 ) * Lowsinceshort ) 
       { 
         exit = 4;    
         CoverPrice[ i ] = ( 1 + TrailingStop * 0.01 ) * 
Lowsinceshort ; 
       } 

      //Reset for the next loop
      if( exit >= 3 ) 
       { 
         Short[ i ] = 0; 
         Cover[ i ] = exit + 1; // mark appropriate exit code 
         exit = 0; 
         priceatshort= 0; // reset price 
         Lowsinceshort = 0; 
       } 
    } 
} 

SetPositionSize( 50, spsPercentOfEquity ); /*Initial % of equity to 
be traded.*/
SetPositionSize( 50, spsPercentOfPosition * ( Short == 
sigScaleOut ) ); /* percentage to scale out when PT's are hit*/