Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

can't run this Simple code-2

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

    #31
    Don't create this as a strategy. Create it as an indicator then.
    Josh P.NinjaTrader Customer Service

    Comment


      #32
      How do you mean? It's not just one line there are maybe 20 or 30 throughout the day. Can that be done?

      Comment


        #33
        Yes, create it as an indicator. Indicators can use all the same code as a strategy, just without the strategy specific things like placing orders.
        Josh P.NinjaTrader Customer Service

        Comment


          #34
          I just tried to create an indicator via the wizard but I saw limited options. No drawing tools , no open , high , lows of current bar and so on....
          How is this done? Can you send me a link if there are such options available?

          Comment


            #35
            You cannot create these from wizards. What you are trying to do requires programming. Just bring the lines of code from the strategy over into your indicator. What is inside the OnBarUpdate() methods are what pertains to you.
            Josh P.NinjaTrader Customer Service

            Comment


              #36
              ok i just managed to create an indicator via the wizard then copy/pasted the contents of one of my strategies which pertained to OnBarUpdate() section and saved it. Now when I go to run the indicator off of a chart I don't see that indicator on the list. How can I run it to see if it works?

              Comment


                #37
                You need to press F5 to compile your script. You will also need to ensure you have this line at the top of your OnBarUpdate()

                Code:
                if (CurrentBar < 1)
                     return;
                The 1 needs to be increased to match whatever data requirement you have coded. Please see this tip for more information: http://www.ninjatrader-support2.com/...ead.php?t=3170
                Josh P.NinjaTrader Customer Service

                Comment


                  #38
                  Ok. I made a few indicators for those lines and they seem to work just fine. I think they work better than strategies. Thanks for the suggestion Josh.
                  Here is another question :
                  How can I have the value of each line show up on the price Axis. or show up some where. Cause for example if a line is drawn from yesterday/yesterday data , I won't be able to distinguish where it is being drawn from unless I scroll back in time which takes a lot of time.
                  Is there a better way?

                  Comment


                    #39
                    Use the Plot instead of the draw line. That is the only way to get price markers.

                    I highly recommend you take a look at all of the custom indicator tutorials available here first: http://www.ninjatrader-support.com/H...tml?Overview23
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #40
                      1-When I place my cursor below the current price on a chart and right click , a window opens up which gives me the option of placing Buy orders or Sell Stop orders but when I click on them nothing shows up on my chart i.e. no order is generated? (I have activated the chart trader if that makes any difference).
                      2-How can I change the color of a line or arrow drawn on a chart ?

                      Comment


                        #41
                        1. Does the order appears in the orders tab? If so, repair the installation:

                        Please try repairing your NinjaTrader Installation:
                        1. Shut Down NinjaTrader
                        2. Go to Uninstall Programs in the Windows Control Panel
                        3. Select NinjaTrader and hit the "repair" or "change" button and follow the instructions to repair the installation.

                        2. Double click on the object to bring up its properties.

                        If it is not too much of a hassle for you, please post charting questions in a new thread in the Charting section of the forums.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #42
                          Sorry. I will post it in a charting section next time.
                          Can you tell me if I am going to be loosing my indicators and strategies when reinstalling?

                          Comment


                            #43
                            You will not lose those items.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #44
                              Hello, I have created a simple indicator which in reality serves as a template for tick charts or second charts. It basically draws verical lines for each one minute period. Part of the code is shown below and as you can see the way it is coded is quite a long code for one day worth of vertical lines at each minute period.I have two questions :
                              1- Is there an easier way to construct this code which will enable the code to execute more efficiently?
                              2-Why is it that some lines don't show up on the chart? (There are almost 400 lines for this indicator but this problem happens with as few as 60 lines).

                              protectedoverridevoid OnBarUpdate()
                              {
                              if (ToTime(Time[0]) == ToTime(9, 31, 0))
                              {
                              DrawVerticalLine(
                              "My vertical line" + CurrentBar, 0, Color.Silver, DashStyle.Dot, 1);
                              }
                              if (ToTime(Time[0]) == ToTime(9, 32, 0))
                              {
                              DrawVerticalLine(
                              "My vertical line" + CurrentBar, 0, Color.Silver, DashStyle.Dot, 1);
                              }
                              if (ToTime(Time[0]) == ToTime(9, 33, 0))
                              {
                              DrawVerticalLine(
                              "My vertical line" + CurrentBar, 0, Color.Silver, DashStyle.Dot, 1);
                              }

                              Also this code is to serve as a template , How can I designate a specific date to the code so that the lines are drawn for a particular day not for all days visible in the chart?
                              Obviously it wouldn't be practical to insert a "if condition" for each of these lines evertime I want to use it for a different date, therefore how can the codes above be written so that they would have the same result as the code below?

                              if (ToDay(Time[0]) == ToDay(2009, 1, 20)
                              && ToTime(Time[
                              0]) == ToTime(9, 31, 0))

                              Comment


                                #45
                                1. Use a loop.
                                2. You will need to debug it. Likely you are using the same signal name for your line and thus it is modifying the previous line instead of adding a new one. This can happen very easily with your code if within one bar you have two minutes.
                                3. Just encompass the whole code with a large if-statement for the ToDay check.
                                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
                                635 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                364 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                106 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                567 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                571 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X