Errors, bugs, questions - page 1189

 

meta-quotes, you have me completely confused (

bool  ObjectCreate(
   long         chart_id,      // идентификатор графика
   string       name,          // имя объекта
   ENUM_OBJECT  type,          // тип объекта
   int          sub_window,    // индекс окна
   datetime     time1,         // время первой точки привязки
   double       price1,        // цена первой точки привязки
   ...
   datetime     timeN=0,       // время N-ой точки привязки
   double       priceN=0,      // цена N-ой точки привязки
   ...
   datetime     time30=0,      // время 30-й точки привязки
   double       price30=0      // цена 30-точки привязки
   );
 

N after 30 first ?

30 max?

 
sanyooooook:

meta-quotes, you've got me completely confused (

N after 30 first ?

30 max?

The help specifies:

Creates an object with the specified name, type and initial coordinates in the specified sub-window of the graph. You can specify up to 30 coordinates when creating it.

I.e. 30 is the maximum. So first comes an unknown number (N) of parameters and the very last parameter with index 30.

 
barabashkakvn:

The help specifies:

Creates an object with the specified name, type and initial coordinates in the specified sub-window of the graph. Up to 30 coordinates can be specified during creation.

I.e. 30 is the maximum. So first comes an unknown number (N) of parameters and the very last parameter with index 30.

Usually they write N, and after that they specify the maximum number N where N<=30

SZZ: they are masters of confusion: one change of indexation alone, when copying an array, costs nothing )

or this:

           ObjectSetInteger(0,iObjectName,OBJPROP_TIME,0,X1Time);

it turns out that the first coordinate of the trend line is not the first. but zero, and nowhere does it say that, at least where you can quickly find this information.

 
sanyooooook:
you usually write N, and after that you specify the maximum N where N<=30

Not in this context. This is not a description of conditions, but a variable name. And the variable name should reflect the maximum allowable index. This is why the last variables go with index 30:

   datetime     time30=0,      // время 30-й точки привязки
   double       price30=0      // цена 30-точки привязки
 
paladin800:
Is there any way to make file operations write/read files not to disk but to RAM to work faster and without holes?
You can make a RAM disk, you can create a file in memory.
 
barabashkakvn:

Not in this context. This is not a description of conditions, but a variable name. And the variable name should reflect the maximum allowable index. Therefore, the last variables go with an index of 30:

In all maths textbooks they write it like I mentioned above, they specify N and then give this N a value not exceeding 30.
 

They've got it right in the reference in the quad:

bool  ObjectCreate(
   long          chart_id,      // идентификатор графика
   string        object_name,   // имя объекта
   ENUM_OBJECT   object_type,   // тип объекта
   int           sub_window,    // индекс окна
   datetime      time1,         // время первой точки привязки
   double        price1,        // цена первой точки привязки
   ...
   datetime      timeN=0,       // время N-точки привязки
   double        priceN=0       // цена N-точки привязки
   );
 

 
TheXpert:
You can make a RAM disk, you can create a file in memory.
I see. The problem is that the terminal sandbox is on the C drive and even if I create a RAM drive (e.g. E drive), I can't redirect the sandbox there.
 
paladin800:
I see. The problem is that the sandbox of terminals is located on drive C and even if I create a RAM-drive (e.g. drive E), I can't redirect sandbox there.

First of all, it is possible to redirect it.

And if you use WinAPI, you don't need to redirect either. Secondly, creation of files in memory has nothing to do with RAM-disks, though WinAPI is needed too.

 

I used Metaeditor's help to take an example of how to work with the spread. I ran it on GBPCHF, CADCHF where spread is not 1-2 pips. Can you tell me why the array is filled with zeros? Is it designed that way?

#property indicator_separate_window
#property indicator_buffers 1
//---- plot Spread
#property  indicator_label1  "Spread"
#property  indicator_type1   DRAW_HISTOGRAM
#property  indicator_color1  clrRed
#property  indicator_style1  STYLE_SOLID
#property  indicator_width1  1
//--- input parameters
input int      bars=3000;
//--- indicator buffers
double         SpreadBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,SpreadBuffer,INDICATOR_DATA);
   IndicatorSetInteger(INDICATOR_DIGITS,0);
//---
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
  {
//---
   if(prev_calculated==0)
     {
      int spread_int[];
      ArraySetAsSeries(spread_int,true);
      int spreads=CopySpread(Symbol(),0,0,bars,spread_int);
      Print("Получено исторических значений спреда: ",spreads);
      for (int i=0;i<spreads;i++) 
      {
      SpreadBuffer[rates_total-1-i]=spread_int[i];
      if(i<=30) Print("spread["+i+"] =",spread_int[i]);
      }
     }
   else
     {
      double Ask,Bid;
      Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
      Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
      Comment("Ask = ",Ask,"  Bid = ",Bid);
      SpreadBuffer[rates_total-1]=(Ask-Bid)/Point();
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }