stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

write actual equity into a log file (.csv)
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1629
Page 1 of 1
Author:  forextrader-radioman [ Fri Mar 15, 2013 7:14 am ]
Post subject:  write actual equity into a log file (.csv)

Hy coders!

Can anyone of you help me with a code snippet?

I will implement a routine "write actual equity into a log file (.csv)" every hour. Data shall contain:

Date, Time, Forex Pair, Equity

Greetings from Hamburg/Germany,
Dietmar
Author:  fxprotrader [ Sat Mar 16, 2013 7:22 pm ]
Post subject:  Re: write actual equity into a log file (.csv)

forextrader-radioman wrote:Hy coders!

Can anyone of you help me with a code snippet?

I will implement a routine "write actual equity into a log file (.csv)" every hour. Data shall contain:

Date, Time, Forex Pair, Equity

Greetings from Hamburg/Germany,
Dietmar
Dietmar-
The following is a code snippet that includes the log function.
Put it on an H1 chart and it will log once per hour

Code: Select all

datetime bartime=0;

if(bartime!=Time[0]){
bartime=Time[0];   

string TF = GetTimeFrameStr();
datetime dSymTime = (iTime(Symbol(),Period(),i));
int dDayofWk = (TimeDayOfWeek(Time[i]));
string TradeInfo =action+","+ DoubleToStr(ArrowPips,0)+"/"+DoubleToStr(TradeSizeSL,0)+"/"+DoubleToStr(TradeSizeTP,0);

//call the log function
logwrite(Symbol()+" "+TF,TimeToStr(Time[i], TIME_DATE)+","+TimeToStr(Time[i], TIME_MINUTES)+","+dDayofWk+","+i+","+Symbol()+","+TF+","+IndiResults+","+TradeInfo+","+text+"|");
}

//+------------------------------------------------------------------+
//| log function                                 |
//+------------------------------------------------------------------+
void logwrite (string filename, string mydata){ 
int myhandle;
filename=filename+"_"+Symbol()+"_mysettings.txt";
 
 myhandle = FileOpen(filename, FILE_CSV|FILE_WRITE|FILE_READ, ";");
 if(myhandle>0){
      FileSeek(myhandle,0,SEEK_END);
      FileWrite(myhandle,mydata);
      FileClose(myhandle);
}
} 
Author:  forextrader-radioman [ Sun Mar 17, 2013 7:40 am ]
Post subject:  Re: write actual equity into a log file (.csv)

fxprotrader wrote: Dietmar-
The following is a code snippet that includes the log function.
Put it on an H1 chart and it will log once per hour
[...]
fxprotrader,
many thanks for that! ... very nice :)

Dietmar
Author:  niepce [ Tue Apr 16, 2013 9:24 am ]
Post subject:  Re: write actual equity into a log file (.csv)

into .hst : http://codebase.mql4.com/6217
All times are UTC Page 1 of 1