Errors, bugs, questions - page 2817

 
is it possible to control this figure through MQL? (this is the box from the line on the chart in MT)
 
TesterMaxProfit.all_symbols.M1.20200727.20200805.42.405 CEC9C4975113F378E5F241968A332.opt

Can you tell me what algorithm is used to form the name of the opt-files?

 

on mt4 - it seems to me that ChartSaveTemplate(...) works with errors, build 1280

here's the script:

//+------------------------------------------------------------------+
//|                                              Test.mq4            |
//|                   Copyright 2006-2015, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright   "2006-2015, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property strict
#property  show_inputs

void OnStart()
{
   string s_Symbol = Symbol();
   string s_EA_Name = "eStomper_02";
   string s_MagicChartIDSuffix = "MagicChart";
   int i_Magic = 1;
   string s_GlobalMagicChartID;
   string s_Period = _Period;
   
   s_GlobalMagicChartID = StringConcatenate(s_EA_Name,"-",s_MagicChartIDSuffix,"-",i_Magic,"-",s_Symbol,"-",s_Period);
   if(ChartSaveTemplate(0,s_GlobalMagicChartID))
   {
      Print("s_GlobalMagicChartID=",s_GlobalMagicChartID);     
   }
   else
   {
      Print(__FUNCTION__," Couldnot Save template : " + s_GlobalMagicChartID + ".tpl" + "Error = " + GetLastError());
      return;
   }
}
//+------------------------------------------------------------------+
для М1 и М5 имя шаблона усекается, _Period - в имени шаблона не присутсвует..

смотрю полный игнор, но вот если сделать так, то все в порядке. явно в компиляторе ошибка, что-то типа неправильного выравнивания.


//+------------------------------------------------------------------+
//|                                              Test.mq4            |
//|                   Copyright 2006-2015, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright   "2006-2015, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property strict
#property  show_inputs

void OnStart()
{
   string s_Symbol = Symbol();
   string s_EA_Name = "eStomper_02";
   string s_MagicChartIDSuffix = "MagicChart";
   int i_Magic = 1;
   string s_GlobalMagicChartID;
   string s_Period = _Period;
   
   if (s_Period == "1" || s_Period == "5")
   {
      s_Period = "0" + s_Period;
   }
   s_GlobalMagicChartID = StringConcatenate(s_EA_Name,"-",s_MagicChartIDSuffix,"-",i_Magic,"-",s_Symbol,"-",s_Period);
   if(ChartSaveTemplate(0,s_GlobalMagicChartID))
   {
      Print("s_GlobalMagicChartID=",s_GlobalMagicChartID);     
   }
   else
   {
      Print(__FUNCTION__," Couldnot Save template : " + s_GlobalMagicChartID + ".tpl" + "Error = " + GetLastError());
      return;
   }
}
//+------------------------------------------------------------------+



 
fxsaber:

Can you tell me, what algorithm is used to form the name of opt-files?

This is MD5 from values of input parameters of the Expert Advisor (for the optimized ones - start-step-stop, for the non-optimized ones - current value)

42 - real ticks, optimization by symbols

Торговые советники и собственные индикаторы - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
Торговые советники и собственные индикаторы - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
  • www.metatrader5.com
Среди программ для автоматического трейдинга можно выделить две большие категории: торговые роботы и индикаторы. Первые предназначены для совершения торговых операций на рынках, а вторые — для анализа котировок и выявления закономерностей в их изменении. При этом индикаторы могут использоваться непосредственно в роботах, образуя полноценную...
 
Pavel Verveyko:
is it possible to control this figure via MQL? (this is the box from the line on the chart in MT)
Using this library
 
Rorschach:
With the help of this library

many thanks

 

Question for clarification. How do I know the symbol and timeframe of an indicator by its handle?

There isIndicatorParameters function in MQL API to read indicator parameters, but it is not enough: what is the point of knowing, for example, period, if the symbol and timeframe are not known? I am not sure if this is an omission or I cannot find how to do this - please give me the link.

 
Stanislav Korotky:

Question for clarification. How do I know from an indicator handle the symbol and timeframe it was created for?

no way

i can't. Last year@fxsaber asked the same question, but with respect to files - how to know the file name from a handle, there is no solution

I found a suggested container for a file handle from@fxsaber

struct FILE
{
  const int handle;
  
  FILE( const string FileName, const int Flags ) : handle(::FileOpen(FileName, Flags)) {}  
  ~FILE( void ) { if (this.handle != INVALID_HANDLE) ::FileClose(this.handle); }
};
 
Stanislav Korotky:

Question for clarification. How do I know the symbol and timeframe of an indicator by its handle?

