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

Equivalent of Pyramiding in Ninja Trader 8

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

    Equivalent of Pyramiding in Ninja Trader 8

    Hi,
    In PineScript codes, there is a parameter called "Pyramiding" that limits the max number of trades that are open simultaneously in one direction. (These trades do not necessarily occur in consecutive bars.)

    How to set this parameter in NT8?

    Suppose you are currently in the long position. And 20 bars later, you will receive a long signal again. How to open a new position without closing the previous position?
    In other words, how can you scale-in to your position? (However, this is not done in Trading View and the same direction positions are examined in several separate positions.)

    I don't think the "Entries per direction" parameter in NT8 can solve my problem.
    For example, if the parameter is equal to 2, then when the long signal is issued, the long position opens in 2 consecutive bars.

    Thank you for your help


    #2
    Hi,
    In PineScript codes, there is a parameter called "Pyramiding" that limits the max number of trades that are open simultaneously in one direction. (These trades do not necessarily occur in consecutive bars.)

    How to set this parameter in NT8?

    Suppose you are currently in the long position. And 20 bars later, you will receive a long signal again. How to open a new position without closing the previous position?
    In other words, how can you scale-in to your position? (However, this is not done in Trading View and the same direction positions are examined in several separate positions.)

    I don't think the "Entries per direction" parameter in NT8 can solve my problem.
    For example, if the parameter is equal to 2, then when the long signal is issued, the long position opens in 2 consecutive bars.

    Thank you for your help

    Comment


      #3
      Hello alichi50,

      In NinjaTrader there is EntriesPerDirection and EntryHandling. This controls the number of entries that can be placed into a position, and is based on the position when the entry is called.
      This is not based on the total numbers of orders that can be placed at the same time, but instead, once the position reaches the entries per direction all further entry orders are ignored until the position becomes less than the entries per direction again.

      Below are links to the help guide.



      This is also discussed in the Strategy Builder 301 training video.
      NinjaTrader's Strategy Builder empowers traders of all levels with point-and-click automated trading strategy development. Create your own advanced automated...



      You could achieve this in an unlocked script with custom logic. Just shooting ideas, you could have a List<Order> collection that adds elements during OnOrderUpdate when the order becomes accepted or working, and then removes from the list when the order is filled, cancelled, or rejected. The count of the list would be the number of working orders. You could also just use an integer for a counter that is incremented when an order you have identified as an entry becomes working and decrements when it fills..

      Create a new List, add elements to it, and loop over its elements with for and foreach.



      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hello alichi50,

        I am seeing that you may be creating duplicate posts on the forum. We respectfully ask that you only create one inquiry. Creating multiple forum threads will create two separate tickets and may cause multiple technicians to start at the beginning of reviewing your inquiry, tying up resources with our platform support and delaying our ability to respond to all customers in a timely manner.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you for your guidance

          My strategy does not have SL and TP. And works as a "flip" for longs and shorts.

          When the "EntryLong" function is called. There are three cases :
          1- Do not have an open position and be flat, so you take a long position.
          2- Have a long position. So you take another long position.
          3- Have a short position. First close the short position and then take a long position and actually flip.

          If case 1 or 3 occurs, it will be done. But if case 2 occurs, it will not be done. (This is exactly my problem) (The same is true for short positions in reverse.)

          (I even examined the above three cases in three separate conditions by the "Position.MarketPosition == MarketPosition.Flat(Or Long Or Short)". But again, I did not get a result.)

          And again, my opinion is that the EntriesPerDirection and EntryHandling does not solve the problem.
          There are many cases of long and short positions that are part of case 2 and are ignored ...
          I saw the YouTube video mentioned above.
          I can not use the "Exit" function because it creates 3 positions at flip times. And in fact the results of the strategy will be wrong.

          If the positions of case 2 are not taken, I can not use counting methods to determine their maximum limit.
          There is a variable in TradingView that returns the total size of the working positions. And its name is "Strategy.position_size. For example if Strategy.position_size== -2 then you currently have two short positions. Simply!

          Here is the last part of my code :

          if (Long_Cond)
          EnterLong(1,"Long");
          else if (Short_Cond)
          EnterShort(1,"Short");

          Where Long_Cond and Short_Cond are Boolean.

          I hope I was able to explain my problem. thank you

          Comment


            #6
            Hello alichi50,

            If placing a second order is being ignored with a message in the NinjaScript Output window from TraceOrders as suggested in Post # , this likely means that EntriesPerDirection is not greater than the number of orders you are placing, or the EntryHandling is not set to UniqueEntries. (Note that any changes in State.SetDefaults require removing the instance of the script and adding a new instance)

            If you are not familiar with using TraceOrders and prints to understand behavior, see the post below.


            The managed approach is based on the position. Calling an exit and an entry at the same time will result in the automatic Close position order, exit order submitted by the script, and new entry submitted by the script resulting in 3 orders. This is not related to orders being ignored due to the EntriesPerDirection and EntryHandling.
            See the post below.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Creamers, 04-27-2024, 05:32 AM
            6 responses
            42 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by iceman2018, Today, 11:46 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by Torontobluejays, Yesterday, 08:43 AM
            4 responses
            23 views
            0 likes
            Last Post Torontobluejays  
            Started by Ticks_66, Today, 09:50 AM
            2 responses
            14 views
            0 likes
            Last Post Ticks_66  
            Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
            7 responses
            27 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X