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

EnterLongStop(DefaultQuantity, Close[0] + 2 * TickSize, "LongUpBar+2");

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

    EnterLongStop(DefaultQuantity, Close[0] + 2 * TickSize, "LongUpBar+2");

    Hi Cody,

    Hopefully I attached the screen shot properly as a zip file.

    EnterLongStop(DefaultQuantity, Close[0] + 2 * TickSize, "LongUpBar+2");
    I understand that this script above will signal an entry if price exceeds Close[0] by +2, but it will only signal if the +2 occurs during Close[0]. I want to create a script that will signal an entry if price doesn't exceed Close[0] by +2 for several bars (say seven) and then does exceed Close[0] by +2 on the eighth bar. Can you help me? Thank you.
    Attached Files
    Last edited by paunic305; 01-29-2016, 12:04 PM.

    #2
    Hello,
    Unfortunately it does not appear the file came attached.
    Please reattach your image of the illustration to your reply to this post.
    Thank you.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      EnterLongStop(DefaultQuantity, Close[0] + 2 * TickSize, "LongUpBar+2"

      Hi Cody,

      Hopefully I attached the screen shot properly as a zip file.

      EnterLongStop(DefaultQuantity, Close[0] + 2 * TickSize, "LongUpBar+2");
      I understand that this script above will signal an entry if price exceeds Close[0] by +2, but it will only signal if the +2 occurs during Close[0]. I want to create a script that will signal an entry if price doesn't exceed Close[0] by +2 for several bars (say seven) and then does exceed Close[0] by +2 on the eighth bar. Can you help me? Thank you.
      Attached Files

      Comment


        #4
        Hello,
        What you are wanting to do would be possible by creating a double variable to hold Close[0] + 2 and then you could run a for loop and use another variable to hold a count the number of times that the closing prices is greater than the saved double and once the count is equal to 8 to then submit your order.
        For more information on for loops please see the following link: https://ninjatrader.com/support/help...g_commands.htm

        If we can be of any other assistance please let us know.
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          EnterLongStop(DefaultQuantity, Close[0] + 2 * TickSize, "LongUpBar+2"

          Hi Cody,

          I went to the link about loops, and I don't quite understand that yet. I'll keep trying though.
          Meanwhile, any chance you could send me an example of a portion of script that does something very similar to what I'm after? I'm very much a beginner. By the way I could have been clearer in my question. You see I'm not just seeking an entry on a specific bar (bar 8) but on any bar after Close[0] that exceeds Close[0] by +2. I don't know if it helps to show you how I'm thinking of it in my mind, even though it is incorrect. But I'll give it a try:

          BarsSinceClose[0]() == +2
          EnterLong;

          I realize that there is no such statement as BasrSinceClose[0]() == +2. But I gave it a try since I saw an example of BarsSinceEntryExecution().

          Comment


            #6
            Hello,
            I am going to need more clarification on what you are wanting.
            Are you looking for just when the price is exceeded by Close[0] by two ticks to enter or are you looking for a certain number of bars after the Close[0] to submit?
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              EnterLongStop(DefaultQuantity, Close[0] + 2 * TickSize, "LongUpBar+2"

              Hi Cody,

              I'm looking for just when the price is exceeded Close[0] by two ticks to enter. The action that I already have (shown in the title of this post) only enters if the price exceeds Close[0] by two ticks during that same bar of Close[0]. I want an action statement that will enter on any future bar that exceeds Close[0] by two ticks.

              Thank you,
              Paul

              Comment


                #8
                Hello,
                To do this you could create a variable to hold a value of the CurrentBar for Close[0]. Then in addition to your check for entry that the price is Close[0] + 2 ticks you check that the CurrentBar is greater than the saved value for example:

                Code:
                private double ClosePlus2tick = 0;
                private int CloseBar = 0;
                
                protected override void OnBarUpdate()
                {
                    if(/*Condition for when you want to hold Close[0] + 2 ticks*/)
                    {
                	    ClosePlus2tick = Close[0] + 2 *TickSize;
                	    CloseBar = CurrentBar;
                    }
                    if(Close[0] >= ClosePlus2tick && CurrentBar > CloseBar)
                    {
                	    EnterLong();	
                    }
                }
                If we can be of any other assistance please let us know.
                Cody B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Tim-c, Today, 10:58 AM
                0 responses
                1 view
                0 likes
                Last Post Tim-c
                by Tim-c
                 
                Started by traderqz, Yesterday, 09:06 AM
                3 responses
                21 views
                0 likes
                Last Post NinjaTrader_ThomasC  
                Started by f.saeidi, Today, 10:19 AM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by kujista, Today, 06:23 AM
                5 responses
                18 views
                0 likes
                Last Post kujista
                by kujista
                 
                Started by traderqz, Today, 12:06 AM
                3 responses
                6 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X