Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

can't run this Simple code-2

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

    can't run this Simple code-2

    Can anyone figureout why this code doesn't run correctly? Only the vertical line and horizontal line from the high of the bar shows on the charts.The horizontal line from the low doesn't show up!!!
    Also How can I replace the horizotal line with a horizontal ray?

    // Condition set 1
    if (ToTime(Time[0]) == ToTime(10, 16, 0))
    {
    DrawHorizontalLine(
    "My horizontal line" + CurrentBar, Low[0], Color.Coral);
    DrawVerticalLine(
    "My vertical line" + CurrentBar, 0, Color.Blue);
    DrawHorizontalLine(
    "My horizontal line" + CurrentBar, High[0], Color.Fuchsia);

    #2
    Hi yellowTrader, you will need a unique tag for every object, try "MyHorizontalLine2" + CurrentBar for the second one...

    The syntax to draw a ray can be found here - http://www.ninjatrader-support.com/H...6/DrawRay.html

    Comment


      #3
      Hello Gertrand, I started a new code via the wizard and unlocked it to make the corrections as you explained but this time none of the three lines show up on my charts. Also why is there a "9" in the time value section? Does that represent seconds? this wasn't the case with the other code I generated before.
      By the way how can I include seconds in time values? apparently the wizard doesn't allow me to do so.

      // Condition set 1
      if (ToTime(Time[0]) == ToTime(11, 15, 9))
      {
      DrawHorizontalLine(
      "My horizontal line" + CurrentBar, High[0], Color.Blue);
      DrawHorizontalLine(
      "My horizontal line 2" + CurrentBar, Low[0], Color.OrangeRed);
      DrawVerticalLine(
      "My vertical line" + CurrentBar, 0, Color.SpringGreen);
      }

      Comment


        #4
        Sorry I misspelled your name.

        Comment


          #5
          No problem, please try the attached code, works for me on ES 1min for example. Correct, to enter seconds you need to go into the NinjaScript editor.
          Attached Files

          Comment


            #6
            What exactly do I do with this file? Sorry I a new to Ninja and all this stuff sounds chinese to me. Am I suppose to copy/paste the file inside strategy folder that you sent me into some other folder? and where exactly?

            Comment


              #7
              Hi yellowTrader, please download it to your desktop and import it via File > Utilities > Import NinjaScript into your NinjaTrader platform. The strategy will then show up under the 'linesExample' name in your Strategies list. Apply it to the chart and you should see the 3 lines print.

              Comment


                #8
                Thanks Bertrand. It worked perfectly. But I need to know what was wrong with my codes so I can manage in the future.
                One of the issues I don't understand is that why whenever I try to create a strategy via the wizard the last didit of my time value is a "9" ? this is happening on every single strategy I attempt to make. But it wasn't like that before. Any Ideas?
                Also Since I need the lines to be calculated real time (not at bars close) I unchecked that option via the wizard and Also added another action which is to beep exactly at the start of the minute bar desired. But it keeps beeping throughout that entire minute. How can that be stopped? I just need it to beep once on the first second of that minute.
                Another question I have is how can I arm these lines so that when crossed an order is activated?

                Comment


                  #9
                  Hi yellowTrader, great! In the first code you posted you reused a drawing tag id, which resulted in you getting only 2 lines to display. In th next code your time setup was off, so this condition never became true. I'm not sure where the '9' came from, just make sure you clear the entries in the Wizard time statement and enter it fresh with your needed values.

                  If you select to update this on every tick the alert will also fire during the minute, to change this you would need to move in to custom programming with the NinjaScript editor.

                  Directly 'arming' these lines in unfortunately not possible, but you can program an automated strategy to enter orders at prices you manually put in, please see this link for an overveiw how to get started in strategies - http://www.ninjatrader-support.com/H...verview39.html

                  Comment


                    #10
                    Hi Bertrand, I don't see any difference between the time setups of the first code i sent you and the second code except that the second one contains a "9" which brings me to the problem I have at the moment and I think maybe my Ninja has a bug.
                    I restarted ninja and launched the wizard to create a new strategy and when I got to "Conditions and Actions" page I clicked the "Add" button in the condition window , when condition builder came up I clicked once on"Time Series" on the left panel then clicked on "Time value" on the right panel (which sets the value equal to the current time )and then I clicked "ok" and what is generated in the condition window is :
                    " ToTime(Time[0])==ToTime(13,44,9) " when 13:44 is the current time.
                    Now where is this "9" coming from? Also my code doesn't work when I try to run it which I think is the same reason the second code I sent you didn't run either.
                    Thank you for your help.

                    Comment


                      #11
                      yellowTrader,

                      To remove the 9 just go back to the Condition Builder and retype out the whole time parameter. Then it should clear that out. Seconds are not supported in the Strategy Wizard.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        I forgot to send you the simple startegy I created which doesn't work.

                        // Condition set 1
                        if (ToTime(Time[0]) == ToTime(13, 44, 9))
                        {
                        DrawVerticalLine(
                        "My vertical line" + CurrentBar, 0, Color.Blue);
                        }

                        Comment


                          #13
                          Please clear out the 9 as described earlier.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Ok I tried retyping it and it worked . I got rid of the "9" but do I retype everytime I creat a strategy? Do I need to uninstall and reinstall Ninja?

                            Comment


                              #15
                              No. It will stay the same now. It was probably introduced when you were trying to add seconds which is not supported.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              656 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              371 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              579 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X