MultiCharts .NET FAQ

Questions about MultiCharts .NET and user contributed studies.
User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Working with studies/solution/references:
  • You can add new study in Visual Sudio:
    The format of the study file name is:TechName.TechType.cs(vb) where:
    1) TechName - the name of the study (must be equal to class name).
    2) TechType - type of the study (Indicator, Strategy, Function)
    When the new file with name that matches this template is created, MC will "pick up" it as new study.
    OR
    Open the solution file in the studio, modify, then save it. Once the file is saved - MultiCharts .Net editor picks up the changes in the study file and compiles it. Modifications appear in MC Editor and on the chart if the sudy is applied to it.
    More detailed info in the intro video at this page.
  • If you want to customize the solution and/or project - you need to save it under different name.
    Keep in mind that "full integration" between MC.NET and MS VS is monitoring for changes of *.cs (*.vb) files by MC in "%allusersprofile%\Application Data\TS Support\MultiCharts .NET\StudyServer\Techniques\CS" (for 32bit MC .NET) and "%allusersprofile%\Application Data\TS Support\MultiCharts .NET64\StudyServer\Techniques\CS" (for 64bit MC .NET) folders.
  • All references should be added through PowerLanguage .Net Editor only. The references you have added are global and available for all studies. There is only one direction of synchronization: from МultiСharts .Net editor to PlStudies* project. The changes done in VS for PlStudies* project would not be saved and would not show up in MC.Net editor.
  • You can organize your code in folders in the PowerLanguage .Net editor. However, those folders don't show up in Visual Studio when you open the PLStudies2010.sln file.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q:How does one reference a dll?

A: It depends on the type of the dll you are using.
  • For C# dll you need to add a reference in PowerLanguage .Net Editor (Right click on the workarea with the code in PowerLanguage .Net Editor->References-> Add reference/Add global reference).
  • For C++ dll you need to reference the functions that are provided by this dll for ex:

    Code: Select all

    [DllImport( "mTestMCdll.dll", CharSet = CharSet.Unicode )]
    public static extern void CreateGPanelHDCHWND( IntPtr hdc, IntPtr hwnd );
  • For COM dll please refer to this page.
  • 32bit dll will work with 32 bit version of MultiCharts only.
    64bit dll will work with 64 bit version of MultiCharts only.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q: How to protect .Net studies?

A: There is no built-in password protection for studies in MultiCharts .Net. The most effective protection is to move the main part of the code into C++ library and then reference this library from C# study.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

  • To reference previous bar's values (ex. previous bar's close):

    Code: Select all

    Bars.Close[1]
  • To reference previous study values (ex. previous moving average value):

    Code: Select all

    m_avg[1]
  • To reference data from a subchart (ex. current close from second data series):

    Code: Select all

    BarsOfData(2).Close
  • To make the function calculated on data2. Example for ADX and ATR functions:

    Code: Select all

    ADX _a = new ADX(this,2);
    //
    double _aa = PublicFunctions.TrueRange(this, 10, 2);

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q: Can I define IntrabarOrderGeneration directly in the code with MC.Net as I can do with MC standard?

A: IOGModeAttribute Class is available in MC.Net. Here is how you can use it:

Code: Select all

[IOGMode(IOGMode.Enabled)]

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q: Where can I find DataLoader interface example?

A: In MultiCharts .NET you can access a lot of various data directly from the scripts. It can be real-time ask and bid and level 2 data from various symbols that are not even charted. You can also access all information from the Order and Position Tracker. This is an example for using the DataLoader interface. For MultiCharts .Net 8.5 Release you can find an example here.

A sample code that subscribes to realtime data and outputs the realtime bar values in Output tab of PLEditor window can be found here.

Releated article in MultiCharts.NET-Programming Guide:
4.7.4 Receiving the data for any symbol and any resolution. DataLoader.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q: How do I specify the amount of contracts in the code?

A: Here is an example how to do that. If you do not specify the amount to buy/sell in the code then the value specified in Trade Size of the Properties tab of the Strategy Properties would be used.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q: PowerLanguage .Net Editor windows are outside of the main editor window after the update.
How to stick them back?
Q: I cannot see PowerLanguage .Net Editor window, though I can see it's icon on the Windows Task Bar and process in the Task Manager.
Q: I cannot see the source code of any study in the PowerLanguage .Net Editor window. Why?

A: 1) Close PowerLanguage .Net Editor window.
2) Go to Windows Start menu-Run->regedit.exe
3) Go to the following path :
for 32bit MC: HKEY_CURRENT_USER\Software\TS Support\MultiCharts .Net\
for 64bit MC: HKEY_CURRENT_USER\Software\TS Support\MultiCharts .Net64\
4) In the registry tree please make a right click on the "PLEditor" folder and click Delete.
5) Start PowerLanguage .Net Editor now.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Everything you need to know about MultiCharts .Net functions:
  • The source code of the functions has been opened in MultiCharts 8.5.
  • Functions are not in VS solution, they are built-in in PLEditor.
  • That means prebuilt functions cannot be seen in Visual Studio.
  • Prebuilt functions are read-only and cannot be exported.
  • You can create new functions from PowerLanguage .Net editor only.
  • User created functions are present in VS solution and can be exported/imported in PLEditor.
  • After each change in a function you need to remove and re-add the strategy to the chart.
  • MC.NET does not analyze the script to know if any functions are used and if they were modified.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q: How do I make my charts/studies communicate between each other?
A: There are two ways to do that:

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

In MultiCharts .Net there are two approaches for order generation: managed and unmanaged orders.

Managed orders are monitored by the strategy. Strategy can be trading only one instrument that is the main data series of your chart. The orders are valid at broker while they are sent by the strategy. That means the conditions for order generation should be met in your code on each bar close or each tick (if IOG=ON) calculation while you need to keep your orders active.
If you want to modify an order - just change the parameter you need (price or quantity) and the order will be modified or cancelled and resubmitted (depends on broker). Here is an example how to modify the amount of contracts for the order. If you want to cancel the order-stop sending it from the code (make the conditions for order generation invalid).

With unmanaged orders you can trade on multiple symbols through different broker plugins directly from one script. The symbols don't need to be on the chart, but you are responsible for managing your orders if you are using this approach. Here is an example of how to use the TradeManager. Another example - Trading from MultiCharts Realtime Market Scanner.
For more information please refer to .Net programming guide: Extended Trading Possibilities. TradeManager:1, 2, 3, 4.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q:What class/method shall be used to retrieve name of symbol and resolution?

A: 1) Bars.Info.Name
2) Bars.Info.Resolution

/* For example, for ES 5 min chart, Resolution.ChartType = ChartType.Regular; Resolution.Type = EResolution.Minute; Resolution.Size = 5; */

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

Q: How do I create and remove a drawing from the code?

A:This indicator will create three drawings on bar #10, then on bar #15 it will delete the arrow drawing.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 13 Dec 2013

VariableObject and VariableSeries. Description, difference, code sample. Check here.


User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 30 Dec 2013

With MultiCharts .Net you can create a study using C# or VB.Net and export it into a pln file.
With regular MultiCharts you can create a study using PowerLanguage and export it into a pla file.

Studies from MultiCharts .Net cannot be used in regular MultiCharts and viсe versa.
There is no backward compatibility between pln and pla files.
There is no automated conversion tool C#/VB.Net <-->PowerLanguage.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 11 Dec 2014

Q: I have modified the source code of the indicator and saved/compiled it. Why is that required to remove and re-add the study to see the modification results?

A: That is expected behavior. It is required to re-add the study to the chart if any of the parameters were changed in the object constructor in Create method.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 24 Feb 2015

Additional information, clarifications and examples: MultiCharts .NET programming articles TradingCode.net

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MultiCharts .NET FAQ

Postby Henry MultiСharts » 23 Apr 2015

Q: Why StartCalc() method and all code above row where is used BarsOfData (for first time) is called twice?

A: Explanation can be found in the following post.


Return to “MultiCharts .NET”