I have an strategy where stop order change to BE in certain conditions. It runs OnEachTick.
if (MyBreakEven == BreakEven.Yes
&& stopShortOrder != null
&& stopShortPrice > Position.AveragePrice
&& CurrentBar > barNumberOfEntryShort)
{
targetShortPricetoBE = (Position.AveragePrice - ((Position.AveragePrice - targetShortPrice) * 0.5));
if (Low[0] <= targetShortPricetoBE)
{
ChangeOrder(stopShortOrder, stopShortOrder.Quantity, 0, Position.AveragePrice);
if (!printOnce)
{
Print(Time[0] + " || " + Name + " || " + Account + " || " + Instrument);
Print(" StopShort to BE " + targetShortPricetoBE + " Objetivo " + targetShortPrice);
Print("");
printOnce = true;
}
}
}
The problem is that when it occurs, output windows print a line every tick until position is closed
30/12/2020 20:03:04 Strategy 'TrendFree V 1.01/137491657': Changed custom managed order: orderId='b2f88af3e99f433e95447cb75c7be0a5' account='SimStrategies' name='Stop S1' orderState=Accepted instrument='NQ 03-21' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=12869.375 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=42868 time='2020-12-30 20:01:17' gtd='2099-12-01' statementDate='2020-12-30' limitPriceChanged=0 quantityChanged=2 stopPriceChanged=12869,375
30/12/2020 20:03:04 Strategy 'TrendFree V 1.01/137491657': Changed custom managed order: orderId='b2f88af3e99f433e95447cb75c7be0a5' account='SimStrategies' name='Stop S1' orderState=Accepted instrument='NQ 03-21' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=12869.375 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=42868 time='2020-12-30 20:01:17' gtd='2099-12-01' statementDate='2020-12-30' limitPriceChanged=0 quantityChanged=2 stopPriceChanged=12869,375
30/12/2020 20:03:04 Strategy 'TrendFree V 1.01/137491657': Changed custom managed order: orderId='b2f88af3e99f433e95447cb75c7be0a5' account='SimStrategies' name='Stop S1' orderState=Accepted instrument='NQ 03-21' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=12869.375 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=42868 time='2020-12-30 20:01:17' gtd='2099-12-01' statementDate='2020-12-30' limitPriceChanged=0 quantityChanged=2 stopPriceChanged=12869,375
30/12/2020 20:03:04 Strategy 'TrendFree V 1.01/137491657': Changed custom managed order: orderId='b2f88af3e99f433e95447cb75c7be0a5' account='SimStrategies' name='Stop S1' orderState=Accepted instrument='NQ 03-21' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=12869.375 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=42868 time='2020-12-30 20:01:17' gtd='2099-12-01' statementDate='2020-12-30' limitPriceChanged=0 quantityChanged=2 stopPriceChanged=12869,375
30/12/2020 20:03:05 Strategy 'TrendFree V 1.01/137491657': Changed custom managed order: orderId='b2f88af3e99f433e95447cb75c7be0a5' account='SimStrategies' name='Stop S1' orderState=Accepted instrument='NQ 03-21' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=12869.375 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=42868 time='2020-12-30 20:01:17' gtd='2099-12-01' statementDate='2020-12-30' limitPriceChanged=0 quantityChanged=2 stopPriceChanged=12869,375
30/12/2020 20:03:05 Strategy 'TrendFree V 1.01/137491657': Changed custom managed order: orderId='b2f88af3e99f433e95447cb75c7be0a5' account='SimStrategies' name='Stop S1' orderState=Accepted instrument='NQ 03-21' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=12869.375 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=42868 time='2020-12-30 20:01:17' gtd='2099-12-01' statementDate='2020-12-30' limitPriceChanged=0 quantityChanged=2 stopPriceChanged=12869,375
30/12/2020 20:03:05 Strategy 'TrendFree V 1.01/137491657': Changed custom managed order: orderId='b2f88af3e99f433e95447cb75c7be0a5' account='SimStrategies' name='Stop S1' orderState=Accepted instrument='NQ 03-21' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=12869.375 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=42868 time='2020-12-30 20:01:17' gtd='2099-12-01' statementDate='2020-12-30' limitPriceChanged=0 quantityChanged=2 stopPriceChanged=12869,375
How can I prevent from this behaviour?
Thanks
Comment