Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Looking to get an ETH calculated ema to display on RTH dataseries

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

    Looking to get an ETH calculated ema to display on RTH dataseries

    I like to use a 5 minute RTH chart to see gaps more easily.

    I have found that certain emas on the assets I like to trade are more useful calculated with ETH settings than RTH settings.

    If I use ETH dataseries combined with RTH dataseries on the same chart, you get insane "gaps" from left to right due to the timescale getting widened (in addition to making oscillators look wonky as well)

    So I am wondering how I can get price to only display RTH candles (I already have overlays with transparent line on close) and start painting ETH emas from the open.

    My friend who has made all sorts of great indicators came up with the following code.

    Code:
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class ETHEMA : Indicator
    {
    
    private EMA ema;
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "ETHEMA";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    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;
    
    AddPlot(Brushes.Red, "EMA_ETH");
    }
    else if (State == State.Configure) {
    
    AddDataSeries(BarsArray[0].Instrument.FullName, BarsArray[0].BarsPeriod, "CME US Index Futures ETH");
    
    }
    }
    
    protected override void OnBarUpdate()
    {
    if (BarsInProgress==0) {
    Value[0] = EMA(BarsArray[1], 21)[0];
    }
    }
    }
    }
    I will use the hourly as an example (looking to display hourly 21ema for ETH on a 60min RTH dataseries):

    If used on a lone dataseries it properly displays ETH 21 ema even on an RTH dataseries.

    If a single additional 30 minute dataseries is added, it displays slightly worse output relative to what ETH ema should be as well, with 30min candles painted and 1hr hidden (line on close transparent). Look at dec 17th where the red ema gets close to the wick.

    On the 1hr alone it is calculated perfectly with the ema very close about 10 points above the wick.

    With 30min candles it is 80 points above the wick.

    On a 5 minute candle chart it's 150 points above the wick.

    In my third screenshot with 5 minute candles i have my crosshair directly over the wick that should have tested (frontran by about 10 points) the 1hr 21 ETH ema but instead of properly showing it a few points higher it shows it about 150 points higher!





    Last edited by alcorr247; 12-18-2021, 05:38 PM.

    #2
    Hello alcorr247,

    The code does appear mostly correct. Below is a link to an example of this.


    Adding data series to the chart itself would mess with the equidistant bar spacing.

    I'm not sure if I am understanding if this is an issue with the code, or if this is an issue with adding multiple data series to a chart.

    May I have you clarify if the issue exists with no added data series on the chart?
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

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