Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Print Daily SMA into 5 minutes chart

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

    Print Daily SMA into 5 minutes chart

    Hi, is it possible to plot a daily or any higher time frame into a smaller time frame within the strategy?

    I tried to plot a Daily SMA into a 5-minute chart and it doesn't work.



    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Day, 1);
    }
    else if (State == State.DataLoaded)
    {

    SMAD = SMA(Closes[1], 20);

    SMAD.Plots[0].Brush = Brushes.Yellow;
    SMAD.Plots[0].Width = 5;
    AddChartIndicator(SMAD);
    }​

    Thank you!



    #2
    Hello xtremel,

    The way you passed the secondary series to the indicator is correct, that will allow the strategy to access those values in its code. AddChartIndicator does not work with indicators that use secondary series so that part can be removed.

    To plot the indicator value the strategy would need to add a plot and then you would need to set the indicator value to the plot.

    Code:
    Value[0] = SMAD[0];

    Comment


      #3
      Hi Jesse,

      I tried the following, and don't see any errors, but I can't see the plot.

      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {

      // Add plots and associated Series<double> objects
      AddPlot(Brushes.Yellow, "SMAD"); // Defines the plot for Values[0]


      }
      else if (State == State.Configure)
      {
      AddDataSeries(Data.BarsPeriodType.Day, 1);
      }
      }

      protected override void OnBarUpdate()
      {


      if (CurrentBars[0] < 72
      || CurrentBars[1] < 72)
      return;
      // Variable Higher Time Frames
      Values[0][0] = SMAD[0]; // "SMAD"
      }​
      Last edited by xtremel; 11-04-2022, 09:48 AM.

      Comment


        #4
        Hello xtremel,

        You likely don't have enough data loaded. You are checking for 72 days of data:


        if (CurrentBars[0] < 72
        || CurrentBars[1] < 72)

        Try and use:

        if (CurrentBars[1] < 1)​​

        Comment


          #5
          Thank you! that fixed the problem

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          88 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          134 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          68 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          119 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          67 views
          0 likes
          Last Post PaulMohn  
          Working...
          X