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 cre8able, Yesterday, 01:16 PM
            3 responses
            11 views
            0 likes
            Last Post cre8able  
            Started by Harry, 05-02-2018, 01:54 PM
            10 responses
            3,203 views
            0 likes
            Last Post tharton3  
            Started by ChartTourist, Today, 08:22 AM
            0 responses
            6 views
            0 likes
            Last Post ChartTourist  
            Started by LiamTwine, Today, 08:10 AM
            0 responses
            2 views
            0 likes
            Last Post LiamTwine  
            Started by Balage0922, Today, 07:38 AM
            0 responses
            5 views
            0 likes
            Last Post Balage0922  
            Working...
            X