Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninja Traders 8 - Problems with Order Handling

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

    #16
    Hello ajsdnyyrr1234DDf,

    Thank you for your response.

    This is a known item that has been reported to FOREX.com. Currently this is expected on their end as two orders cannot act on the same position at the same time. They have let our development team know they are looking into this to attempt to prevent this error.

    In your case you would look into waiting for a position to exit first and then submit an entry when the exit fills. So instead of the Enter method to close the current position and open the new position consider using an Exit method with a specific signal name that you can check for as filled in OnExecutionUpdate() and then submit the entry for the new position.

    Please let me know if you have any questions.

    Comment


      #17
      Thanks. I implemented the suggestion. I am using Managed Orders so I am not calling any of the Order Objects to check the Order Status. Instead, I am checking MarketPosition to see if it is flat before placing the new entry order. I am adding a 5-second delay timer from the Exit Call to the Entry Call.

      Now the problem I am running into is, the timer is not getting executed for backtests. Is this expected?

      See below the code:


      private void GoLong()
      {
      if (Position.MarketPosition == MarketPosition.Short)
      {
      System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer {Interval = 5000};
      timer.Tick += delegate
      {
      Print("Timer finished GoLong: " + Time[0].ToString());
      timer.Stop();
      Print("Check for Market Position inside GoLong: " + Time[0].ToString());
      if (Position.MarketPosition == MarketPosition.Flat)
      EnterLong(Convert.ToInt32(Quantity), @"LongHACEU");
      timer.Dispose();
      };
      Print("Calling Exit inside GoLong: " + Time[0].ToString());
      ExitShort(@"ShortHACEU");
      Print("Starting Timer inside GoLong: " + Time[0].ToString());
      timer.Start();
      }
      else
      EnterLong(Convert.ToInt32(Quantity), @"LongHACEU");
      }


      ========

      See below the output from backtest run:

      Calling Exit inside GoLong: 6/13/2018 03:15:00
      Starting Timer inside GoLong: 6/13/2018 03:15:00
      Calling Exit inside GoLong: 6/18/2018 02:15:00
      Starting timer inside GoLong: 6/18/2018 02:15:00
      Enabling NinjaScript strategy 'Ninja8HACEU/140038328' : On starting a real-time strategy - StartBehavior=AdoptAccountPosition AccountPosition=EURUSD 4000S, EURUSD 4000S EntryHandling=All entries EntriesPerDirection=2 StopTargetHandling=By strategy position ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=False SetOrderQuantityBy=Strategy ConnectionLossHandling=Keep running DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes

      Comment


        #18
        Hello ajsdnyyrr1234DDf,

        Thank you for your response.

        Timers will not run in backtesting. You would not need to use a delay for your backtesting for these orders either.

        Please let me know if you have any questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Perr0Grande, Today, 08:16 PM
        0 responses
        2 views
        0 likes
        Last Post Perr0Grande  
        Started by elderan, Today, 08:03 PM
        0 responses
        5 views
        0 likes
        Last Post elderan
        by elderan
         
        Started by algospoke, Today, 06:40 PM
        0 responses
        10 views
        0 likes
        Last Post algospoke  
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        12 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        7 views
        0 likes
        Last Post quantismo  
        Working...
        X