[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 365

 
sibemol >> :

Thanks for the reply, I'll try it and let you know the results.

I've just added a few things as an idea.


//+------------------------------------------------------------------+
//| CopyBars.mq4 |
//| Copyright © 2009, Sorento |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Sibemol & Sorento" // :)
#property link "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 White
//---- input parameters
extern int Max_Length=9;
double v1[];int pos, hFile;datetime CurentT;
string O="CB", strng, F=";", Filler="0000000000000000";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
string Name_File;
Name_File=StringConcatenate(O,Symbol(),TimeYear(Time[0]),"_",TimeMonth(
Time[0]),"_",TimeDay(Time[0]),"x",TimeHour(iTime(NULL,1,0)),"_",
TimeMinute(iTime(NULL,1,0)),".CSV");
Print ("Bars in ",Name_File," start!");
hFile=FileOpen(Name_File,FILE_CSV |FILE_WRITE,F);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,v1);
strng=StringConcatenate("<ticker>",F,"<per>",F,"<date>",F,"<time>",F,"<open>",F,"<high>");
strng=StringConcatenate(strng,F,"<low>",F,"<close>",F,"<volume>",F,"<oi>",F);
pos=pos+StringLen(strng);
FileWrite(hFile,strng);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
FileClose(hFile);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(), limit;
//----- первый вызов
if (counted_bars==0)
{CurentT=Time[0];// при записи может закрыться текущий бар и появится новый
limit=Bars-1;
CurentT =FilesWR(limit,1);
//----
return(0);
}
//---- последующие
if (counted_bars>0)
if (CurentT<Time[0])
{// мог быть обрыв связи - нужно найти последний и может еще не обновлённый бар
limit=iBarShift(NULL,Period(),CurentT,false);
CurentT=Time[0];// при записи может закрыться текущий бар и появится новый
FilesWR(limit+1,0);
}
else FilesWR(1,0); //бар еще текущий
//-----
return(0);
}
//+------------------------------------------------------------------+
datetime FilesWR(int startBar,int code){

int codec=code;

for(int i=startBar; i>=0; i--)
{
v1[i]=Close[i];
int _Year=TimeYear(Time[i]),
_Month=TimeMonth(Time[i]),
_Day=TimeDay(Time[i]),
_Hour=TimeHour(Time[i]),
_Minute=TimeMinute(Time[i]);

string Y, M, D, H, Mi, Date, _Time;

if(_Month<10) M="0"+DoubleToStr(_Month, 0); else M=DoubleToStr(_Month, 0);
if(_Day<10) D="0"+DoubleToStr(_Day, 0); else D=DoubleToStr(_Day, 0);
if(_Hour<1) H="00";
else if(_Hour<10 ) H="0"+DoubleToStr(_Hour, 0);
else H=DoubleToStr(_Hour, 0);
if(_Minute<1)Mi="00";
else if(_Minute<10) Mi="0"+DoubleToStr(_Minute, 0);
else Mi=DoubleToStr(_Minute, 0);
Date=DoubleToStr(_Year, 0)+M+D;
_Time=H+Mi;

strng=StringConcatenate(Symbol(),F, Period(),F, Date,F, _Time,F,
DS(Open[i]),F,DS(High[i]),F, DS(Low[i]),F,DS( Close[i]),F,IS( Volume[i],10),F);
pos=+StringLen(strng);// можно заранее просчитать длину и использовать предопределённую константу
if (codec==0)
{//обновим предпоследний бар тоже
FileSeek(hFile,pos-StringLen(strng),SEEK_SET);
codec=+1;
}

FileWrite(hFile,strng);// при записи может закрыться текущий бар и появится новый
if ( CurentT<Time[0]) i=+1;// сместим индексы

}
CurentT=Time[0];
FileFlush(hFile);
return ;
}
//----------Быстрая коричневая сука----------
//----------12345678901234567890----------!!!
string DS(double value)
{
string strng=DoubleToStr(value,Digits);
int k=StringLen(strng);
int l=StringFind(strng,".")+Digits+1;
if (l<k)
{ strng=StringConcatenate(strng,StringSubstr(Filler,0,k-l));k=2*k-l;}
int i=Max_Length-k;// add char
return (StringConcatenate(StringSubstr(Filler,0,i+1),strng));
}
string IS(int iValue, int Max_Length)
{
string strng=DoubleToStr(iValue,0);
int k=StringLen(strng);
int i=Max_Length-k;// add 0
return (StringConcatenate(StringSubstr(Filler,0,i+1),strng));
}
 

