Questions from Beginners MQL5 MT5 MetaTrader 5 - page 841

 
Vitaly Muzichenko:

The kodobase is full of libraries and there's also an article

It's a famous article. It's not the right one.

It's inconvenient to define it every time.

 
double Bid  double Ask  double Close[]  double Low[]  и так далее


Codebase is full of libraries, but I'm asking if anyone knows of specific libraries that could make a mountain once and for all

 
Stefan Stoyanov:
The article is well known This is not the right one.

Codebase is full of libraries, but I'm asking about specific libraries if anyone knows .

You need to take 2-3 libraries, and build one of your own from them - complete.

 
Vitaly Muzichenko:

We need to take 2-3 libraries and use them to build one of our own - a complete library.


Where is the library index that will tell us what a particular library is for and how to communicate with it?

In general, I do not want to collect and make libraries.
My question about the existence of ready libraries, if I will create them again, it is better to work through the article
 
Stefan Stoyanov:

Where is the library index that will tell us what a particular library is for and how to communicate with it?

Generally speaking, I don't want to build and make libraries.
My question is about the existence of ready-made libraries, if I'm going to build them again, it's better to work through the article

It's very easy to build, you take longer to write on a forum and create problems for yourself.

Here's some of it:

#ifdef __MQL5__
datetime iTime(string symb,ENUM_TIMEFRAMES tf,int index) {
datetime Arr[1];
  return((CopyTime(symb,tf,index,1,Arr)==1)?Arr[0]:WRONG_VALUE);
 }
//-------------------------------------------------------------------------------------------------------
double iOpen(string symb,ENUM_TIMEFRAMES tf,int index) {
double Arr[1];
  return((CopyOpen(symb,tf,index,1,Arr)==1)?Arr[0]:WRONG_VALUE);
 }
//-------------------------------------------------------------------------------------------------------
double iClose(string symb,ENUM_TIMEFRAMES tf,int index) {
double Arr[1];
  return((CopyClose(symb,tf,index,1,Arr)==1)?Arr[0]:WRONG_VALUE);
 }
//-------------------------------------------------------------------------------------------------------
double iLow(string symb,ENUM_TIMEFRAMES tf,int index) {
double Arr[1];
  return((CopyLow(symb,tf,index,1,Arr)==1)?Arr[0]:WRONG_VALUE);
 }
//-------------------------------------------------------------------------------------------------------
double iHigh(string symb,ENUM_TIMEFRAMES tf,int index) {
double Arr[1];
  return((CopyHigh(symb,tf,index,1,Arr)==1)?Arr[0]:WRONG_VALUE);
 }
//-------------------------------------------------------------------------------------------------------
double AccountFreeMarginCheck(const string Symb,const int Cmd,const double dVolume) {
 double Margin;
   return(::OrderCalcMargin((ENUM_ORDER_TYPE)Cmd, Symb, dVolume,
          ::SymbolInfoDouble(Symb,(Cmd==::ORDER_TYPE_BUY) ? ::SYMBOL_ASK : ::SYMBOL_BID),Margin) ?
          ::AccountInfoDouble(::ACCOUNT_MARGIN_FREE) - Margin : -1);
 }
#endif
 

I found this code

I want to ask if this code can be reduced to a file with some name, so that it is not reset every time, but just stays in the folder



// Позволяет, как в MT4, работать с таймсериями: Open[Pos], High[Pos], Low[Pos], Close[Pos], Time[Pos], Volume[Pos].
// А так же задает привычные MT4-функции: iOpen, iHigh, iLow, iClose, iTime, iVolume.
#define  DEFINE_TIMESERIE(NAME,FUNC,T)                                                                         \
  class CLASS##NAME                                                                                           \
  {                                                                                                           \
  public:                                                                                                     \
    static T Get( const string Symb, const int TimeFrame, const int iShift )                                  \
    {                                                                                                         \
      T tValue[];                                                                                             \
                                                                                                              \
      return((Copy##FUNC((Symb == NULL) ? _Symbol : Symb, _Period, iShift, 1, tValue) > 0) ? tValue[0] : -1); \
    }                                                                                                         \
                                                                                                              \
    T operator []( const int iPos ) const                                                                     \
    {                                                                                                         \
      return(CLASS##NAME::Get(_Symbol, _Period, iPos));                                                       \
    }                                                                                                         \
  };                                                                                                          \
                                                                                                              \
  CLASS##NAME  NAME;                                                                                           \
                                                                                                              \
  T i##NAME( const string Symb, const int TimeFrame, const int iShift )                                       \
  {                                                                                                           \
    return(CLASS##NAME::Get(Symb,  TimeFrame, iShift));                                                        \
  }

DEFINE_TIMESERIE(Volume, TickVolume, long)
DEFINE_TIMESERIE(Time, Time, datetime)
DEFINE_TIMESERIE(Open, Open, double)
DEFINE_TIMESERIE(High, High, double)
DEFINE_TIMESERIE(Low, Low, double)
DEFINE_TIMESERIE(Close, Close, double)





 

I used to define an opener this way:


  MqlRates mrate[];          // To be used to store the prices, volumes and spread of each bar  
   ArraySetAsSeries(mrate,true);
   if(CopyRates(_Symbol,_Period,0,3,mrate)<0)
     {
      Print("Error copying rates/history data - error:",GetLastError(),"!!");
      return(0);
     }
   double close=mrate[0].close; double open=mrate[0].open;
   double high=mrate[0].high;   double low=mrate[0].low;


This method is the same as yours ?

//-------------------------------------------------------------------------------------------------------
double iOpen(string symb,ENUM_TIMEFRAMES tf,int index) {
double Arr[1];
  return((CopyOpen(symb,tf,index,1,Arr)==1)?Arr[0]:WRONG_VALUE);
 }
//------------------------------------------------------------------------------




 
Stefan Stoyanov :

I found this code

I want to ask if this code can be reduced to a file with some name, so that it doesn't reset every time, but just stays in the folder

Add this line at the beginning of the working file.

 #include  "your_file.mqh" 

Place your_file.mqh in the "include" folder of your terminal

 
Ugh!!! The extension ....mq5 will of course have an error
Files:
 
Stefan Stoyanov:
Ugh! The extension ....mq5 will of course have an error

don't place code inside OnTick()

just include file your_file.mqh with defines to your expert_file.mq5 as i told you in my previous post

 
Kirill Belousov:

don't place code inside OnTick()

just include file your_file.mqh with defines to your expert_file.mq5 as I told you in my previous post

I already did. Thanks !
Reason: