Announcement

Collapse
No announcement yet.

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.

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X