Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cannot get a horizontal line to draw when backtesting

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

    Cannot get a horizontal line to draw when backtesting

    Hi there,

    Forgive me if this has been asked ad-nauseam in previous posts, but I couldn't find the answer.

    I'm trying to get a horizontal line drawn whenever the price of a security goes above the high of any of the last 30 candlesticks for a single security. The horizontal line would equal the current bar close.

    Here's what I'm currently trying with the Strategy Tool:

    User Defined Inputs: (None)

    Conditions and Actions - Set 1:
    When the following conditions are true:
    High[0] > High[30]

    Do the following:
    DrawHorizontalLine("high" + CurrentBar, High[30], Color.Green)

    I've also tried using "HighestBar" and "Close" up above, but nothing is showing up.
    Note that I'm testing one trading day for a security.

    Please help when you have a moment. I know I'm doing some rather dim.

    Yours,
    Spider

    #2
    Spiderbird,

    High[0] > High[30]

    This line here will only compare the current high to the high 30 bars ago.

    You would want to use MAX(High,30)[0] instead.

    MAX is an indicator in the indicators list.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi Adam P!

      Thanks for the reply. Unfortunately it's not working quite right. I'm getting a line that pervades throughout each bar, and I'm looking for a horizontal line at the highest point of a 30 bar period.

      The first image is what I'm looking at in the condition builder:


      The second image is what I'm viewing after submitting the previous screen to the strategy analyzer:


      This third image is what I'm viewing in a NinjaTrader Chart (the line through all securities that MAX is creating):


      This fourth image is what I'm after:


      I've also attached them to this e-mail if the above URL's don't work.
      Please let me know if you have any questions or suggestions!

      Yours,
      Spider
      Attached Files
      Last edited by Spiderbird; 04-09-2012, 10:35 PM.

      Comment


        #4
        SpiderBird,

        Please find an image along with explanation.
        Attached Files
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Hi Adam,

          Fantastic! That's for pointing that out to me. After using both MAX and MIN (for the low points of a candlestick chart), I realized my original formula was inaccurate. Meaning, you can't have a greater HIGH amount if you're comparing it against MAX in any time frame. It works if you use a "==" conditional, but the MAX line was what I was looking for to begin with. Thanks all the same!

          Btw, if I wanted to understand the parameters for the different choices in the Condition Builder, is that covered in NinjaTrader's Help files (online and with the local installation)?

          Yours,
          Spider

          Comment


            #6
            Hello Spider,
            Thanks for writing in and I am replying for Adam.

            To know more about the strategy wizard please refer to the help files here http://www.ninjatrader.com/support/h...egy_wizard.htm

            You can also take some time to watch this YouTube video tutorial http://www.youtube.com/watch?v=fVFqw...G0IuPM3sjVBRyC

            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Hi JoyDeep,

              I actually do have a follow-up question. I've attached the following image as a visual, because it seemed to help last time.

              Basically, I'm aiming to:

              1. Check the maximum high of the last 5 bars on a chart, EXCLUDING the current bar.
              2. When the current bars' price action goes above the highest point of the last 5 bars, I'll have NinjaTrader color the background green.

              With the way it's structured right now (after Adam's help), it doesn't seem to work. What should I change in the Condition Builder to satisfy the above?

              Thanks in advance,
              Spider
              Attached Files
              Last edited by Spiderbird; 04-19-2012, 11:30 PM. Reason: Forgot to add the image!

              Comment


                #8
                Hello Spiderbird,
                Unfortunately you cannot do it via the Strategy Wizard. However you can code it via unlocking the code and edit the code in the NinjaScript editor.

                Please let me know if I can assist you any further.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  Hi JoyDeep,

                  I actually figured it out within the condition builder. It was a matter of comparing the highs of the 5 previous bars against the current one using multiple "High[#]" commands. It looks something like this:

                  High[0]<High[1]
                  High[0]<High[2]
                  .....
                  High[0]<High[5]

                  Then it executes the condition and colors the background the appropriate color.

                  Thanks for the help all the same.

                  - Spider
                  Last edited by Spiderbird; 04-22-2012, 09:31 AM. Reason: Modified text

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RookieTrader, Today, 09:37 AM
                  3 responses
                  14 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by kulwinder73, Today, 10:31 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post kulwinder73  
                  Started by terofs, Yesterday, 04:18 PM
                  1 response
                  23 views
                  0 likes
                  Last Post terofs
                  by terofs
                   
                  Started by CommonWhale, Today, 09:55 AM
                  1 response
                  3 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Started by Gerik, Today, 09:40 AM
                  2 responses
                  7 views
                  0 likes
                  Last Post Gerik
                  by Gerik
                   
                  Working...
                  X