• 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

Mutiple entries not working in strategy develpment

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

    Mutiple entries not working in strategy develpment

    Hi all,

    I am trying to create a strategy using the ATR Trailing indicator found here https://ninjatraderecosystem.com/use...d/atrtrailing/

    my code is as follows

    ---------------------

    protected override void OnBarUpdate()
    {


    if (CurrentBar < ATRPeriod) return;

    if (( IsFlat || IsLong ) && ( Low[0] > _atrTrail.Lower[0] ) && _atrTrail.Upper[0] != 0)
    {
    this.EnterShortStopMarket(lots, _atrTrail.Upper[0], "Short 1");
    this.EnterShortStopMarket(lots, _atrTrail.Upper[0], "Short 2");
    }

    if ( (IsFlat || IsShort) && (High[0] < _atrTrail.Lower[0] ) && _atrTrail.Lower[0] != 0 )
    {

    EnterLongStopMarket(lots, _atrTrail.Lower[0], "Long 1");
    EnterLongStopMarket(lots, _atrTrail.Lower[0], "Long 2");
    }
    }

    ------------------------

    For some reason the 2nd order is only submitted in short direction and only once
    All orders thereafter are only Long 1 and Short 1

    I have
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.UniqueEntries;

    The idea is to use some form of profit target for one order and use a protective trailing stop for the 2nd one

    Any help is greatly appreciated.


    Ioannis


    #2
    Hello Ioannis,

    With UniqueEntries I would expect both orders (also this only prevents a new order after the position is taken).

    May I test the script?

    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


      #3
      Hello Chelsea,

      Find below the strategy code as an attachment.

      The idea behind having two entries is to have a profit target for one and let the other run - hence the ATRTarget1 variable..

      Of course I have not been able to implement the idea as only one entry was executed.

      Rgrds

      Ioannis

      Attached Files

      Comment


        #4
        Any updates on the support side on why the platform is not working as it should? Still waiting for an answer !

        Comment


          #5
          Hello Ioannis,

          I'm still looking into this and I've forwarded an inquiry to our development as I'm not seeing the order is ignored from TraceOrders, nor do I see the order initialized in OnOrderUpdate().

          I will keep you in on the loop once I have more information.

          I appreciate your patience.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hello,

            more than 20 days have passed, since the last message from support. Do we have an update? I suppose it is a programming issue with the platform?

            Comment


              #7
              Hello Ioannis,

              This is still being discussed between our support and our development to determine if the behavior is expected due to the internal order handling rules.

              "Methods that generate orders to enter a position will be ignored if: A position is open and an order submitted by a non market order exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction."

              I apologize for the amount of time it is taking to resolve this inquiry and I really do appreciate your patience.
              Last edited by NinjaTrader_ChelseaB; 09-11-2019, 09:14 AM.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hello Chelsea,

                assuming it is an "expected behavior" what would be the way around the problem?

                There surely must be a way to code this simple strategy .

                Regards

                Ioannis

                Comment


                  #9
                  Hello Ioannis,

                  If it does turn out to be expected, you may need to wait until the first working order fills before placing the second.

                  Or use the unmanaged approach.

                  Once I have more information I will let you know.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by yikccv, Today, 08:49 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post yikccv
                  by yikccv
                   
                  Started by supernova0219, Today, 07:48 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post supernova0219  
                  Started by qwfxny, Today, 07:20 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post qwfxny
                  by qwfxny
                   
                  Started by bouncetherubble, Today, 04:48 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post bouncetherubble  
                  Started by johnnybegoode, Today, 11:35 AM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_ChrisL  
                  Working...
                  X