Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Output when changing order

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Output when changing order

    Hello

    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

    #2
    Hello impeeza,

    Thank you for your reply.

    This doesn't have anything to do with your print statements, this looks like it's from the Log tab of the Control Center or printed in the Output log if you have TraceOrders = true in State.SetDefaults. It's occurring because this will fire off on each tick when the current Low is less than or equal to your TargetShortPricetoBE value.

    if (Low[0] <= targetShortPricetoBE)
    {
    ChangeOrder(stopShortOrder, stopShortOrder.Quantity, 0, Position.AveragePrice);
    //code continues

    It's because this gets fired off repeatedly for that same order. I'd perhaps consider using a bool to only trigger this one time, when the Low is initially below the target short price, and reset that bool when the position is exited, much like you're doing with that printOnce bool.

    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    61 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X