Scale out of shorts

if ( C[b] >= HHV_5[b] AND C[b] >  (Sell_avg+0.2))
    {
		if(fristsell==0)
		{
			fristsell=fristsell+1;
			Sell_avg=0;
		}
        PosSell=PosSell + 1;
        Short[b] = sigScaleIn;
        ShortPrice[b] = C[b] ;
        Sell_avg=((POS_SIZE*(PosSell-1)*Sell_avg)+(C[b]*POS_SIZE))/((POS_SIZE*PosSell));
    }
    else
    {
        if ( C[b] < (Sell_avg) AND PosSell > 0 )
        {
            PosSell = PosSell-1;
            Cover[b] = sigScaleOut;
            CoverPrice[b] = C[b] ;
            if(PosSell==0)
            {
				Sell_avg=0;
				fristsell=0;
            }
        }
     }
}


SetPositionSize( POS_SIZE, spsShares ); 
//SetPositionSize( POS_SIZE, spsShares * ( sell == sigScaleOut ) );
SetPositionSize( POS_SIZE, spsShares * ( Cover == sigScaleOut ) ); 

hi I am unable to scale out of short position
Thanks

As written in the manual http://www.amibroker.com/guide/h_pyramid.html both sigScaleIn AND sigScaleOut should be assigned to Buy/Short variable. Only full exit signals (not scaling) should be assigned to Sell/Cover.

Quote:

All you have to do to implement pyraminding is to:

  • Assign sigScaleIn to BUY/SHORT variable if you want to scale-in (increase size of) LONG/SHORT position
  • Assign sigScaleOut to BUY/SHORT variable if you want to scale-out (decrease size of) LONG/SHORT position
1 Like