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 fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,406 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by Shai Samuel, 07-02-2022, 02:46 PM
            4 responses
            98 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by DJ888, Yesterday, 10:57 PM
            0 responses
            8 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            160 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Yesterday, 09:29 PM
            0 responses
            9 views
            0 likes
            Last Post Belfortbucks  
            Working...
            X