A simple ScaleIn and ScaleOut system just can be done by me. Please help!

Hi, Guys,

I'm running out of every thing trying to make a ScaleIn and ScaleOut system working. And I'm here to ask you for help.:blush:

Here is what I'm trying to achieve:

  1. I got a trading system with 2 different buy signals and 2 different sell signals.

  2. For scaleIn:

I need to scaleIn 50% of my equity each buy signal. That means I'll buy 50% at buy signal1 and buy another 50% at buy signal2. If 2 buy signals are triggered( at different bar or at the same bar) the position will be 100%.

  1. For scaleOut:

If the position is 50% (just one buy signal1 triggered) I’ll just sell it at sell signal1, and if the position is 100% (both 2 buy signals triggered) I’ll scaleOut, each sell signal 50% (Selling 100% if both 2 sell signals triggered at the same bar) .

Thank you for your help.


Post my code here:

SetOption( "initialequity", 10000);
SetOption( "AccountMargin", 100);
MaxPos = 2;
SetOption( "MaxOpenPositions", MaxPos );
SetPositionSize( 50, spsPercentOfEquity);

FastMA = MA(C, 5);
SlowMA1 = MA(C, 20);
SlowMA2 = MA(C, 40));
BuySig1 = Cross(FMA, SlowMA1);
BuySig2 = Cross(FMA, SlowMA2);
SellSig1 = Cross(SlowMA1, FMA);
SellSig2 = Cross(SlowMA2, FMA);

I've tried this way, and it seems doesn't work:

Entry = BuySig1 OR BuySig2;
Exit = SellSig1 OR SellSig2;
Buy = IIf(Entry, sigScaleIn, 0);
Sell = IIf(Exit, sigScaleOut, 0);

You are making mistake in your coding. If you read http://www.amibroker.com/guide/h_pyramid.html you will see that both scale IN and OUTS should go to Buy/Short variable. Only full exit go to Sell and Cover.

Hi Yescgh! I would like to do something alike. Did you achieve what you wanted to do?