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 Skifree, Today, 03:41 AM
            3 responses
            12 views
            0 likes
            Last Post Skifree
            by Skifree
             
            Started by traderqz, Yesterday, 09:06 AM
            5 responses
            32 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by guillembm, Today, 11:25 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by owensd, 04-21-2024, 11:34 PM
            9 responses
            34 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by trilliantrader, 04-10-2024, 09:33 PM
            7 responses
            25 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X