I have a low level strategy with the following two exits. The first is a scale-out, the second is the remaining full exit.
// Midway Profit Target -----------------------------------------------------------
if (mp == 1 AND UsePrftTgt1 AND High[i] >= MarkHalfwayPrftTgt AND OkToScaleOut1 AND BarsInTrade > 1)
{
if ( PrftTgt1_PctToExit < 100 )
{
Buy[ i ] = sigScaleOut;
BuyPrice[i] = Max(Open[i], MarkHalfwayPrftTgt);
OkToScaleOut1 = 0;
HitPT1 = 1;
}
else
{
Sell[i] = 1;
SellPrice[i] = Max(Open[i], MarkHalfwayPrftTgt);
mp = 0;
MarkEntryPrc = 0;
MarkEntryBN = 0;
MarkEntryDN = 0;
MarkEntryTN = 0;
MarkExitATRstopPrc = 0;
MarkLatestHHprftTgt = 0;
MarkHalfwayPrftTgt = 0;
BarsInTrade = 0;
}
}
// Profit Target -----------------------------------------------------------
if (mp == 1 AND UsePrftTgt2 AND High[i] >= MarkLatestHHprftTgt AND OkToScaleOut2 AND BarsInTrade > 1)
{
if ( PrftTgt2_PctToExit < 100 )
{
Buy[ i ] = sigScaleOut;
BuyPrice[i] = Max(Open[i], MarkLatestHHprftTgt);
HitPT2 = 1;
OkToScaleOut2 = 0;
}
else
{
Sell[i] = 1;
SellPrice[i] = Max(Open[i], MarkLatestHHprftTgt);
mp = 0;
MarkEntryPrc = 0;
MarkEntryBN = 0;
MarkEntryDN = 0;
MarkEntryTN = 0;
MarkExitATRstopPrc = 0;
MarkLatestHHprftTgt = 0;
MarkHalfwayPrftTgt = 0;
BarsInTrade = 0;
}
}
The position sizing looks like this:
SetPositionSize( PositionSizeDollarsOrPctInput, spsValue );
if (HitPT1) { SetPositionSize( PrftTgt1_PctToExit, spsPercentOfPosition * ( Buy == sigScaleOut ) ); }
if (HitPT2) { SetPositionSize( PrftTgt2_PctToExit, spsPercentOfPosition * ( Buy == sigScaleOut ) ); }
The issue is that when both of these exits get hit on the same bar, it actually erroneously buys again on this exit bar. These exits work fine for all other bars if both exits do not hit on the same bar. How do I get a scale-out, and full exit on the same bar to work? Can AB handle multi-stage position sizing all from within one bar?