Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error with stop-order

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

    Error with stop-order

    Sometimes when a stop order is sent by my strategy, it causes an error because the price (bad/ask) has changed quickly and then the stop-order is not correct. The problem is that the strategy is turned-off automaticly. How can I solve it?

    Thanks in advance.

    #2
    Hello soyjesus,

    How are you setting your stop loss order inside of your code?

    Example:
    Code:
    protected override void OnBarUpdate()
    {	
    
    if(MarketPosition.Flat != Position.MarketPosition)
    {
    //sets stop loss 5 ticks behind average entry price
    SetStopLoss(CalculationMode.Ticks, 5);
    }
    }
    JCNinjaTrader Customer Service

    Comment


      #3
      With every new bar my strategy set a new level stop like: "SetStopLoss(CalculationMode.Price, LevelStop)" where LevelStop is a variable.

      The error occurs just when the strategy changes the level-stop for a new one.

      Comment


        #4
        Hello soyjesus,

        So using "CaclulationMode.Price" is going to be an absolute value, which you would want to make sure that it is being reset after the position is closed so that it will not use the same price for the next order that gets processed.

        Here is a reference that demonstrates this that you may view at the link below.



        You may also add TraceOrders = true to your Initialize() method and you view valuable output related to strategy submitted orders through Tools > Output window to see what price your stop loss is being set to so it is easier to see what is happening.
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        382 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        1 view
        0 likes
        Last Post oviejo
        by oviejo
         
        Started by pechtri, 06-22-2023, 02:31 AM
        10 responses
        125 views
        0 likes
        Last Post Leeroy_Jenkins  
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Yesterday, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Working...
        X