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

Custom Plot Colours for SMA

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

    Custom Plot Colours for SMA

    Hello,

    Could anyone refer me to a tutorial for a custom plot colour simple moving average, with the following conditions:

    if sma[0] > close[0] then plot green

    if sma[0] < close[0] then plot red

    Many thanks,

    #2
    Welcome to our forums - you can modify the conditions used to color the SMA in this reference sample we have - http://www.ninjatrader-support2.com/...ead.php?t=3227
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Custom Plot Color

      This Custom Plot was applied to a SMA. Can it be possible to use a Linear Regression line instead.

      Comment


        #4
        You can replace it with any indicator you want. The sample only shows you the framework you can employ to achieve what you want.

        Thing to note about Linear Regression is that it can look different on every single bar so you will need to specify in your code exactly what you want in terms of values for it.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Custom Plot Color

          Thanks for your reply. The Linear regression line referred to is a Ninja installed indicator called LinReg. My knowledge of how to do this is quite limited. Could you refer me to instructions for this purpose

          Comment


            #6
            Jaylock, you would need to make a copy of the download SampleMultiColoredPlot indicator using the SMA per default.

            The modify the calls it's using (SMA) to use the LinearRegression, so to start with a snippet right into the code you would need to use -

            Code:
             
            // Plot green if the LinearRegression is rising
            // Rising() returns true when the current value is greater than the value of the previous bar.
            if (Rising(LinReg(Period)))
            {
            // Connects the rising plot segment with the other plots
            RisingPlot.Set(1, LinReg(Period)[1]);
             
            // Adds the new rising plot line segment to the line
            RisingPlot.Set(LinReg(Period)[0]);
            }
            Proceed for the other scenarios (Falling and Flat) and you should be there.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by r68cervera, Today, 05:29 AM
            0 responses
            2 views
            0 likes
            Last Post r68cervera  
            Started by geddyisodin, Today, 05:20 AM
            0 responses
            3 views
            0 likes
            Last Post geddyisodin  
            Started by JonesJoker, 04-22-2024, 12:23 PM
            6 responses
            33 views
            0 likes
            Last Post JonesJoker  
            Started by GussJ, 03-04-2020, 03:11 PM
            12 responses
            3,239 views
            0 likes
            Last Post Leafcutter  
            Started by AveryFlynn, Today, 04:57 AM
            0 responses
            6 views
            0 likes
            Last Post AveryFlynn  
            Working...
            X