There is IndicatorParameters function in MQL API to read indicator parameters, but it is not enough: what is the point of knowing, for example, period, if the symbol and timeframe are not known? If there is an error or I cannot find how to do it, please give me the link.

Igor Makanu:

no way

Yes, you can.

bool FindIndicatorByHandle(long handle, string &symbol, ENUM_TIMEFRAMES &timeframe, long &ChartId, int &sub_win, string &Name) {
   long chart_id =ChartFirst();
   while (chart_id!=-1) {
      int total_sub = (int)ChartGetInteger(chart_id,CHART_WINDOWS_TOTAL);
      int total_ind;
      for(int i=0; i<total_sub; i++) {
         total_ind = ChartIndicatorsTotal(chart_id,i);
         for (int j=0; j<total_ind; j++) {
            string name = ChartIndicatorName(chart_id,i,j);
            if (ChartIndicatorGet(chart_id,i,name)== handle) {
               ChartId=chart_id;
               symbol= ChartSymbol(chart_id);
               timeframe=ChartPeriod(chart_id);
               sub_win=i;
               Name=name;
               return true;
            }
         }
      }
      chart_id=ChartNext(chart_id);
   }
   return false;
}

I am attaching the test script.

The result of the script work:

2020.08.07 01:39:43.435 All_Indicators (US30Index,M1)   Market Watch: CADRUB  USDRUB  USDCAD  EURCAD  EURUSD  .BrentCrud  XAUUSD  GBPAUD  BTCUSD  US30Index  USDJPY  Symb001  USD-BTC  EURCHF  USDCHF  
2020.08.07 01:39:43.498 All_Indicators (US30Index,M1)   Chart EURUSD PERIOD_M1 has indicators: TestMinMax(handle=10)   RVI(10)(handle=11)   RSI_154(14)(handle=12)   
2020.08.07 01:39:43.499 All_Indicators (US30Index,M1)   Chart .BrentCrud PERIOD_M1 has indicators: 
2020.08.07 01:39:43.500 All_Indicators (US30Index,M1)   Chart CADRUB PERIOD_M1 has indicators: 
2020.08.07 01:39:43.501 All_Indicators (US30Index,M1)   Chart USDCAD PERIOD_M5 has indicators: 
2020.08.07 01:39:43.502 All_Indicators (US30Index,M1)   Chart US30Index PERIOD_M1 has indicators: MA(100)(handle=13)   TestMinMax(handle=14)   
2020.08.07 01:39:43.505 All_Indicators (US30Index,M1)   Chart .BrentCrud PERIOD_D1 has indicators: DinTF(handle=15)   
2020.08.07 01:39:43.509 All_Indicators (US30Index,M1)   Chart USDRUB PERIOD_M1 has indicators: Bands(200)(handle=16)   Env(10)(handle=17)   MACD(12,26,9)(handle=18)   RSI(14)(handle=19)   
2020.08.07 01:39:43.523 All_Indicators (US30Index,M1)   Chart EURUSD PERIOD_M30 has indicators: MA(15)(handle=20)   TestMinMax(handle=21)   
2020.08.07 01:39:43.527 All_Indicators (US30Index,M1)   Chart .BrentCrud PERIOD_M5 has indicators: 
2020.08.07 01:39:43.527 All_Indicators (US30Index,M1)   Chart USDCAD PERIOD_M15 has indicators: DinTF(handle=22)   
2020.08.07 01:39:43.527 All_Indicators (US30Index,M1)   Chart USDCAD PERIOD_H1 has indicators: pMa(2 - 940)(handle=23)   !Channels_3.05)(handle=24)   
2020.08.07 01:39:43.528 All_Indicators (US30Index,M1)   Chart USDCAD PERIOD_H4 has indicators: 
2020.08.07 01:39:43.528 All_Indicators (US30Index,M1)   Chart XAUUSD PERIOD_M1 has indicators: Tick(handle=25)   
2020.08.07 01:39:43.528 All_Indicators (US30Index,M1)   --------------------------------------------------------------------------------
2020.08.07 01:39:43.528 All_Indicators (US30Index,M1)   Попробуем найти индикатор по хэндлу h = 18
2020.08.07 01:39:43.529 All_Indicators (US30Index,M1)   Нашли: USDRUB  PERIOD_M1, chart_id = 128968168864101623, подокно = 1, короткое имя = MACD(12,26,9)
Files:
 
Nikolai Semko:

You can.

Your code will probably work

I never usedChartIndicatorGet(), only now I found it in the reference

but anyway, it is easier to bind the indicator handle directly to the indicator name in your code, although it may be the task to find out what the user has launched


thanks! interesting

Reason: