Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам - страница 2575

 
Artyom Trishkin #:
Поставите курсор внутрь круглых скобок и нажмите ctrl+shift+пробел. Всë и увидите. Ну, или нажмите F1 на функции. 

Спасибо

 

подскажите почему получение спреда настолько дольше ask или bid?

Test_1()] = 77 mсs

Test_2()] = 76 mсs

Test_4()] = 7716 mсs


#define _TEST(_function,_count) {ulong _latency=GetMicrosecondCount();for(int i=0; i<_count; i++){_function;}_latency=GetMicrosecondCount()-_latency; ::Print("Time[" + __FILE__ + " " + (string)__LINE__ + " in " + __FUNCTION__+ ": " + #_function + "] = " + (string)_latency + " mсs");}
#define count 1000*5
void OnStart()
  {
_TEST(Test_1(),count); 
_TEST(Test_2(),count); 
_TEST(Test_4(),count); 
  }
void Test_1()
{
double bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
}
//---
void Test_2()
{
double ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
}
//---
void Test_3()
{
//int spread=ask-bid;
}
//---
void Test_4()
{
int spread2=SymbolInfoInteger(Symbol(),SYMBOL_SPREAD);
}
 

коллеги помогите индик чтобы поддавался iCustom во вложении - такие значения надо чтобы принтовал с робота типа 205682


а он печатает (выдает через робота), 10,  11, какие то номера баров чтоли...??? 

красные  линии это что он выдает (не правильно), зеленые стрелки это правильно то что надо чтобы он выдавал

вот обращение к iCustom

с робота

 double ind_10,ind_11,ind_12,  ind_20,ind_21,ind_22, 
          ind_30,ind_31,ind_32,  
          BufS0, BufS1, BufS2; // средняя для трехножного индикатора пересечение с ней отсматриваем за закрытие


// зеленый цвет линии индика
   ind_10=NormalizeDouble(iCustom(_Symbol,_Period,"spreads",1,"USDCAD",true,1,0,0),_Digits); // "0" - bar
   ind_11=iCustom(_Symbol,_Period,"spreads",1,"USDCAD",true,1,0,1); // "1" - bar
   ind_12=iCustom(_Symbol,_Period,"spreads",1,"USDCAD",true,1,0,2); // "2" - bar
  
   Print(" 1 ind_10 = ", DoubleToString(ind_10,_Digits)," ind_11 = ",DoubleToString(ind_11,_Digits)," ind_12 = ",DoubleToString(ind_12,_Digits));
Файлы:
spreads.mq5  9 kb
 
Здравствуйте! Подскажите пожалуйста, в чем проблема? Есть индикатор Аллигатор. По вверх синей линии хочу создать еще одну линию, но другого цвета и с большей толщиной. Но получается какая-то вот такая дребедень(Прикрепил во вложения). Код следующий: 
//+------------------------------------------------------------------+
//|                                                      MA_Test.mq5 |
//|                      copyright "2009, MetaQuotes Software Corp." |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+

#property copyright "2009, MetaQuotes Software Corp." 
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots 4
#property indicator_buffers 8

#property indicator_type1   DRAW_COLOR_LINE
#property indicator_color1 clrBlue
#property indicator_width1  1
#property indicator_label1 "Jaws"


#property indicator_type2   DRAW_COLOR_LINE
#property indicator_color2 clrRed
#property indicator_width2  1
#property indicator_label2 "Teeth"

#property indicator_type3   DRAW_COLOR_LINE
#property indicator_color3 clrLime
#property indicator_width3  1
#property indicator_label3 "Lips"

#property indicator_type4   DRAW_COLOR_LINE
#property indicator_color4 clrAqua
#property indicator_width4  3
#property indicator_label4 "BuyCross"
double ExtJaws[];
double ExtColorJaws[];

double ExtTeeth[];
double ExtColorTeeth[];

double ExtLips[];
double ExtColorLips[];

double ExtBuyCr[];
double ExtClrBuyCr[];
//---- input parameters
input int                InpJawsPeriod=13;               // Jaws period
input int                InpJawsShift=8;                 // Jaws shift
input int                InpTeethPeriod=8;               // Teeth period
input int                InpTeethShift=5;                // Teeth shift
input int                InpLipsPeriod=5;                // Lips period
input int                InpLipsShift=3;                 // Lips shift
input ENUM_MA_METHOD     InpMAMethod=MODE_SMMA;          // Moving average method
input ENUM_APPLIED_PRICE InpAppliedPrice=PRICE_MEDIAN;   // Applied price
//---- indicator buffers
//---- handles for moving averages
int    ExtJawsHandle;
int    ExtTeethHandle;
int    ExtLipsHandle;

int ExtBuyCRHandle;
//--- bars minimum for calculation
int    ExtBarsMinimum;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
  SetIndexBuffer(0,ExtJaws,INDICATOR_DATA);
  SetIndexBuffer(1,ExtColorJaws,INDICATOR_COLOR_INDEX);
  SetIndexBuffer(2,ExtTeeth,INDICATOR_DATA);
  SetIndexBuffer(3,ExtColorTeeth,INDICATOR_COLOR_INDEX);  
  SetIndexBuffer(4,ExtLips,INDICATOR_DATA);
  SetIndexBuffer(5,ExtColorLips,INDICATOR_COLOR_INDEX);
  SetIndexBuffer(6,ExtBuyCr,INDICATOR_DATA);
  SetIndexBuffer(7,ExtClrBuyCr,INDICATOR_COLOR_INDEX);  
//--- indicator buffers mapping
//--- set accuracy
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//---- sets first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpJawsPeriod-1);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpTeethPeriod-1);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpLipsPeriod-1);
   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,InpJawsPeriod-1);
//---- line shifts when drawing
   PlotIndexSetInteger(0,PLOT_SHIFT,InpJawsShift);
   PlotIndexSetInteger(1,PLOT_SHIFT,InpTeethShift);
   PlotIndexSetInteger(2,PLOT_SHIFT,InpLipsShift);
   PlotIndexSetInteger(3,PLOT_SHIFT,InpJawsShift);
//---- name for DataWindow
   PlotIndexSetString(0,PLOT_LABEL,"Jaws("+string(InpJawsPeriod)+")");
   PlotIndexSetString(1,PLOT_LABEL,"Teeth("+string(InpTeethPeriod)+")");
   PlotIndexSetString(2,PLOT_LABEL,"Lips("+string(InpLipsPeriod)+")");
   PlotIndexSetString(3,PLOT_LABEL,"Buy Cross("+string(InpJawsPeriod)+")");
//--- get MA's handles
   ExtJawsHandle=iMA(NULL,0,InpJawsPeriod,0,InpMAMethod,InpAppliedPrice);   
   ExtTeethHandle=iMA(NULL,0,InpTeethPeriod,0,InpMAMethod,InpAppliedPrice);
   ExtLipsHandle=iMA(NULL,0,InpLipsPeriod,0,InpMAMethod,InpAppliedPrice);
   
ExtBuyCRHandle=iMA(NULL,0,InpJawsPeriod,0,InpMAMethod,InpAppliedPrice);     
ExtBarsMinimum=InpJawsPeriod+InpJawsShift;   
   if(ExtBarsMinimum<(InpTeethPeriod+InpTeethShift))
      ExtBarsMinimum=InpTeethPeriod+InpTeethShift;
   if(ExtBarsMinimum<(InpLipsPeriod+InpLipsPeriod))
      ExtBarsMinimum=InpLipsPeriod+InpLipsPeriod;      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
//--- check for rates total
   if(rates_total<ExtBarsMinimum)
      return(0); // not enough bars for calculation
//--- not all data may be calculated
   int calculated=BarsCalculated(ExtJawsHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtJawsHandle is calculated (",calculated,"bars ). Error",GetLastError());
      return(0);
     }
   calculated=BarsCalculated(ExtTeethHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtTeethHandle is calculated (",calculated,"bars ). Error",GetLastError());
      return(0);
     }     
   calculated=BarsCalculated(ExtLipsHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtLipsHandle is calculated (",calculated,"bars ). Error",GetLastError());
      return(0);
      }  
   calculated=BarsCalculated(ExtBuyCRHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtBuyCRHandle is calculated (",calculated,"bars ). Error",GetLastError());
      return(0);
      }            
//--- we can copy not all data
   int to_copy;
   if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
      if(prev_calculated>0) to_copy++;
     }
//---- get ma buffers
   if(CopyBuffer(ExtJawsHandle,0,0,to_copy,ExtJaws)<=0)
     {
      Print("getting ExtJawsHandle is failed! Error",GetLastError());
      return(0);
     }     
   if(CopyBuffer(ExtTeethHandle,0,0,to_copy,ExtTeeth)<=0)
     {
      Print("getting ExtTeethHandle is failed! Error",GetLastError());
      return(0);
     }     
   if(CopyBuffer(ExtLipsHandle,0,0,to_copy,ExtLips)<=0)
     {
      Print("getting ExtLipsHandle is failed! Error",GetLastError());
      return(0);
     }   
//New MA
   if(CopyBuffer(ExtJawsHandle,0,0,to_copy,ExtClrBuyCr)<=0)
     {
      Print("getting ExtBuyCRHandle is failed! Error",GetLastError());
      return(0);
     }          
     
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
В чем может быть проблема? 
Файлы:
 
Roman Shiredchenko #:

коллеги помогите


   indHandle=iCustom(_Symbol,_Period,"spreads",1,"GBPUSD",true,1);


 
W1nd ReD #:
В чем может быть проблема? 
//New MA
   if(CopyBuffer(ExtJawsHandle,0,0,to_copy,ExtClrBuyCr)<=0)
     {
      Print("getting ExtBuyCRHandle is failed! Error",GetLastError());
      return(0);
     }  
 
Tretyakov Rostyslav #:

Но я же ее и создал специально, чтобы она отрисовывалась также, как и синяя линия аллигатора. Тогда на что ее изменить, чтобы не потерялся смысл? 

Что линия цвета Аква была такая же, как и синяя?

 
W1nd ReD #:

Но я же ее и создал специально, чтобы она отрисовывалась также, как и синяя линия аллигатора. Тогда на что ее изменить, чтобы не потерялся смысл? 

Что линия цвета Аква была такая же, как и синяя?


Вы не то буфер прописали.

 
Tretyakov Rostyslav #:


Вы не то буфер прописали.

Увидел! Спасибо огромное!

 
Tretyakov Rostyslav #:


пока все равно пишет 10  11   12


iCustom(_Symbol,_Period,"spreads",1,"USDCAD",true,1,1); // "1" - bar
   ind_10=iCustom(_Symbol,_Period,"spreads",1,"USDCAD",true,1,0);
 //   indHandle=iCustom(_Symbol,_Period,"spreads",1,"USDCAD",true,1);
   ind_11=iCustom(_Symbol,_Period,"spreads",1,"USDCAD",true,1,1); // "1" - bar
   ind_12=iCustom(_Symbol,_Period,"spreads",1,"USDCAD",true,1,2); // "2" - bar
 
   Alert(" 1 ind_10 = ", DoubleToString(ind_10,_Digits)," ind_11 = ",DoubleToString(ind_11,_Digits)," ind_12 = ",DoubleToString(ind_12,_Digits));
Файлы:
spreads.mq5  9 kb