Hello friends, I'm trying to figure out why mycode sigscaleout doesn't work like in the chart. I started this code from development from here.
Some of the same topics still do not provide appropriate answers to my codings here, here.
//modification from https://www.amibroker.com/guide/h_pyramid.html
//http://www.amibroker.com/members/library/formula.php?id=1380
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
///////////////////////////////////////////////////////////////////////////////////////////////////
SetTradeDelays(0, 0, 0, 0);
SetOption("AllowPositionShrinking", True );
SetOption( "InitialEquity", 100000000 );
SetOption( "MaxOpenPositions", 80 );
TickSize = 0 ;
Buy1 = RSI() < 20 ;
Sell1 = RSI() > 80 ;
BarsSinceSell = BarsSince(Sell1);
BarsSinceBuy = BarsSince(Buy1);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FirstEntry = Buy1 ;
InFirstPos = Flip(FirstEntry, Sell1);
FirstTrigger = ExRem(InFirstPos, Sell1);
BarsSinceFirstTrigger = BarsSince(FirstTrigger);
FirstTriggerPrice = IIf(BarsSinceFirstTrigger < BarsSinceSell, Ref(C,-BarsSinceFirstTrigger), 0 );
SecondEntry = C < (FirstTriggerPrice) AND InFirstPos AND Ref(InFirstPos,-1);
InSecondPos = Flip(SecondEntry, Sell1);
SecondTrigger = ExRem(InSecondPos, Sell1);
BarsSinceSecondTrigger = BarsSince(SecondTrigger);
SecondTriggerPrice = IIf(BarsSinceSecondTrigger < BarsSinceSell, Ref(C,-BarsSinceSecondTrigger), 0);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Jual_1 = Sell1;
PosisiJual1 = Flip(Jual_1, Buy1);
Triger_jual1 = ExRem(PosisiJual1, Buy1);
Bars_sejak_jual1 = BarsSince(Triger_jual1);
TriggerJual1 = IIf(Bars_sejak_jual1 < BarsSinceBuy, Ref(C,-Bars_sejak_jual1), 0 );
Jual_2 = C > (TriggerJual1) AND PosisiJual1 AND Ref(PosisiJual1,-1);
PosisiJual2 = Flip(Jual_2, Buy1);
Triger_dua = ExRem(PosisiJual2, Buy1);
Bars_sejak_jual2 = BarsSince(Triger_dua);
secondTriggerJual = IIf(Bars_sejak_jual2 < BarsSinceBuy, Ref(C,-Bars_sejak_jual2), 0);
Buy = IIf( FirstTrigger, 1, IIf( SecondTrigger, sigScaleIn, 0 ) ) +
IIf(Triger_jual1, 1, IIf( Triger_dua, sigScaleOut, 0)) ;
Sell = sell1;
Sell = ExRem(Sell,Buy);
//Sell = ExRem(Buy,sell);
BuyPrice = SellPrice = C;
SetPositionSize(IIf( FirstTrigger,400, 800 ),
IIf( Buy > 0,spsShares, spsNoChange ) );
SetPositionSize( 50, IIf( Buy == sigScaleOut, spsPercentOfPosition, spsNoChange ) );
PlotShapes (IIf (FirstTrigger, shapeSmallCircle, shapeNone), colorWhite, 0,c, 0 );
PlotShapes (IIf (SecondTrigger, shapeSmallCircle, shapeNone), colorGreen, 0,C, 0 );
PlotShapes (IIf (Triger_jual1, shapeSmallCircle, shapeNone), colorRed, 0, C, 0);
PlotShapes (IIf (Triger_dua, shapeSmallCircle, shapeNone), colorBlue, 0, C, 0);
Need help to anyone thank you.