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

Only one enter long order is triggered when all conditions are met

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

    Only one enter long order is triggered when all conditions are met

    Hi

    I have created a strategy to test using the strategy builder wizard. I've used the wizard to get the framework of the system sorted, & am expecting to update the code for some of the more details conditions.

    When my conditions are met I want to create 2 buy market orders. I've created them both in the wizard but only one is being triggered, the first one in the list.

    I've tried to set the unique entries or all entries, I've also changed from number of entries per direction to 2. Something isn't working correctly here but I'm not sure why.

    The reason I want to use 2 orders is so that I can have one set to a fixed profit target & one will use a trailing stop that I'm going to have to code myself I think.

    Any help would be appreciated, please see the code below

    Code:
    EntriesPerDirection                        = 1;
    EntryHandling                                = EntryHandling.UniqueEntries;

    Code:
    protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0) 
                    return;
    
                if (CurrentBars[0] < 1)
                    return;
    
                 // Set 1
                if ((RSI1.Avg[0] > RSI_long))
                {
                    EnterLong(Convert.ToInt32(DefaultQuantity), @"Buy_2");
                    EnterLong(Convert.ToInt32(DefaultQuantity), @"Buy_1");
                }
    
                 // Set 2
                if (Close[0] < HMA1[0])
                {
                    ExitLong(Convert.ToInt32(DefaultQuantity), @"Exit_Long_1", @"Buy_1");
                    ExitLong(Convert.ToInt32(DefaultQuantity), @"Exit_Long_2", @"Buy_2");
                }
    
            }
    In the above example only Buy_2 is being created

    #2
    EnteriesPerDirection = 2

    Comment


      #3
      Hi Emma, thanks for the response, I've tried this but it's not working

      If I'm using multiple entries I'm assuming I should use unique entries though?

      Comment


        #4
        Hello Gav_G,

        Unique entries would allow for both entries when each entry has a unique signal name.

        Have these default settings been changed and the script compiled since the script was added to a chart? (If so, remove and re-add the instance from the chart to reload the defaults)

        If that does not correct the behavior, may I test the script on my end?

        To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
        1. Click Tools -> Export -> NinjaScript...
        2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
        3. Click the 'Export' button
        4. Enter a unique name for the file in the value for 'File name:'
        5. Choose a save location -> click Save
        6. Click OK to clear the export location message
        By default your exported file will be in the following location:
        • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
        Below is a link to the help guide on Exporting NinjaScripts.
        http://ninjatrader.com/support/helpG...-us/export.htm

        Once exported, please attach the file as an attachment to your reply.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea

          Thanks for this, I now have this working, I think it was due to me needing to re add it to the chart.

          I was using the strategy analyser which I had open, I was compiling in the strategy builder & then hitting run. Am I right in saying that for default settings to take effect, I would need to close & reopen the strategy analyser?

          Comment


            #6
            Hello Gav_G,

            I would expect defaults to take effect immediately in the Strategy Analyzer without having to close it.

            I've tested on my end to confirm. Are you able to reproduce this behavior with the Strategy Analyzer?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I will test his & let you know if I see any different behaviour

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by warreng86, 11-10-2020, 02:04 PM
              7 responses
              1,360 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by Perr0Grande, Today, 08:16 PM
              0 responses
              5 views
              0 likes
              Last Post Perr0Grande  
              Started by elderan, Today, 08:03 PM
              0 responses
              9 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
              14 views
              0 likes
              Last Post maybeimnotrader  
              Working...
              X