Custom Resolution Plugin using ATR

Questions about MultiCharts .NET and user contributed studies.
MrZ
Posts: 2
Joined: Jun 14 2024

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!

HellGhostEvocatorX
Posts: 143
Joined: Feb 10 2022
Has thanked: 68 times
Been thanked: 23 times

Jun 20 2024

Hello.
Please use the "Full Editor" to better display your code here in the forum.

If you just want to know how to calculate the atr, you can simply use the function already integrated in Multicharts.net, which you can also view in the Powerlanguage Editor. If you need a code example to use, you can take a look at the ready-made indicator "Average_True_Range". I also think that someone here in the "user-contributed studies" here in the forum posted a slightly different calculation of the ATR.

If you have general questions, take a look here in the forum under: "Frequently asked questions about MultiCharts .NET" or "MultiCharts .NET tutorials". There is a lot of useful information there. Alternatively, chatgpt is now also relatively compatible with multicharts,net if you first post an empty indicator template and then ask the relevant programming questions.
If you want to see how individual functions are structured, you can largely view them via Visualstudio by right-clicking on the method and definition.

If you only want to calculate the atr from midnight, you have to remember that the atr always needs a few candles to advance (standard is usually 14) and is only then displayed. For example, you could query midnight with Bars.Time[0] ==. or look at the example indicators like First_Bar_of_Day

Since they only posted one method, I'm not sure if you even know how to program indicators in Multicharts, but there is a corresponding PDF for that, or the Multicharts wiki.

If you would like an overview, the powerlanguage editor under help--> Powerlanguage.net help might be what you are looking for.

MrZ
Posts: 2
Joined: Jun 14 2024

Jun 25 2024

Thank you HellGhostEvocatorX, much appreciated!

You gave me some good inputs and I was walking through a couple of resources. But yet, I'm struggling with some of the basics. On my way to code my own stuff I have some hurdles to overcome like:

1) Power Language .NET Editor: several references are made to this editor in various places but it seems they are outdated (like for example in MultiCharts .NET Programming Guidev 1.2, the latest one I could find). It seems this Power Language .NET Editor was decomissioned and not accessible anymore. Is the go-to editor Visual Studio then?

2) PowerLanguage .NET methods and classes: where can I find a reference to these?

I'm trying to figure out what are the latest (and current) tools and standards (and what is simply outdated).

So any hints to this would be of great use. Thanks in advance to the community.

HellGhostEvocatorX
Posts: 143
Joined: Feb 10 2022
Has thanked: 68 times
Been thanked: 23 times

Jun 26 2024

That's right, as far as I know the 1.2 guide is the most current. The information is also contained on the mutlicharts Wiki page. The PL Editor is still there, you can open it by clicking on the button in Multicharts itself, or via your own shortcut, e.g. Press the Windows key and enter “multicharts .net64 Power language editore” in the search bar. I would recommend using Visual Studio, but it's not a must, you can use both editors in parallel. Visual Studio offers more options for troubleshooting, but I also use the PL Editor in parallel.Image

You can use the help file "Powerlanguage.net help" that I mentioned and search/filter there for "methods" or "class". Alternatively, if you use visual studio, the built-in “intelli Sense” will also make suggestions for you when programming. You should start programming first, the rest will come naturally. Maybe first take a look at josh's tutorials on https://www.tradingcode.net/multicharts ... -articles/, if you are looking for a specific function/method, google will be happy to help you, chatgpt is also a good one Help (although not always perfect). There are now many options for self-help, and many questions have already been answered here in the forum and there is now also some example code. What's important is that you get started first, and to do this you should first program some indicators/signals :)
Attachments
MS Powerlanguage editor.png
(149.1 KiB) Not downloaded yet