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

Market Analyzer Trend Column

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

    Market Analyzer Trend Column

    I have a 50 SMA column on my market analyzer. How would I go about coloring this if it has increased/decreased from the last bar?

    I've done it in all my other platforms but am finding it quite a bit more difficult in ninjatrader (I'm sure lack of experience on my part).

    Thank you

    #2
    Hello UncleRyan,

    Welcome to the NinjaTrader support forums.

    In this situation the requirement to check if its changed from the previous value requires being able to look at the previous value. This is a good situation to make a simple wrapper indicator to be used in the analyzer. This will also prevent the actual SMA value from being reported in that cell but would allow you to use this indicator for cell coloring or row filtering.

    The market analyzer specifically wants very simple conditions for its cell conditions. Something that works good for that is using 1, -1 or 0 to denote three states.

    To do this you can use the following steps:
    1. Open the NinjaScript editor and right click on the indicator folder -> new indicator
    2. Click next and give it a unique name
    3. Go to the Plots and lines page
    4. Click Add and create a new plot, you can name it anything like SignalPlot
    5. Click Generate

    This creates the basic structure you need, the condition you want to check could be accomplished like this:


    Code:
     protected override void OnBarUpdate()
            {
                Value[0] = 0; //set a default for every bar
                if(CurrentBar < 1) return; // set the 1 to whatever the max bars ago used was
    
                if(SMA(12)[0] > SMA(12)[1])
                {
                    Value[0] = 1; // increased, set to 1
                } 
                else if(SMA(12)[0] < SMA(12)[1])
                {
                    Value[0] = -1; // decreased, set to -1
                }
            }
    Now in the analyzer you can use this script instead of the SMA, for its cell conditions you can check if the value is 0 for neutral or 1/-1 for positive/negative to have 3 states.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by llanqui, Today, 11:10 AM
      0 responses
      4 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by llanqui, Today, 10:29 AM
      0 responses
      5 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by llanqui, Today, 08:32 AM
      1 response
      11 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by lollers, Yesterday, 03:26 AM
      1 response
      53 views
      0 likes
      Last Post lollers
      by lollers
       
      Started by Salahinho99, 05-05-2024, 04:13 AM
      7 responses
      63 views
      0 likes
      Last Post Salahinho99  
      Working...
      X