Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error Oco id

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

    Error Oco id

    Hi i'm having some trouble with oco order, in the attachment there is the problem .
    this is the script that i suppose create the problem: ( i'd like to point out that it gives me an error only on the nd 03-22, iif i use the fdax or other es 03-22 it doesn't give me an error)


    if (Position.GetUnrealizedProfitLoss(PerformanceUnit. Ticks) > m_tikTrailing && firstTrail)
    {
    if (Position.GetUnrealizedProfitLoss(PerformanceUnit. Ticks) > m_tikTrailing && firstTrail)
    {
    SetStopLoss(CalculationMode.Ticks, 0);
    firstTrail = false;

    }

    }

    I'm just checking when the position is in profit of more than 6 tik ( m_tikTrailing) ( first trial it's for the trialing stop loss that i'm not currently using so it doesn't matter)
    And then it comes this error
    Last edited by AlessioCianini12; 01-11-2022, 07:17 AM.

    #2
    Hello AlessioCianini12,

    Thanks for your post.

    The error message about OCO id error is consequential to the incorrect actions performed by the strategy. The bottom message is the real error here. It is saying that the strategy submitted an order that was rejected. The order was rejected because it was a buy-stop market order that was placed above the current price. The order was to be placed at 16386.5.

    I would suggest adding print statements to your code and print out the values being determined/used in your conditional statement along with the current price to see where the error is occurring. 6 ticks may or may not be an appropriate distance, as it depends on the volatility in the market.

    Comment


      #3
      Yeah ok but it normally works, so i'm wondering is it possible to put a setstoploss that when touched just send a market order?

      Comment


        #4
        Hello AlessioCianini12,

        Thanks for your reply.

        The SetStopLoss uses a buystopmarket type order that when price touches will change to a market order to be immediately filled. However, if you submit it above the current market price it is rejected. The stop loss must be below the current price when submitted.

        You can replace the SetStopLoss() if you wish by using a ExitLong() (or ExitShort() when going short) as these are market orders regardless of the price. Note: Do not use both SetStopLoss and the exit methods at the same time as it is possible you will have duplicate orders resulting in an unexpected position. You would need your logic to monitor price and when price hits your stop level you would submit the appropriate Exit order which again would be a market order.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        44 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        65 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X