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

Help needed with Swing indicator

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

    Help needed with Swing indicator

    I am using the Swing indicator in my strategy to enter trades when Close crosses a swing. The issue is that when I use a high strength setting such as 50 bars some entrees are made too far away from the swing. How do I prevent this and only have entrees made when Close crosses right next to the Swing?

    #2
    Hello relogical,

    What code are you currently using in the condition?

    If a print is added printing the Swing price, does this reflect the price that you are expecting?

    For example:

    Print(Close[0]: "+Close[0]+" > SwingHigh[0]: "+Swing(5).SwingHigh[0]+" && Close[1]: "+Close[1]+" < SwingHigh[1]: "+Swing(5).SwingHigh[1]);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      The entrees are made correct upon crossover of Swing line. The issue is that if the Swing strength is set to a high number the crossover is made not just where the Swing line ends but also several bars away. I just need to figure out how to make the entrees right at the end of the line.

      Comment


        #4
        Hello relogical,

        So the order is being submitted at the correct time when the cross happens, but the order is not filling right away? Is this the issue?

        In your prints, you are able to confirm that the cross happens at the right time and the order is being submitted, is this correct?

        What type of order are you submitting?

        Are you submitting a limit or stop order at a price that is not the current market price?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The swing indicator when set to a high strength draws a longer swing line than a lower strength setting thus making my strategy enter into several trades on the same swing line even though the crossover is not right at the end of this line visually. In other words there are many crossover entrees made on the same swing line instead of just one.

          Comment


            #6
            Hello relogical,

            Are you only wanting to allow 1 entry in a particular direction?

            Are you wanting to somehow change the data so that there isn't multiple crossovers?

            Are you running this with Calculate on bar close set to True and you are getting multiple trades on the same bar?

            Are the multiple trades on different bars?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              The trades are made on different bars but at the same price point where swing line is. I just want to make one entree per same swing line. My strat makes multiple entrees per direction scaling in.

              Comment


                #8
                Hello relogical,

                In that case, I suggest you use a bool after the first entry that is reset once there is a new swing.

                In #region Variables:
                private bool allowTrades = true;

                In OnBarUpdate:
                if (/* new swing conditions */)
                {
                allowTrades = true;
                }
                if (/* entry conditions */ && allowTrades == true)
                {
                EnterLong();
                allowTrades = false;
                }
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I don't think this will solve it. I need to prevent multiple entrees on the same swing.

                  Comment


                    #10
                    Originally posted by relogical View Post
                    I don't think this will solve it. I need to prevent multiple entrees on the same swing.
                    Huh? That is what the suggested code does, in the first instance. Why do you look at it askance? Just curious.

                    Comment


                      #11
                      Hi relogical,

                      The psuedocode was intended to show how to prevent multiple entries on a swing.

                      Is this not what you are looking for?

                      You may also be able to limit the orders by setting EntriesPerDirection to 1.
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by adeelshahzad, Today, 03:54 AM
                      5 responses
                      32 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by stafe, 04-15-2024, 08:34 PM
                      7 responses
                      32 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by merzo, 06-25-2023, 02:19 AM
                      10 responses
                      823 views
                      1 like
                      Last Post NinjaTrader_ChristopherJ  
                      Started by frankthearm, Today, 09:08 AM
                      5 responses
                      21 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by jeronymite, 04-12-2024, 04:26 PM
                      3 responses
                      43 views
                      0 likes
                      Last Post jeronymite  
                      Working...
                      X