• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Color bars

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

    Color bars

    I hope someone can help, I have not had much luck trying to program this.
    1. i use a ema and an xma (they should be adjustable)
    2. xma comes from below the ema and the ema crosses the xma, and the price closes at least one tick above the ema, then paint the bar BLUE
    3. when the ema comes from above the ema and crosses the xma and the price closes at least one tick below the ema..then paint the bar red.

    Hope someone can help..Thanks in advance

    #2
    Hi qkracer,

    Have you tried out our Strategy Wizard? What you are trying to code is possible through the use of the point and click interface of the Strategy Wizard.

    Video Overview of the Strategy Wizard:
    http://www.ninjatrader.com/V6_Videos...egyWizard.html
    http://www.ninjatrader.com/V6_Videos...onBuilder.html

    Tutorials that will help you get what you want for your particular indicator:
    http://www.ninjatrader-support.com/H...ItemValue.html
    http://www.ninjatrader-support.com/H...omparison.html

    There are also NinjaScript consultants you can contact for coding. The list is here: http://www.ninjatrader.com/webnew/pa...injaScript.htm
    JoshNinjaTrader Customer Service

    Comment


      #3
      Color Bars

      Thanks..even with my limited programming, I just might be able to figure this out.

      One question though..once the conidtions are met then I want to change the color or the bar..Not sure how to do that.. If you could guide me one more time... I will have a go at it!! Once again thanks

      Comment


        #4
        Unfortunately you can't explicitly do that in the Strategy Wizard, but you can get everything else accomplished with the wizard. Once you have everything else done you can then press the "Unlock Code" button and then manually type in the necessary lines to change the bar color.

        Code:
        BarColor = Color.Blue;
        Code:
        BarColor = Color.Red;
        You want to type those lines inside the brackets for the corresponding if statements. When you get to this stage and you still need help just copy paste the code here and I can show you the exact location to input those the two lines of code.
        JoshNinjaTrader Customer Service

        Comment


          #5
          color bars

          Guess as simple as it looks I still cant grasp it. I thought I would do something real simple and paint a dot.. still cant get it to work.
          if (CrossAbove(EMA(Median, 4), SMA(Median, 21), 1))
          {
          DrawDot(
          "dot long" + CurrentBar, 0, 0, Color.Blue);
          }
          // Condition set 2
          if (CrossBelow(EMA(Median, 4), SMA(Median, 21), 1))
          {
          DrawDot(
          "My dot" + CurrentBar, 0, 0, Color.Crimson);
          }
          }

          Comment


            #6
            You told it to draw a dot at bar= 0, price=0 .... Your 'y' coordinate is wrong.

            Try "DrawDot("dot long" + CurrentBar, 0, Close[0], Color.Blue);"

            Or if you want to draw a dot just a bit below the bar ...

            "DrawDot("dot long" + CurrentBar, 0, Low[0]-2*TickSize, Color.Blue);"

            Don't include the quotes.

            Comment


              #7
              Thanks for the tip... Gosh I tried to make a simple example just so I could understand how this works..and so far I am having no success. No dots after making the changes that you recommended. My code looks like this now...
              protectedoverridevoid OnBarUpdate()
              {
              // Condition set 1
              if (CrossAbove(EMA(Median, 4), SMA(Median, 21), 1))
              {
              DrawDot(
              "dot long" + CurrentBar, 0, High[0]+2*TickSize, Color.Blue);
              }
              // Condition set 2
              if (CrossBelow(EMA(Median, 4), SMA(Median, 21), 1))
              {
              DrawDot(
              "dot short" + CurrentBar, 0, Low[0]-2*TickSize, Color.Red);
              }
              }

              Comment


                #8
                Try

                protectedoverridevoid OnBarUpdate()
                {
                // Condition set 1
                if (CrossAbove(EMA(Median, 4), SMA(Median, 21), 1
                ))
                {
                DrawDot(CurrentBar.ToString() +
                "dot long" + CurrentBar, 0, High[0]+2
                *TickSize, Color.Blue);
                }
                // Condition set 2
                if (CrossBelow(EMA(Median, 4), SMA(Median, 21), 1
                ))
                {
                DrawDot(CurrentBar.ToString() +
                "dot short" + CurrentBar, 0, Low[0]-2
                *TickSize, Color.Red);
                }
                }
                RayNinjaTrader Customer Service

                Comment


                  #9
                  qkracer: I just tried your code and it works fine just the way you had it.

                  Code:
                  #region Using declarations
                  using System;
                  using System.Diagnostics;
                  using System.Drawing;
                  using System.Drawing.Drawing2D;
                  using System.ComponentModel;
                  using System.Xml.Serialization;
                  using NinjaTrader.Data;
                  using NinjaTrader.Gui.Chart;
                  #endregion
                  
                  // This namespace holds all indicators and is required. Do not change it.
                  namespace NinjaTrader.Indicator
                  {
                      /// <summary>
                      /// xxtest
                      [Description("xxtest")]
                      [Gui.Design.DisplayName("xxtest")]
                      public class xxtest : Indicator
                      {
                          protected override void Initialize()
                          {
                          }
                  
                          protected override void OnBarUpdate()
                          {
                              // Condition set 1
                              if (CrossAbove(EMA(Median, 4), SMA(Median, 21), 1))
                              {
                                  DrawDot("dot long" + CurrentBar, 0, High[0]+2*TickSize, Color.Blue);
                              }
                      
                              // Condition set 2
                              if (CrossBelow(EMA(Median, 4), SMA(Median, 21), 1))
                              {
                                  DrawDot("dot short" + CurrentBar, 0, Low[0]-2*TickSize, Color.Red);
                              }
                          }
                      }
                  }
                  Attached Files

                  Comment


                    #10
                    I suspect maybe you aren't compiling your code qkracer. Hit F5 to compile your indicator.
                    JoshNinjaTrader Customer Service

                    Comment


                      #11
                      Got it working... .Thanks everyone for your help, think i can get what I want from here. Much appreciated

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by chartish, Today, 04:43 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post chartish  
                      Started by Trader17, Today, 04:07 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post Trader17  
                      Started by GussJ, Today, 01:30 PM
                      2 responses
                      18 views
                      0 likes
                      Last Post GussJ
                      by GussJ
                       
                      Started by GARZONJ, Today, 12:25 PM
                      3 responses
                      17 views
                      0 likes
                      Last Post NinjaTrader_PaulH  
                      Started by RandanAL, Today, 11:53 AM
                      1 response
                      13 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X