The optimisation ended with the following message:

There were 60 passes done during optimization
optimization stopped, 140 cache records were used, 140 cache records rejected

In this case, in the settings window it was:

200 / 1 280 (200)


1. Can anyone explain what these numbers mean and how they could have been obtained? (60, 140, 200, 1280)

2. If, say, two parameters were optimised and the number of possible combinations were 15 and 20 respectively - where would they be visible (among these numbers)?

3. Is there any limitation on the number of optimization cycles? (would all combinations be guaranteed to be considered?).

Thank you!

 

How do I make a description of the Fibo object levels available from the properties? How to set their values in the code is clear:

      ObjectSet("fibo", OBJPROP_FIBOLEVELS,8);
      ObjectSet("fibo", OBJPROP_FIRSTLEVEL+0,0.0);
      ObjectSet("fibo", OBJPROP_FIRSTLEVEL+1,0.382);
      ObjectSet("fibo", OBJPROP_FIRSTLEVEL+2,0.618);
      ObjectSet("fibo", OBJPROP_FIRSTLEVEL+3,1.0);
      ObjectSet("fibo", OBJPROP_FIRSTLEVEL+4,1.382);
      ObjectSet("fibo", OBJPROP_FIRSTLEVEL+5,1.618);
      ObjectSet("fibo", OBJPROP_FIRSTLEVEL+6,2.0);
      ObjectSet("fibo", OBJPROP_FIRSTLEVEL+7,2.618);

But the description? Or is it not available from the code?

 

Sorento, thank you very much! As soon as the weekend is over I'll be sure to check your version and alsu.

2alsu: I got confused with the fields, counting them as strings )).

 
sibemol >> :
Sorento, thank you very much! As soon as the weekend is over I will definitely check your variant and alsu.

without market movement check now. this will allow you to concentrate on debugging only two situations.

the bar is still old

and there is a new one.

If there is a new bar, you need to update the fully formed one.

there is something to optimize.

And check the algorithm for skipping a link and losing a fragment of history artificially.


Good luck on your way.


PS. I think I need to shift back two lengths though. Think about it.

 
Sorento, checked the code without changing anything on the standing market. The lines look like this: EURUSD;15;20091224;1830;0001.43580;0001.43625;0001.43566;0001.43611;00000000163; EURUSD;15;20091224;1845;0001.43612;0001.43612;0001.43536;0001.43538;00000000180; and the two latest bars are written (duplicated) at the beginning of the file. I will have to shift it. I will study your code. Thank you.
 

leading and filling zeros after DoubleToStr(value,Digits) are needed for length constancy - that was the problem.

You can search for position from the end. ;)

Good luck in your search.

 

2Sorento:

In your code.

int start()
{
int counted_bars=IndicatorCounted(), limit;
//----- первый вызов
if ( counted_bars==0)
{ CurentT=Time[0];// при записи может закрыться текущий бар и появится новый
limit=Bars-1;
CurentT = FilesWR( limit,1);
//----
//return(0);

I've removed return(0), then the file was written as it should be, only there are no values of the last <oi> field, which contains 0 in all records, but it's nothing, I'll fix it. Now we need to check in motion. Thanks again.

Is there no way to remove the lead zeros in the price fields? It seems to the length does not affect.

 
Svinozavr >> :

How do I make a description of the Fibo object levels available from the properties? How to set their values in the code is clear:

And description? Or it is not accessible from the code?


Thanks to Sorento - suggested ObjectSetFiboDescription.

Question removed.

 
sibemol >> :

2Sorento:

In your code.

Removed return(0), then file is written as it should, only there are no values of last <oi> field, containing 0 in all records, but it's trifles, I'll figure it out. Now we need to check in motion. Thanks again.

ZS Is there no way to remove lead. zeros in the price fields? Doesn't seem to affect the length.

gold run. 1140 и 980

record length changes.

and <oi> I've removed it for lack of use ;)

Reason: