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.
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];
}
}
}
}
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!

Comment