Hi everyone,
I'm trying to use sigScaleOut, but instead of Partial Exit, it Exit 100% Positon Size.
Even I use code in https://www.amibroker.com/guide/h_pyramid.html or my own code below, it sill Exit 100%.
I test by compare 2 case: only use Buy/Short= sigScaleOut and only use take profit using Sell/Cover with Same Profit target. The Total profit of two cases are equal.
I dont know if I forget setting something?
I have tried any options below, but it still exit 100%.
Any suggestion is highly aprreciated.
//SetPositionSize(2, spsShares );
//SetPositionSize( 50, spsPercentOfPosition* ( Buy == sigScaleOut OR Short == sigScaleOut));
//SetPositionSize( 50, IIf( Short == sigScaleOut OR Buy == sigScaleOut, spsPercentOfPosition, spsNoChange ) );
//SetPositionSize( 1, IIf( Short == sigScaleOut OR Buy == sigScaleOut, spsShares, spsNoChange ) );
Full Code
Plot(MA( C, 10 ), "MA 10", colorRed);
Plot(MA( C, 50 ), "MA 50", colorBlue);
BuyE = Cross( MA( C, 10 ), MA( C, 50 ) );
SellE = Cross( MA( C, 50 ), MA( C, 10 ) );
ShortE = SellE;
CoverE = BuyE;
holdBuy = Flip(BuyE, SellE);
holdShort = Flip(ShortE, CoverE);
FirstProfitTarget = 5; // profit
SecondProfitTarget = 10; // in point
//Because I will trade on next bar opem
LongEntryPrice = IIf(Ref(holdBuy, -1), ValueWhen(Ref(BuyE,-1) ==1, O, 1), 0);
ShortEntryPrice = IIf(Ref(holdShort, -1), ValueWhen(Ref(ShortE,-1)==1, O, 1), 0);
//TP =Take profit
BuyTP = Ref(holdBuy, -1) && C >= (LongEntryPrice + FirstProfitTarget);
ShortTP = Ref(holdShort, -1) && C <= (ShortEntryPrice -FirstProfitTarget);
BuyTP = ExRem(BuyTP, SellE);
ShortTP = ExRem(ShortTP, CoverE);
BuyTP2 = Ref(holdBuy, -1) && C >= (LongEntryPrice + SecondProfitTarget);
ShortTP2 = Ref(holdShort, -1) && C <= (ShortEntryPrice -SecondProfitTarget);
BuyTP2 = ExRem(BuyTP2, SellE);
ShortTP2 = ExRem(ShortTP2, CoverE);
Buy = IIf(BuyTP, sigScaleOut, BuyE); //Buy = BuyE + BuyTP*sigScaleOut;
Short = IIf(ShortTP, sigScaleOut, ShortE); //Short = ShortE + ShortTP*sigScaleOut;
Sell = IIf(BuyTP2, 3, SellE);
Cover = IIf(ShortTP2, 3, CoverE);
//SetPositionSize(2, spsShares );
//SetPositionSize( 50, spsPercentOfPosition* ( Buy == sigScaleOut OR Short == sigScaleOut));
//SetPositionSize( 50, IIf( Short == sigScaleOut OR Buy == sigScaleOut, spsPercentOfPosition, spsNoChange ) );
//SetPositionSize( 1, IIf( Short == sigScaleOut OR Buy == sigScaleOut, spsShares, spsNoChange ) );