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

accessing different MAs

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

    accessing different MAs

    Hi,

    I would like to know how I can determine in a strategy program what the colors are for 3 different moving averages. I created 3 separate MAs on a chart and am writing a strategy, part of which is to determine the colors of these 3 MAs. Is this possible to do? Can someone recommend the best direction to take. I've done some ninja scripting but I'm a novice to scripting with C#. However, any advice would be appreciated.
    Thanks
    Spartacus

    #2
    Hi Spartacus, for this you would need to check for the conditions that lead to the plot coloring - you can directly access the MA values by calling their method in your strategy code compared to the SMA or other indicator methods for example.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thanks for the response.

      Below is the simple moving average script.

      Can you give me an example below, with a snippet of inserted code, how I can reference the Color offset into Plot after declaring the plot of the moving average?

      I'm having difficulty knowing how to access it to test its color attribute.

      Thanks
      Spartacus

      protectedoverridevoid Initialize()
      {
      Add(
      new Plot(Color.FromKnownColor(KnownColor.Orange),PlotS tyle.Line, "Plot1"));
      }

      protectedoverridevoid OnBarUpdate()
      {
      double sum = 0;
      // Do not calculate if we don't have enough bars
      if (CurrentBar < Period) return;
      for (int barsAgo = 0; barsAgo < Period; barsAgo++)
      {
      sum = sum + Input[barsAgo];
      }
      Plot0.Set(sum / Period);
      }

      Comment


        #4
        Hi Spartacus, I'm sorry I'm not following what you seek here, the average script you posted does not set any specific colors, it only uses one plot with the default orange color here.

        If you want to code a strategy for an indicator that change colors according to inbuild rules you would need to recreate those rules in your strategy script, for example if you color bars blue on a rising 14 period SMA, then check in the strategy for the rising condition to then enter a trade, move a stop etc.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NinjaTrader_ChelseaB, 03-14-2017, 10:17 AM
        227 responses
        34,317 views
        7 likes
        Last Post rare312
        by rare312
         
        Started by f.saeidi, Today, 12:11 AM
        0 responses
        5 views
        0 likes
        Last Post f.saeidi  
        Started by Graci117, Yesterday, 11:40 PM
        0 responses
        6 views
        0 likes
        Last Post Graci117  
        Started by BIOK.NT, Yesterday, 01:56 PM
        2 responses
        11 views
        0 likes
        Last Post BIOK.NT
        by BIOK.NT
         
        Started by i2ogu3, Yesterday, 11:31 PM
        0 responses
        6 views
        0 likes
        Last Post i2ogu3
        by i2ogu3
         
        Working...
        X