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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        33 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        286 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        284 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        133 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        91 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X