Libraries: TimeSeries - Function Library for Working with Time Series - page 2

 

In general, I have a dual attitude to such developments.

On the one hand, a man has worked hard, and did not regret to post, kudos and respect.

On the other hand, it is necessary for labuhovs stupidly porting codes from MT4 to MT5. "Stupidly" means without going into the possibilities of the language and without delving into the strategy itself.

By the way, I am doing this myself now :) so the criticism is directed to me.

I will try to elaborate on the stupidity and possibilities of MQL5.

Take a simple function iClose, in MT4 it was not possible to get the whole time series at once (only piece by piece), in MT5 it is optimised so that there is no difference between copying one value and the whole series (a little exaggerated, but almost so). So it often takes a comparable amount of time to organise the array to which the data will be copied, so it makes no sense to receive Close one by one. Moreover, these series are already present in indicators by default. So when porting, it makes sense to split the code into a calculation code (which is copied into the indicator) and a trading code (which is executed in the Expert Advisor).

What I mean is that on the one hand such codes are useful for beginners, it becomes easier for them to live.

On the other hand, it sets the wrong programming standard, programming through the G.

By the way, here is one more feature for the includnik:

// it's in the incloudnik
MqlTick last_tick;
#define Ask last_tick.ask
#define Bid last_tick.bid
// it's in OnTick
SymbolInfoTick(_Symbol,last_tick);
// now you can use it anywhere
 Ask; // и
 Bid;
 

Here's more refinement for you.

But it would be better to rewrite everything on the basis of the standard bible.

Files:
 
Sorry, is there an incorrect code there? Migration from MQL4 to MQL5
 
BoraBo:
Sorry, is there an incorrect code there? Switching from MQL4 to MQL5.

Why is it incorrect, it is correct (I copied some of the code from there),

but there is no code there, only enums are broken, and everything else is in the article itself.

+ I ported OrderSend there, I think the lion's share of problems is related to setting orders.

By the way, a lot of things are missing, for example, the whole trading functionality is not broken (I made only OrderSend and OrderClose).

So there is room for development for enthusiasts.

 
Urain:

It's just that the code in the article and in this library is almost identical, I thought maybe something in the article is wrong.

 
BoraBo:

It's just that the code in the article and in this library is almost identical, I thought maybe something in the article is wrong.

But why invent bicycles, I copied what is already there, edited it, added my own.

Voila and everything works.

That's why sources are published, so that others can use them.

Otherwise, every programmer would still write in assembly language.

[Deleted]  
komposter:

I will gladly make analogues of all necessary functions (including accounting of virtual transactions), when I get my hands on them.

Now I need these functions, I could not find a ready-made library. So I had to make my own.

I have been using my library for about three years now, constantly refining it. everything works like a Swiss watch.

You have found some interesting points, I will have to think about implementation.

 
Interesting:

You have found some interesting points, will have to think about the implementation.

can you tell me from the code what interesting points you found?
[Deleted]  
sergeev:
hint on the code, what interesting points did you find?

Some things are simpler and more functional than mine. I didn't put error checks in certain places.

My code is sometimes 3-4 times bigger.

PS

My code, however, seems to me to be more in line with MQL4 (there may be other variants).

[Deleted]  

as an example (very first implementations) for iHighest and iOpen

//Function iHighest
int iHighest(string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0) export 
//Returns the shift of the maximum value over a specific number of periods depending on type. 
{
//----------------------------------------------------------------------------//
//Work variables
ENUM_TIMEFRAMES TF; //Period as ENUM_TIMEFRAMES

double Arr[];
long Volume[];
datetime Time[];

int Result = -1; //Returned importance
//----------------------------------------------------------------------------//

TF = MinuteToPeriod(timeframe);

  if(start<0)  start = 0;
  if(count<=0) count = Bars(symbol,TF);
//MODE_OPEN
  if(type==MODE_OPEN)
  {
  ArraySetAsSeries(Arr,true);

  CopyOpen(symbol,TF,start,count,Arr);

  Result = ArrayMaximum(Arr,0,count) + start;
  }
//MODE_LOW
  if(type==MODE_LOW)
  {
  ArraySetAsSeries(Arr,true);

  CopyLow(symbol,TF,start,count,Arr);

  Result = ArrayMaximum(Arr,0,count) + start;
  }
//MODE_HIGH
  if(type==MODE_HIGH)
  {
  ArraySetAsSeries(Arr,true);

  CopyHigh(symbol,TF,start,count,Arr);

  Result = ArrayMaximum(Arr,0,count) + start;
  }
//MODE_CLOSE
  if(type==MODE_CLOSE)
  {
  ArraySetAsSeries(Arr,true);

  CopyClose(symbol,TF,start,count,Arr);

  Result = ArrayMaximum(Arr,0,count) + start;
  }
//MODE_VOLUME
  if(type==MODE_VOLUME)
  {
  ArraySetAsSeries(Volume,true);

  CopyTickVolume(symbol,TF,start,count,Volume);

  Result = ArrayMaximum(Volume,0,count) + start;
  }
//MODE_TIME
  if(type==MODE_TIME)
  {
  ArraySetAsSeries(Time,true);

  CopyTime(symbol,TF,start,count,Time);

  Result = ArrayMaximum(Time,0,count) + start;
  }
//Checking for presence of the errors 
  if(GetLastError()!=0)
  {
  Result = -1; //Message on error
  }  
//----------------------------------------------------------------------------//
return(Result);
//----------------------------------------------------------------------------//
}
//Function iOpen
double iOpen(string symbol, int timeframe, int shift) export 
//Returns Open value for the bar of indicated symbol with timeframe and shift.
//If local history is empty (not loaded), function returns 0.
//For the current chart, the information about open prices is in the predefined array named Open[]. 
{
//----------------------------------------------------------------------------//
//Work variables
ENUM_TIMEFRAMES TF; //Period as ENUM_TIMEFRAMES

double Arr[];

double Result = 0; //Returned importance
//----------------------------------------------------------------------------//

ResetLastError();

  if(shift>=0)
  {
  TF = MinuteToPeriod(timeframe);

  CopyOpen(symbol,TF,0,Bars(symbol,TF),Arr);
  
    if(ArraySize(Arr)>0)
    {
    ArraySetAsSeries(Arr,true);
    Result = Arr[shift];
    } 

  }
//Checking for presence of the errors 
  if(GetLastError()!=0)
  {
  Result = 0; //Message on error
  }  
//----------------------------------------------------------------------------//
return(Result);
//----------------------------------------------------------------------------//
}