Code to plot historical data

Questions about MultiCharts and user contributed studies.
MichaelF
Posts: 2
Joined: 08 Jul 2018

Code to plot historical data

Postby MichaelF » 11 Jul 2018

Hi All,

I hope you are All well, i am new MC user and I try to do something which will be probably very easy for you. I have an .csv file as below

Data1 Data2
DATE CLOSE DATE CLOSE
20070510 27.09 20070510 27.09
20070511 26.41 20070511 26.41
20070514 27.23 20070514 27.23
20070515 27.89 20070515 27.89
20070516 27.07 20070516 27.07
20070517 24.86 20070517 24.86
20070518 24.71 20070518 24.71
20070521 24.67 20070521 24.67
20070522 26.03 20070522 26.03
20070523 26.35 20070523 26.35
20070524 26.63 20070524 26.63
20070525 25.81 20070525 25.81
20070529 27.83 20070529 27.83
20070530 28.61 20070530 28.61
20070531 28.44 20070531 28.44
20070601 27.39 20070601 27.39
.............................


This file will be updated end of each weekand will be used to create Data1 time serie etc.

I need your help to create a code that will read the file and that will then plot a line on chart.

Thank you very much for your help,

looking forward to hearing from you.

best.

User avatar
Henry MultiСharts
Posts: 9134
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: Code to plot historical data

Postby Henry MultiСharts » 11 Jul 2018

Hello MichaelF,

The data can be read from a csv file and plotted on a chart using the ASCII mapping feature. It creates a link from the software to the ASCII file with data. ASCII mapping does not import data into MultiCharts database (Edit data window of QuoteManager will be empty). Each time you plot an ASCII mapping symbol-the data is taken from the file directly. That is possible to map multiple ASCII files at the same time. You do not need to create ASCII mapping instrument manually-it is created automatically upon mapping.
More information: http://www.multicharts.com/trading-soft ... ping_ASCII

If you still want to go with an indicator reading the data from a file - please refer to the following post:
viewtopic.php?f=1&t=49864&p=122839#p121836

MichaelF
Posts: 2
Joined: 08 Jul 2018

Re: Code to plot historical data

Postby MichaelF » 11 Jul 2018

Henry,

Thanks for your quick reply, problem with using the ASCII mapping is that it is not dynamic and need to import the updated data again and again.

I looked at the indicator reading using .dll. After downloaded the zip file and extracted the files on my desktop I created the indicator with the following code :

DefineDLLFunc: "C:\Users\Fab\Desktop\IOData\IOData\Release\IOData.dll", int, "RFile", lpstr;
DefineDLLFunc: "C:\Users\Fab\Desktop\IOData\IOData\Release\IOData.dll", lpstr, "InData", int;
var: idx(0), LinesCount(0);
once cleardebug;

if(LastBarOnChart_s) then begin
Print("What's in the file ?");
LinesCount = RFile("C:\Users\Fab\Desktop\VolDataTest.csv");

for idx = 0 to LinesCount - 1 begin
print(InData(idx));
end;
end


I have the following error message : " Error in Study "Test_Collection (OIL Last-1Day)* : can't find dll "C:\Users\Fab\Desktop\IOData\IOData\Release\IOData.dll".

Data sample from the csv file

DATE OPEN HIGH LOW CLOSE
20000104 25.2 25.69 24.71 25.55
20000105 25.5 25.61 24.86 24.91
20000106 24.8 25.34 24.51 24.78
20000107 24.65 25 24.15 24.22
20000110 24.15 24.75 24.02 24.67
20000111 24.71 25.8 24.67 25.77
20000112 25.73 26.55 25.38 26.28
20000113 26.28 27.12 26.2 26.69
20000114 26.8 28.1 26.61 28.02
20000118 28.03 29 27.96 28.85
20000119 28.8 29.68 28.55 29.54
20000120 29.25 29.95 28.8 29.66
20000121 27.85 29.1 27.7 28.2

Thanks for your help.

sptrader
Posts: 710
Joined: 09 Apr 2010
Location: Colorado
Has thanked: 470 times
Been thanked: 261 times
Contact:

Re: Code to plot historical data

Postby sptrader » 11 Jul 2018

Hi All,

I hope you are All well, i am new MC user and I try to do something which will be probably very easy for you. I have an .csv file as below

Data1 Data2
DATE CLOSE DATE CLOSE
20070510 27.09 20070510 27.09
20070511 26.41 20070511 26.41
20070514 27.23 20070514 27.23
20070515 27.89 20070515 27.89
20070516 27.07 20070516 27.07
20070517 24.86 20070517 24.86
20070518 24.71 20070518 24.71
20070521 24.67 20070521 24.67
20070522 26.03 20070522 26.03
20070523 26.35 20070523 26.35
20070524 26.63 20070524 26.63
20070525 25.81 20070525 25.81
20070529 27.83 20070529 27.83
20070530 28.61 20070530 28.61
20070531 28.44 20070531 28.44
20070601 27.39 20070601 27.39
.............................


This file will be updated end of each weekand will be used to create Data1 time serie etc.

I need your help to create a code that will read the file and that will then plot a line on chart.

Thank you very much for your help,

looking forward to hearing from you.

best.
If you have Excel, it will read the .csv file directly. Then it can easily plot the line for you too.

User avatar
Henry MultiСharts
Posts: 9134
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: Code to plot historical data

Postby Henry MultiСharts » 12 Jul 2018

MichaelF,

ASCII Mapping is dynamic and reads all the data directly from the file each time you request it. You should not mix it up with the ASCII Import, which is a one time data transfer.

As for the error you got - make sure the IOData.dll is located in C:\Users\Fab\Desktop\IOData\IOData\Release\.
The dll should be the same bit as your MultiCharts. Means 32 bit MultiCharts requires 32 bit DLL, 64 bit MultiCharts requires 64 bit DLL.

Shaman
Posts: 29
Joined: 03 Dec 2018
Has thanked: 5 times

Re: Code to plot historical data

Postby Shaman » 09 Dec 2018

Hello MichaelF,

The data can be read from a csv file and plotted on a chart using the ASCII mapping feature. It creates a link from the software to the ASCII file with data.... More information: http://www.multicharts.com/trading-soft ... ping_ASCII
Tell me - does mapping work only for symbols or can it still be used for indicators? if yes, then I don’t understand how to match the indicator fields, especially if it has several lines (such as bollinger bands?)
and another small question - does mapping understand the% symbol in the data (is it a normal unit of measure for indicators)?


Return to “MultiCharts”