Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator that will plot dots on a chart.

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

    indicator that will plot dots on a chart.





    people with nt,



    i want to know whether it is possible to create an indicator like this below in nt:



    Click image for larger version

Name:	20220111 nt requests 0002.JPG
Views:	1062
Size:	124.8 KB
ID:	1185648



    the logic is very simple and i should be able to code it in ninjascript alright. all this indicator above does is plot a red dot dot above the high if two different moving averages are both decreasing and a blue dot below the low if both averages are increasing.


    this is a very practical format to plot but i'm not aware of nt having any capability that could be used in a similar manner. hopefully it could be possible to adapt this to nt.



    very well, regards.


    #2
    Hello rtwave,

    Thanks for your question.

    Yes, this is possible, and you can create the necessary logic using the Strategy Builder.

    You can create a condition that check if both moving averages are greater than their previous bar (Bars Ago 0 vs. BarsAgo 1) and then you can have an action draw a dot above the High.

    Making Indicator comparisons - https://ninjatrader.com/support/help...plotIndicators

    Drawing on a chart - https://ninjatrader.com/support/help...ToDrawOnAChart

    The same can be done to make another condition that checks if the moving averages are less than the previous bar, and then you can draw a dot below the Low.

    Once generated, you can use the View Code button to see how the Strategy Builder creates the syntax. The code can then be implemented in an indicator.

    Indicator tutorials - https://ninjatrader.com/support/help...indicators.htm

    We look forward to assisting.

    Comment


      #3



      NinjaTrader_Jim, people with nt,




      regards.



      i have been working on this indicator and i could use some help.


      i used the strategy builder to create a very simple indicator, and this is as far as i got:


      Code:
      
      private bool Downtrend;
      private bool Uptrend;
      
      private Brush Brush1;
      private Brush Brush2;
      private EMA EMA1;
      
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"tesampletremsoal.";
      Name = "tesampletremsoal";
      Calculate = Calculate.OnBarClose;
      IsOverlay = true;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = false;
      Emaperiod = 9;
      Downtrend = false;
      Uptrend = false;
      }
      else if (State == State.Configure)
      {
      Brush1 = new SolidColorBrush((Color)ColorConverter.ConvertFromS tring("#FF333333"));
      Brush1.Freeze();
      Brush2 = new SolidColorBrush((Color)ColorConverter.ConvertFromS tring("#FF333333"));
      Brush2.Freeze();
      }
      else if (State == State.DataLoaded)
      {
      EMA1 = EMA(Close, Convert.ToInt32(Emaperiod));
      }
      }
      
      protected override void OnBarUpdate()
      {
      if (CurrentBars[0] < 1)
      return;
      
      // Set 1
      if (EMA1[0] <= EMA1[1])
      {
      Downtrend = true;
      Uptrend = false;
      }
      
      // Set 2
      if (EMA1[0] >= EMA1[1])
      {
      Uptrend= true;
      Downtrend = false;
      }
      
      // Set 3
      if (Downtrend == true)
      {
      Draw.TriangleDown(this, @"tesampletriangles Triangle down_1", true, 0, High[0], Brushes.Red);
      Alert(@"tesampletriangles_1", Priority.Medium, @"down", @"", 0, Brushes.Transparent, Brush1);
      SendMail(@" ", @"down", @"down");
      PlaySound(@"C:\Program Files (x86)\NinjaTrader 8\sounds\Connected.wav");
      }
      
      // Set 4
      if (Uptrend== true)
      {
      Draw.TriangleUp(this, @"tesampletriangles Triangle up_1", true, 0, Low[0], Brushes.Blue);
      Alert(@"tesampletriangles_1", Priority.Medium, @"up", @"", 0, Brushes.Transparent, Brush2);
      SendMail(@" ", @"up", @"up");
      PlaySound(@"C:\Program Files (x86)\NinjaTrader 8\sounds\Connected.wav");
      }
      }
      
      #region Properties
      [NinjaScriptProperty]
      [Range(1, int.MaxValue)]
      [Display(Name="Emaperiod", Description="emaperiod", Order=1, GroupName="Parameters")]
      public int Emaperiod
      { get; set; }
      #endregion

      i have two questions:


      - i am using this structure with boolean variables because this works in the case of a moving average that will change color following these variables. in the case of this format with triangles - dots the indicator will only plot one single down triangle and one up triangle in the entire chart. ¿what logic should i use so that the indicator would draw one single down triangle in every bar where Downtrend becomes true after having been false?


      - and i just began to use alerts, i also want to know the following: in the case o f the triangles, i would want triangles to be drawn anywhere in the chart where the conditions are true, but it would make no sense to open a chart and receive 50 alerts from conditions triggered on historical data. ¿how can i separate the triangles and the other alerts from triggering on historical data or not?




      very well, thanks, regards.

      Comment


        #4
        Hello rtwave,

        Thanks for your question.

        - i am using this structure with boolean variables because this works in the case of a moving average that will change color following these variables. in the case of this format with triangles - dots the indicator will only plot one single down triangle and one up triangle in the entire chart. ¿what logic should i use so that the indicator would draw one single down triangle in every bar where Downtrend becomes true after having been false?
        In order to draw multiple drawing objects, you will need to use unique tags for the drawing object. Using the same tag will update the previous object.

        I.E.

        Draw.TriangleDown(this, @"tesampletriangles Triangle down_1" + CurrentBar, true, 0, High[0], Brushes.Red);

        IF you want to check "Downtrend is true when it was flae on the last bar you could consider a could ways:

        1. track an additional bool "LastDowntrend" and assign that bool with the value from Downtrend, before you check and update Downtrend
        2. track an additional bool "LastDowntrend" that is calculated using the previous bar values as opposed to the current bar values.

        To elaborate on #2, you assign Uptrend and Downtrend based on the current and last EMA1 values. You could make an additional condition that checks BarsAgo 1 and BarsAgo 2 values to set "LastUptrend" and "LastDowntrend"

        Where you check:

        Code:
        if (EMA1[0] <= EMA1[1])
        {
            Downtrend = true;
            Uptrend = false;
        }
        You could also do:

        Code:
        if (EMA1[1] <= EMA1[2])
        {
            LastDowntrend = true;
            LastUptrend = false;
        }
        Keep in mind if you add addition checks for Bars Ago 2 values, you need to make sure the script has first processed 2 bars:

        Code:
        if (CurrentBars[0] < 2)
            return;

        - and i just began to use alerts, i also want to know the following: in the case o f the triangles, i would want triangles to be drawn anywhere in the chart where the conditions are true, but it would make no sense to open a chart and receive 50 alerts from conditions triggered on historical data. ¿how can i separate the triangles and the other alerts from triggering on historical data or not?
        Alerts are not processed with historical data and they will only fire with realtime data. Drawing objects can be made in historical and realtime. If you want to differentiate logic and actions between historical and realtime processing, you could check:

        Code:
        if (State == State.Realtime)
        {
            // Realtime only code here
        }
        Code:
        if (State == State.Historical)
        {
            // Historical only code here.
        }
        Alert() - https://ninjatrader.com/support/help...html?alert.htm

        Comment


          #5




          NinjaTrader_Jim,




          thanks.


          i created a second set of boolean variables that checks for the same downtrend - uptrend conditions but one bar ago and now the triangles are indeed being plotted as intended.



          the only thing i would still improve is the size of the triangles. i would like to make them at least as large as the bar size, or larger.


          Draw.TriangleDown(this, @"tesampletriangles Triangle down_1", true, 0, High[0], Brushes.Red);


          this code above generates smallish triangles that are not easy to detect at a glance. ¿is there any setting to generate much larger triangles?



          and i plan to place the alerts under the same conditions as the triangles. i think i should be able to experiment some and make them work by myself.



          very well, regards.

          Comment


            #6
            Hello rtwave,

            Chart marker sizes cannot be set in NinjaScript, but my colleague, NinjaTrader_Paul, has created a modified ChartMarker that will let you customize the size. His DrawingTool modification can also be used in NinjaScript.

            These are duplicate chart markers to what comes with the platform except you can change the size of them. The existing chart markers will remain as well. This will allow you to create custom sized chart markers that you can create and save as default so that you can draw the markers as needed to [&#8230;]


            The link above is publicly available.

            The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

            Comment


              #7



              NinjaTrader_Jim,




              thanks.



              i have taken a look at the add-on you have shared and it is what i had in mind.


              i think i have made good progress with these indicators i have been working on.


              if something else comes up i will post again.



              thanks, regards.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              648 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              369 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
              573 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              575 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X