• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 itrader46, Today, 02:59 PM
              3 responses
              7 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by madams212121, Today, 12:10 PM
              13 responses
              27 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by jvanelli, Today, 12:19 PM
              1 response
              20 views
              0 likes
              Last Post NinjaTrader_BrendanC  
              Started by raaxus, Today, 11:17 AM
              3 responses
              21 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by login_dejavu, Today, 02:22 AM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X