Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Issues changing an indicator into an MTF indicator.

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

    Issues changing an indicator into an MTF indicator.

    I have a Support/Resistance indicator that use for MTF purposes. However, to do so, I have to add a higher time frame chart to my trading timeframe chart via Data Series. I add the indicator to the chart, apply to the higher time frame chart, BUT plot it on my trading time frame chart. I'm trying to change the indicator to use multiple time frames. I wrote a new indicator and copied the code over but changed it. I went back through the code and added a AddDataSeries, CurrentBars[1] < BarsRequiredToPlot, and changed everything from CurrentBar to CurrentBars[1], High[0] to Highs[1][0], Close[0] to Closes[1][0], etc. The indicator doesn't plot correctly. I've tried everything I could think of. I can't think of what the problem could be. I've attached 2 pictures. 1 of the two charts with the indicator working fine, and 1 of my trading time frame and the indicator plotting via the 1000 tick. I posted the first few lines from the OnStateChange and On Bar Update. If you would like me to post more of the code, I will. However, it is LONG.

    Click image for larger version

Name:	picture01.png
Views:	326
Size:	103.8 KB
ID:	1184687Click image for larger version

Name:	picture02.png
Views:	318
Size:	77.7 KB
ID:	1184688

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Plots rectangles at support and resistance areas. Can be used on multiple timeframes.";
    Name = "MTFDSRLevelsTick";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = false;
    DrawHorizontalGridLines = false;
    DrawVerticalGridLines = false;
    PaintPriceMarkers = false;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    TickTimeframe = 1000;
    Strength = 5;
    BullishOut = Brushes.Lime;
    BullishBod = Brushes.ForestGreen;
    BearishOut = Brushes.Red;
    BearishBod = Brushes.DarkRed;
    Opacity = 15;
    BehindBars = true;
    BehindBarsAdj = 1;
    }
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Tick, TickTimeframe);
    }
    }

    protected override void OnBarUpdate()
    {
    if(BehindBars == true)
    {
    // Make sure our object plots behind the chart bars
    SetZOrder(-1);
    }
    else if(BehindBars == false)
    {
    SetZOrder(BehindBarsAdj);
    }

    if (CurrentBars[0] < BarsRequiredToPlot || CurrentBars[1] < BarsRequiredToPlot)
    return;
    Attached Files

    #2
    Hello jamestrader21x,

    Thanks for your post.

    I'm not entire sure I understand your approach but let me offer a couple of suggestions.

    If the issue is simply determining the support and resistance on one time frame and then displaying it on another, I would suggest using the Draw.Rectangle() method overload that provides the IsGlobal bool.

    Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)

    You would likely want to create a couple of templates that define the support and resistance colors as needed and then all you would need to do is to use the method call and specify the support or resistance template by name. You would apply the indicator to only one chart (the one you develop the support and resistance from) and the levels would appear on all instrument-related charts.

    If the issue is you are using multiple time frames to determine Support and Resistance levels then you would want to make sure you are doing all of the drawing when the chart bars (BarsInProgress == 0) is true.


    Comment


      #3
      I am using Draw.Rectangle. Did you not look at the pictures I posted? The code works fine if I add a higher time frame chart to my trading time frame chart. Add 2 charts to the "Applied" area. Apply the indicator to the higher time frame using input series in the indicator properties. However, when I re-write the code for multiple time frames, it doesn't plot write. I've changed everything as I've said in my original post. I've even tried BarsInProgress. This is what is in the OnBarUpdate


      protected override void OnBarUpdate()
      {
      if(BehindBars == true)
      {
      // Make sure our object plots behind the chart bars
      SetZOrder(-1);
      }
      else if(BehindBars == false)
      {
      SetZOrder(BehindBarsAdj);
      }

      if (CurrentBars[0] < BarsRequiredToPlot || CurrentBars[1] < BarsRequiredToPlot)
      return;

      if (BarsInProgress == 0)
      {
      DSRTTF();
      DSRHTF();

      }

      /*else if (BarsInProgress == 1)
      {
      DSRHTF();
      }*/

      }

      Comment


        #4
        Hello jamestrader21x,

        Thanks for your reply.

        Yes, I did look at your charts, I know you are using Draw.Rectangle(). My suggestion to you was to use the IsGlobal version of Draw.rectangle() was based on that it appears it works fine on a single timeframe. By creating global rectangles you can avoid the MultiTimeframe coding and apply the indicator to a single chart and be able to see the rectangles on other charts of the same instrument.

        That aside, it Looks like you have DrawOnPricePanel set to false, please change that to true. That property would be used in an indicator panel when you only want to have the draw objects show in the indicator panel and in this case you would want them on the price panel.




        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        560 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        325 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
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X