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 Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            30 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            943 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            5 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Working...
            X