Resolve:Using FileAppend  [SOLVED]

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Resolve:Using FileAppend

Postby arjfca » 17 Dec 2013

I just resolve the question

I found that I could add "NewLine" to each string before using the function FileAppend
This add a carriage return and the file is properly formatted

_____________________________________________________________________

Hello

This is a complementary question to this post
viewtopic.php?f=1&t=45869

I just found that I could use the function FileAppend to write string to a file. Work fine, but how to I separate each lines? The end result look like this
37,1.35371,1.35371,42000.0000000000,90500.0000000000,2124031,1,False,False138,1.37932,1.37932,
230000.0000000000,230000.0000000000,35723,1,False,False3,1.37889,1.37759,73000.0000000000,81500.0000000000,
2124031,1,False,False4,1.37127,1.37127,10000.0000000000,10000.0000000000,2124031,1,False,True
It should be like this
37,1.35371,1.35371,42000.0000000000,90500.0000000000,2124031,1,False,False
138,1.37932,1.37932,230000.0000000000,230000.0000000000,35723,1,False,False
3,1.37889,1.37759,73000.0000000000,81500.0000000000,2124031,1,False,False
4,1.37127,1.37127,10000.0000000000,10000.0000000000,2124031,1,False,True
My code:

Code: Select all

//Capture the Trendline characteristics and store them in global variable

Var:
FileName("G:\ExcelMUlticharts\Database\TrendLine"),
ListID (0),
return_Val (0),

Comma (","),

GVCount (0),
TL_count (0),
TL_Num (0),
TL_Num_Ex (0),
TL_First (0),
TL_Last (0),
List_String (""),
TL_Num_String (""),
TL_Price_S (""),
TL_Price_E (""),
TL_Time_S (""),
TL_Time_E (""),
TL_Color (""),
Tl_Style (""),
TL_Ext_L (""),
TL_Ext_R ("");


Const:

DrawManually (7);

Once begin
FileName= FileName +"_" + GetSymbolName + ".txt";
//ListID = ListS.Share("TrendLinesInfo");
FileDelete(Filename);

//Return_Val = Lists.WriteFile(ListID, FileName); //erase

GVSetNamedString("TrendLineFile",FileName);

TL_First = TL_GetFirst(DrawManually );
Tl_Num = TL_First;
TL_Num_Ex = 0;
While TL_Num <> -2 begin
TL_Num_Ex = TL_NUM;
TL_Count = TL_Count +1;
TL_Num_String = NumToStr(TL_Num,0);
TL_Price_S = NumtoStr(TL_GetBeginVal(TL_Num),5);
TL_Price_E = NumToStr(TL_GetEndVal(TL_Num),5);
TL_Time_S = NumToStr(TL_GetBeginTime_s(TL_Num),10);
TL_Time_E = NumToStr(TL_GetEndTime_s(Tl_Num),10);
TL_Color = NumToStr(TL_GetColor(TL_Num),0);
TL_Style = NumToStr(TL_GetStyle(TL_NUM),0);
IF tl_getextleft(TL_Num) then TL_Ext_L = "True" else TL_Ext_L = "False";
IF tl_getextRight(TL_Num) then TL_Ext_R = "True" else TL_Ext_R = "False";

List_String = TL_Num_String + comma + TL_Price_S + comma + TL_Price_E + comma + TL_Time_S + comma + TL_Time_e + comma + TL_Color + comma + TL_Style + comma + TL_Ext_L + comma +TL_Ext_R;
//Print (ListID, " ", list_String);
FileAppend(Filename,List_String);
TL_NUm = TL_GetNext(tl_num,DrawManually);
//Print("TL_Num: ", TL_Num:0:0);
end;
TL_Last = TL_Num;

end;
Martin

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Resolve:Using FileAppend

Postby Andrew MultiCharts » 17 Dec 2013

Hello arjfca,

Do you need exactly FileAppend?

An example of Print doing what you need:

Code: Select all

Condition1 = close > close[1];

If Condition1 = true then begin
print(File("C:\PrintExampleFile.txt"), "======================", NewLine,
"The date is ", DateToString(DateToJulian(Date)), ",", NewLine,
"time is ", TimeToString(ELTimeToDateTime(Time)), ",", NewLine,
"bar # is ", maxbarsback+currentbar, ",", NewLine,
"current bar open is ", open, ",", NewLine,
"current bar high is ", high, ",", NewLine,
"current bar low is ", low, ",", NewLine,
"current bar close is ", close);
end;

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Resolve:Using FileAppend

Postby arjfca » 17 Dec 2013

Hello arjfca,

Do you need exactly FileAppend?

An example of Print doing what you need:

Code: Select all

Condition1 = close > close[1];

If Condition1 = true then begin
print(File("C:\PrintExampleFile.txt"), "======================", NewLine,
"The date is ", DateToString(DateToJulian(Date)), ",", NewLine,
"time is ", TimeToString(ELTimeToDateTime(Time)), ",", NewLine,
"bar # is ", maxbarsback+currentbar, ",", NewLine,
"current bar open is ", open, ",", NewLine,
"current bar high is ", high, ",", NewLine,
"current bar low is ", low, ",", NewLine,
"current bar close is ", close);
end;
???
Is there a counter indication to use it?
Actually the code return what I need
I don't know much more about writing to a file

Martin

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Resolve:Using FileAppend  [SOLVED]

Postby Andrew MultiCharts » 18 Dec 2013

arjfca,

I simply had a ready made example of code doing what you want (write test to a file allocating it to several lines).
If you want to use FileAppend exactly, here is an example (that can be modified to be used in your code):

Code: Select all

FileAppend("c:\test.txt", Text("Hello", Newline, "World"));


Return to “MultiCharts”