Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 637

 
Top2n:


This function returns the position number of the deadline, not the number itself.

Let's say I got the position number, then how do I remove the position?

I gave you a link to the help, 6 lines below there is a help for StringSubstr, which just extracts a substring from a text string starting from a specified position.
 
AlexeyVik:
I gave you a link to the help, 6 lines below there is help for StringSubstr, which just extracts a substring from a text string starting from a specified position.


sc=ObjectsTotal(OBJ_LABEL);
for(int i=0;i<sc;i++) 
 {
 Neme=ObjectName(i);
 
 if(Neme="lTrend_Power") //Если имя объекта OBJ_LABEL то самое,
{
  NemeText="Trend Power: "; // часть описания из строки текст
  for(int il=0;il<=99;il++) // перебираем 1-99
  {
NemeTextPol = StringFind(NemeText+il+"%",il,0); //Полное имя строки текст "Trend Power: 99%". (99% меняется от 1 до 99)

Kon = StringSubstr(NemeText+il+"%",13,3);
  }
}
What am I doing wrong? The task is to extract 99 (digit) from the string
 
Top2n:

What am I doing wrong? The task is to extract 99 (digit) from a string

sc=ObjectsTotal(OBJ_LABEL);

This is the number of label objects, but if some other object is present, there will be an error in the object loop.

Next, if you don't have any other labels with the same name, you don't need to go through all the objects. Just pull out OBJPROP_TEXT and work with it.


string NameText = ObjectGetString(0, "lTrend_Power", OBJPROP_TEXT);

string Kon = StringSubstr(NameText, 13, 2);

and then convert the string containing the number in string format to the required type.

Well, judging by this example, you are too far from understanding the entire programming process.

NemeText="Trend Power: "; // часть описания из строки текст

This is not a part of object description, this variable NemeText is assigned a value "Trend Power:".

Read the whole help, and then you'll remember that you've seen the solution... and you'll find it easier to find everything you need in the documentation.

 
paladin80:
Without knowing what is written inside your EA it is impossible to say what the problem is. How does the EA behave on EURCHFX M5 and EURCHF M1?

It works everywhere, except EURCHFX M1. It is not clear to me what the "Insufficient right" is and I couldn't find anywhere a more detailed explanation, in which cases this message appears; as a reaction to what... Methaquotes should know what it means.
 
AlexeyVik:

This is the number of label objects, but if some other object is present, there will be an error in the object loop.

Next, if you don't have any other labels with the same name, you don't need to go through all the objects. You just pull out OBJPROP_TEXT and work with it.


string NameText = ObjectGetString(0, "lTrend_Power", OBJPROP_TEXT);

string Kon = StringSubstr(NameText, 13, 2);

and then convert the string containing number in string format to the desired type.

Actually you are far from understanding the entire programming process, judging by this example.

This is not a part of object description, this variable NemeText is assigned a value "Trend Power:".

Read the whole help, and then you'll remember that you've seen the solution... and you'll find it easier to find what you need in the documentation.


Thank you, yes you're right, I'll do some reading this weekend, I'm going to the arkaim)))
 

Can you tell me, has anyone tried INDICATOR_COLOR_INDEX to colour one indicator buffer with different colours? Or it does not work in MT4 yet ?

Example >>>

In MT5 this code works like this:

//+------------------------------------------------------------------+
//|                                                        #Test.mq5 |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   1
#property indicator_color1  clrRoyalBlue,clrRed
//--- Индикаторные буферы
double indicator_buffer[];
double color_indicator_buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Установка буферов
   SetIndexBuffer(0,indicator_buffer,INDICATOR_DATA);
   SetIndexBuffer(1,color_indicator_buffer,INDICATOR_COLOR_INDEX);
//--- Свойства
   PlotIndexSetInteger(0,PLOT_LINE_WIDTH,5);
   PlotIndexSetInteger(0,PLOT_ARROW,159);
   PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_COLOR_ARROW);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
//--- Инициализация буфера
   ArrayInitialize(indicator_buffer,0);
//---
   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[])
  {
   int limit=0;
//--- Если первый вызов
   if(prev_calculated==0)
     {
      limit=0;
      ArrayInitialize(indicator_buffer,0);
     }
   else
      limit=prev_calculated-1;
//--- Основной цикл
   for(int i=limit; i<rates_total && !IsStopped(); i++)
     {
      indicator_buffer[i]=rand()%3;
      color_indicator_buffer[i]=(indicator_buffer[i]==1) ? 0 : 1;
     }
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+

//---

In MT4 similar code, but with some corrections for MQL4, shows this result:

//+------------------------------------------------------------------+
//|                                                        #Test.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  clrRoyalBlue,clrRed
//--- Индикаторные буферы
double indicator_buffer[];
double color_indicator_buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Установка буферов
   SetIndexBuffer(0,indicator_buffer,INDICATOR_DATA);
   SetIndexBuffer(1,color_indicator_buffer,INDICATOR_COLOR_INDEX);
//--- Свойства
   SetIndexStyle(0,DRAW_ARROW,EMPTY,5);
   SetIndexArrow(0,159);
   SetIndexEmptyValue(0,0);
//--- Инициализация буфера
   ArrayInitialize(indicator_buffer,0);
//---
   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[])
  {
   int limit=0;
//--- Если первый вызов
   if(prev_calculated==0)
     {
      limit=0;
      ArrayInitialize(indicator_buffer,0);
     }
   else
      limit=prev_calculated-1;
//--- Основной цикл
   for(int i=limit; i<rates_total && !IsStopped(); i++)
     {
      indicator_buffer[i]=rand()%3;
      color_indicator_buffer[i]=(indicator_buffer[i]==1) ? 0 : 1;
     }
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+
 

Yes, I understand that there are a lot of stupid questions. Honestly, I've been trying all day, but with no results.

I am writing the price values of several trend lines on the current bar into an array.

How do I delete the value from the array if there is no object?

 
Top2n:

Yes, I understand that there are a lot of stupid questions. Honestly, I've been trying all day, but with no results.

I am writing the price values of several trend lines on the current bar into an array.

How do I delete the value from the array if there is no object?

If we run through the values of the trend line prices on every tick, initialize the array and increase its dimension when finding the next necessary price of the necessary trend line, then there will be no need to remove the values of the deleted trend lines from the array. The array will be dynamic, and every time at every tick, it will contain only the values of the existing objects.
 
Top2n:

How do I remove a value from an array if there is no object?


By specifying a price of zero.
 

My question is for a newbie:

I recently found out that MetaEditor is not opening in the terminal, and the "change" command does not work in Expert Advisors and indicators ............. Please help me with this. Please help me to find it out.

Reason: