Custom Resolution Plugin using ATR
Posted: Jun 15 2024
Hi,
I'm a seasoned quant-trader and have quite some programming skills. However, I'm a newbie to the MC platform and, admittedly, my C# skills need a refresh. I very much like the MC-approach and especially the fact, that custom resolutions can be programmed. The issue I have, however, is that it's hard to find documentation about existing MC-libraries (maybe I just looked in the wrong places - any ideas/suggestions?).
Within my Custom Resolution Plugin I'm looking to calculate either a) the ATR over the last X bars or b) the ATR over all bars since midnight (yes, intraday chart with typically 1m resolution).
Starting from a 'Regular plugin sample', my OnData method would contain something like this:
public void OnData(ICustomBar Bar, Int64 time_in_ticks, Int32 tickId, double open, double high, double low, double close, long volumeAdded, long upVolumeAdded, long downVolumeAdded, ECustomBarTrendType trend, bool isBarClose)
{
m_Volume += volumeAdded;
m_UpVolume += upVolumeAdded;
m_DownVolume += downVolumeAdded;
if (time = midnight)
{
myATR = ATR(all bars since last midnight)
}
Bar.UpdateBar(time_in_ticks, tickId, open, high, low, close, m_Volume, m_UpVolume, m_DownVolume, trend, true, false);
if (isBarClose)
{
Bar.CloseBar();
m_Volume = 0;
m_UpVolume = 0;
m_DownVolume = 0;
}
}
How can i get the ATR-calculation done? Thanks for hints/suggestions!
I'm a seasoned quant-trader and have quite some programming skills. However, I'm a newbie to the MC platform and, admittedly, my C# skills need a refresh. I very much like the MC-approach and especially the fact, that custom resolutions can be programmed. The issue I have, however, is that it's hard to find documentation about existing MC-libraries (maybe I just looked in the wrong places - any ideas/suggestions?).
Within my Custom Resolution Plugin I'm looking to calculate either a) the ATR over the last X bars or b) the ATR over all bars since midnight (yes, intraday chart with typically 1m resolution).
Starting from a 'Regular plugin sample', my OnData method would contain something like this:
public void OnData(ICustomBar Bar, Int64 time_in_ticks, Int32 tickId, double open, double high, double low, double close, long volumeAdded, long upVolumeAdded, long downVolumeAdded, ECustomBarTrendType trend, bool isBarClose)
{
m_Volume += volumeAdded;
m_UpVolume += upVolumeAdded;
m_DownVolume += downVolumeAdded;
if (time = midnight)
{
myATR = ATR(all bars since last midnight)
}
Bar.UpdateBar(time_in_ticks, tickId, open, high, low, close, m_Volume, m_UpVolume, m_DownVolume, trend, true, false);
if (isBarClose)
{
Bar.CloseBar();
m_Volume = 0;
m_UpVolume = 0;
m_DownVolume = 0;
}
}
How can i get the ATR-calculation done? Thanks for hints/suggestions!