This sells 10% after a 10% increase. You can alter the PerCentGain if you want it to be 10% of your target.
Check the minimum lot size for the instrument:
ONCE partialclose = 1
ONCE PerCent = 0.1 //10% of position to close
ONCE PerCentGain = 0.1 //10% increase
ONCE MinLotSize = 0.5 //0.5 lots minimum
ExitQuantity = abs (CountOfPosition ) * PerCent
LeftQty = max (MinLotSize,abs (CountOfPosition ) - ExitQuantity)
CloseQuantity = abs (CountOfPosition ) - LeftQty
IF Not OnMarket THEN
Flag = 1
ENDIF
IF partialclose AND LongOnMarket and close >= (PositionPrice * (1 + PerCentGain)) AND Flag THEN
SELL CloseQuantity Contracts AT Market
Flag = 0
endif
1 user thanked author for this post.