Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

EntriesPerDirection and EntryHandling failed during simulated trading.

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

    EntriesPerDirection and EntryHandling failed during simulated trading.

    EntriesPerDirection and EntryHandling failed during simulated trading.
    Strategy opened more than 1 Entry Per Direction when I have opened positions that weren't closed.
    Instruments: EURUSD and GBPUSD

    Code:
    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            EntriesPerDirection = 1;
            EntryHandling = EntryHandling.AllEntries;
        }
    }
    I'm connected to NT FXCM Demo.
    The server disconnects on Friday after FX market closes and reconnects and opens on Sunday.
    Is that why EntriesPerDirection and EntryHandling failed during simulated trading?
    This is a "multi-instrument" pair trading strategy.
    Attached Files
    Last edited by johnnybegoode; 01-16-2019, 08:16 PM.

    #2
    Hello johnnybegoode,

    Thank you for the question.

    I wanted to check, is this an image of the real-time results?

    If there were a disconnect and the strategy was disabled then re-enabled that would be one case where you could see multiple entries in the same direction as the strategy would effectively be reset. In the strategies virtual performance it would only be in the direction by one while the account may have two in that direction. As I don't have any details on the setup or syntax used this is only a guess at what may have occurred. Can you provide more details on the events that transpired, was the script disabled and re-enabled?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      It is real-time.
      FXCM disconnects after market closes.
      I did disable and re-enable the strategy.
      I let it run unattended.

      Q1:
      Would adding to (State == State.Configure) reinforce 1 Entry Per Direction?
      Or would it not make a difference?
      Code:
      else if (State == State.Configure)
                  {
                      EntriesPerDirection = 1;
                      EntryHandling = EntryHandling.AllEntries;
                  }
      Q2:
      Would checking before opening orders reinforce 1 Entry Per Direction further?
      Would these 4 lines of checks work?
      Code:
      if          (
      
                  //          Conditions ....
      
      [B]&& (PositionsAccount[0].MarketPosition == MarketPosition.Flat)
                       && (PositionsAccount[0].Quantity == 0)
                       && (PositionsAccount[1].MarketPosition == MarketPosition.Flat)
                       && (PositionsAccount[1].Quantity == 0))[/B]
                  {
                      EnterLong(0,Quantity,"EURUSD");
                      EnterShort(1,Quantity,"GBPUSD");
                  }
      Last edited by johnnybegoode; 01-21-2019, 07:41 PM.

      Comment


        #4
        Hello johnnybegoode,

        Thank you for your response.

        Entry Handling and Entries Per Direction will only affect the orders submitted and not how many positions can be opened. As you indicate in your second question in your latest post you do in fact need to verify the positions if you do not want to scale into an open position. So the answer to your first question is to use your approach in the second question.

        Please let me know if you have any questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by arvidvanstaey, Today, 02:19 PM
        4 responses
        11 views
        0 likes
        Last Post arvidvanstaey  
        Started by samish18, 04-17-2024, 08:57 AM
        16 responses
        61 views
        0 likes
        Last Post samish18  
        Started by jordanq2, Today, 03:10 PM
        2 responses
        9 views
        0 likes
        Last Post jordanq2  
        Started by traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        48 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X