Multicharts AppendFile is replacing instead of appending

Questions about MultiCharts and user contributed studies.
FutureTrader
Posts: 79
Joined: 28 Mar 2013
Has thanked: 3 times
Been thanked: 4 times
Contact:

Multicharts AppendFile is replacing instead of appending

Postby FutureTrader » 08 Dec 2015

Try this one

Code: Select all

inputs:
filePath("C:\multicharts\export\");


variables:
intrabarpersist vFileName(""),
intrabarpersist resolution(""),
int output(0);

if StrLen(filePath) > 0 then begin
once begin
switch bartype_ex begin
case 1:
resolution = NumToStr(barinterval,0) + " tick";
case 2:
resolution = NumToStr(barinterval,0) + " minute";
case 3:
resolution = NumToStr(barinterval,0) + " hour";
case 4:
resolution = "daily";
case 5:
resolution = "weekly";
case 6:
resolution = "monthly";
case 7:
resolution = "year";
case 9:
resolution = NumToStr(barinterval,0) + " second";
end;
vFileName = filePath + symbol + "__" + resolution + "__.csv";
FileDelete(vFileName);
FileAppend(vFileName, "Date, Time, Open, High, Low, Close, Volume, Openint" + newline);
end;
end;

FileAppend(vFileName, FormatDate("yyyy-MM-dd" , DateTime) +","+ FormatTime("HH:mm:ss", DateTime) +","+ NumToStr(Open,5) +","+ NumToStr(High,5) +","+ NumToStr(Low,5) +","+ NumToStr(Close,5) +","+ NumToStr(Volume,5) +","+ NumToStr(Openint,5) + newline);

now switch to the savingPath folder and run in windows powershell:

Code: Select all

Get-Content '.\@ES__1 second__.csv' -Wait -Tail 5
You'll notice Multicharts is not appending each new line instead Multicharts is rewriting/replacing the complete file everytime it tries to append a new line. Running the same logic in TS "Get-Content" is behaving as expecting printing each incoming data as new line.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Multicharts AppendFile is replacing instead of appending

Postby TJ » 08 Dec 2015

Try this one
::
You'll notice Multicharts is not appending each new line instead Multicharts is rewriting/replacing the complete file everytime it tries to append a new line. Running the same logic in TS "Get-Content" is behaving as expecting printing each incoming data as new line.
Please state your MultiCharts version.

FutureTrader
Posts: 79
Joined: 28 Mar 2013
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Multicharts AppendFile is replacing instead of appending

Postby FutureTrader » 08 Dec 2015

Try this one
::
You'll notice Multicharts is not appending each new line instead Multicharts is rewriting/replacing the complete file everytime it tries to append a new line. Running the same logic in TS "Get-Content" is behaving as expecting printing each incoming data as new line.
Please state your MultiCharts version.
9.1 Release (Build 12010)

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

Re: Multicharts AppendFile is replacing instead of appending

Postby Henry MultiСharts » 17 Dec 2015

Hello FutureTrader,

We will check that.

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

Re: Multicharts AppendFile is replacing instead of appending

Postby Henry MultiСharts » 18 Dec 2015

Hello FutureTrader,

We were unable to replicate this behavior on our end. Both TS and MC behave the same way appending the line to the end of the file. Please make sure you using this script on one chart at a time. Please also specify how do you know that the complete file is rewritten.

FutureTrader
Posts: 79
Joined: 28 Mar 2013
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Multicharts AppendFile is replacing instead of appending

Postby FutureTrader » 23 Dec 2015

Hello FutureTrader,

We were unable to replicate this behavior on our end. Both TS and MC behave the same way appending the line to the end of the file. Please make sure you using this script on one chart at a time. Please also specify how do you know that the complete file is rewritten.

I'm using the script on scanner window isn't this possible?

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

Re: Multicharts AppendFile is replacing instead of appending

Postby Henry MultiСharts » 23 Dec 2015

Hello FutureTrader,

In case you are using "Bars Back" date request in the scanner window - then there can be multiple reasons for this behavior, which are explained by the scanner window operation peculiarities and not the FileAppend reserved word operation:
1) the same instrument with the same resolution is present multiple times in the list->two streams are writing to the same file;
2) "Rescan" is done->study is recalculated;
3) adding other indicators that require more bars -> automatically increasing the data series length->study is recalculated;
4) after some realtime bars are accumulated - the data series is shortened to the specified length->study is recalculated.
Please try using the Days Back request in the scanner window. Alternatively you can use your study on a chart or in the Portfolio Trader.


Return to “MultiCharts”