Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Sma that changes color with trend

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

    Sma that changes color with trend

    how to change plot color of sma in NinjaTrader8 ?
    I would like to look back a certain number of bars, not 1 bar like the IsRising code

    eg:
    if (SMA(Period)[0] > SMA(Period)[10])
    PlotBrushes[0][0] = PlotBrushes.Green

    I have no problem writing an indicator using the IsRising code but that only looks back one bar, and is pretty useless for showing trends.

    It seems very difficult to change plot colors.
    Any help would be greatly appreciated

    Thanks
    EsTraderPete

    #2
    Hello EsTraderPete,

    Thanks for writing in.

    You may utilize the ChartIndicators collection to change the color of an indicator's plot.

    Code:
    AddChartIndicator(EMA(Fast));
    AddChartIndicator(EMA(Slow));
    
    ChartIndicators[0].Plots[0].Brush = Brushes.Black;
    ChartIndicators[1].Plots[0].Brush = Brushes.Blue;


    We also have a sample on multi colored plots that may be of use to you. I will link it below:


    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for replying.
      That example will plot two different emas. What I am trying to do is change the color of one ma.
      As in the IsRising example in the help guide but instead of just looking back one bar as IsRising does, I want to look back 10 or more.

      Comment


        #4
        Originally posted by EsTraderPete View Post
        Thanks for replying.
        That example will plot two different emas. What I am trying to do is change the color of one ma.
        As in the IsRising example in the help guide but instead of just looking back one bar as IsRising does, I want to look back 10 or more.
        Your syntax is defective.
        Code:
        if (SMA(Period)[0] > SMA(Period)[10])
        {
            // PlotBrushes[0][0] = PlotBrushes.Green - [COLOR="Red"][B]this is wrong[/B][/COLOR]
            PlotBrushes[0][0] = Brushes.Green
        }

        Comment


          #5
          Hello EsTraderPete,

          Thanks for writing back to this thread.

          It looks like koganam has given you a direct example that you could also use.

          If you have any other questions, please don't hesitate to ask.
          JimNinjaTrader Customer Service

          Comment


            #6
            Thank you very much for your help. My syntax was the problem. The example from koganam fixed the problem.

            Much appreciated
            EsTraderPete

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,789 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            837 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,293 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            13 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            63 views
            0 likes
            Last Post halgo_boulder  
            Working...
            X