Need help with Scaling in

#1
Can some please modify this piece of code to remove the scaling out part. I only need the scaling in.

It should just make the next trade when profit from the trade increase by 5%


// percent equity change threshold when pyramiding is performed
PyramidThreshold = 5;

// regular trading rules (no pyramiding)
Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );

e = Equity(1); // generate equity without pyramiding effect

PcntProfit = 100 * ( e - ValueWhen( Buy, e ) )/ValueWhen( Buy, e );

InTrade = Flip( Buy, Sell );

// ExRem is used here to ensure that scaling-in/out occurs
// only once since trade entry
DoScaleIn = ExRem( InTrade AND PcntProfit > PyramidThreshold, Sell );
DoScaleOut = ExRem( InTrade AND PcntProfit < -PyramidThreshold, Sell );

// modify rules to handle pyramiding
Buy = Buy + sigScaleIn * DoScaleIn + sigScaleOut * DoScaleOut;

PositionSize = IIf( DoScaleOut, 500, 1000 ); // enter and scale-in size $1000, scale-out size: $500


Thanks
 

Nikhil Dogra

Well-Known Member
#3
If you use algo trading platform like presto or mt3 or blitz you can simply use this code itself on amibroker for "entry" and implement the parameter in the algo platform to ignore sell trades & define a profit target in which the scaled in position can be squared off or a max defined loss level as the case may be.. This is a jugaad for your problem, otherwise better to find a freelancer on upwork.