Discussion on the implementation of councillors. - page 5

 
Ivan_Invanov:
Here, I've learned the syntax of the language. I'm learning the constructor as an example. I see a class call. The logic is cut off for me from here. What should I do? Search for articles? Is it better to implement with standard means or write my own classes?
I find an article on clarification of the constructor. Explaining how a signal block works, for instance. And a couple of dry phrases like yes, this parameter is fixed. And there is nothing written to change it. I have such questions, if I don't need the parameter, I can simply delete it? it is in the initialization, delete there too? How can I add more parameters and how? If I saw an example of a change, I could figure it out. I think it's purely a reference problem. Not enough detail, not enough examples , not enough generalizations for a systematic perception. Maybe I'm very blunt, I don't know. I wonder if it's just me? Or maybe the training manuals need to be improved? I am willing to personally pay money for example.
 
Ivan_Invanov:

MQL5 - This is the resource with the most detailed description of documentation. There is a huge amount of information in the articles, on the forum and in KodoBase. Nowhere else in the world you will find such a detailed description.

All you need is the will to understand it all.

 
Vladimir Karputov:

MQL5 - This is the resource with the most detailed description of documentation. There is a huge amount of information in the articles, forum and KodoBase. You won't find it anywhere else where it is explained in such detail.

You just need the will to grasp it all.

Here's a specific question. We have CExpertSignal with AddFilter function. For example, we have a spread there. How do I make it if I cannot see the example. What exactly should I do? Well, I will try to guess it now.

CExpert ExtExpert;
ExtExpert.InitSignal(signal);
signal.AddFilter(filter0);
filer0.Spread(20);

Compilation without errors. Have I written it correctly? Now trades will not be concluded if spread exceeds 20? And what should I do in such a case? What can read?

 
Ivan_Invanov:

Here's a specific question. There is a CExpertSignal with AddFilter in it, but the help doesn't say anything about AddFilter functions. There is a spread, for example. How do I write it, if I can't see the example. What exactly should I do? Well, I will try to guess it now.

Compilation without errors. Have I written it correctly? Now trades will not be concluded if spread exceeds 20? And what should I do in such a case? What should I read?

Read:MQL4/MQL5 Wizard

Assignment:

  • To create a simple Expert Advisor using the Wizard
  • in the MetaEditor open the resulting code
After that ask questions.
Мастер MQL4/MQL5 - Справка по MetaEditor
Мастер MQL4/MQL5 - Справка по MetaEditor
  • www.metatrader5.com
Благодаря Мастеру MQL4/MQL5, трейдер может создать советника, не обладая знаниями в области программирования. Все что нужно сделать — это выбрать торговые сигналы, которые будет использовать советник, алгоритм мани-менеджмента и трейлинг-стопа. Код советника будет сгенерирован автоматически на основе выбранных параметров. Помимо этого, Мастер...
 
Ivan_Invanov:

Here's a specific question. There is a CExpertSignal with AddFilter in it, but the help doesn't say anything about AddFilter functions. For example, there is a spread. How do I write it, if I can't see the example. What exactly should I do? Well, I will try to guess it now.

Compilation without errors. Have I written it correctly? Now trades will not be concluded if spread exceeds 20? And what should I do in such a case? What should I read?

It seems to me that here is an attempt to immediately start writing adult topics without basic knowledge. That's not how it works. First they learn the alphabet, then they learn to write in block letters and little by little they get to essays, and then you need talent. So it's the same without basic knowledge trying to understand automatically generated code... Not the best way to bang your head against the wall.

 
//+------------------------------------------------------------------+
//|                                                            1.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
//--- available signals
#include <Expert\Signal\SignalMA.mqh>
//--- available trailing
#include <Expert\Trailing\TrailingNone.mqh>
//--- available money management
#include <Expert\Money\MoneyFixedRisk.mqh>
//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
//--- inputs for expert
input string             Expert_Title         ="1";         // Document name
ulong                    Expert_MagicNumber   =15825;       //
bool                     Expert_EveryTick     =false;       //
//--- inputs for main signal
input int                Signal_ThresholdOpen =10;          // Signal threshold value to open [0...100]
input int                Signal_ThresholdClose=10;          // Signal threshold value to close [0...100]
input double             Signal_PriceLevel    =0.0;         // Price level to execute a deal
input double             Signal_StopLevel     =50.0;        // Stop Loss level (in points)
input double             Signal_TakeLevel     =50.0;        // Take Profit level (in points)
input int                Signal_Expiration    =4;           // Expiration of pending orders (in bars)
input int                Signal_MA_PeriodMA   =12;          // Moving Average(12,0,...) Period of averaging
input int                Signal_MA_Shift      =0;           // Moving Average(12,0,...) Time shift
input ENUM_MA_METHOD     Signal_MA_Method     =MODE_SMA;    // Moving Average(12,0,...) Method of averaging
input ENUM_APPLIED_PRICE Signal_MA_Applied    =PRICE_CLOSE; // Moving Average(12,0,...) Prices series
input double             Signal_MA_Weight     =1.0;         // Moving Average(12,0,...) Weight [0...1.0]
//--- inputs for money
input double             Money_FixRisk_Percent=10.0;        // Risk percentage
//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing expert");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Creating signal
   CExpertSignal *signal=new CExpertSignal;
   if(signal==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating signal");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//---
   ExtExpert.InitSignal(signal);
   signal.ThresholdOpen(Signal_ThresholdOpen);
   signal.ThresholdClose(Signal_ThresholdClose);
   signal.PriceLevel(Signal_PriceLevel);
   signal.StopLevel(Signal_StopLevel);
   signal.TakeLevel(Signal_TakeLevel);
   signal.Expiration(Signal_Expiration);
//--- Creating filter CSignalMA
   CSignalMA *filter0=new CSignalMA;
   if(filter0==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating filter0");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
   signal.AddFilter(filter0);
//--- Set filter parameters
   filter0.PeriodMA(Signal_MA_PeriodMA);
   filter0.Shift(Signal_MA_Shift);
   filter0.Method(Signal_MA_Method);
   filter0.Applied(Signal_MA_Applied);
   filter0.Weight(Signal_MA_Weight);
//--- Creation of trailing object
   CTrailingNone *trailing=new CTrailingNone;
   if(trailing==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating trailing");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Add trailing to expert (will be deleted automatically))
   if(!ExtExpert.InitTrailing(trailing))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing trailing");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Set trailing parameters
//--- Creation of money object
   CMoneyFixedRisk *money=new CMoneyFixedRisk;
   if(money==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating money");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Add money to expert (will be deleted automatically))
   if(!ExtExpert.InitMoney(money))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing money");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Set money parameters
   money.Percent(Money_FixRisk_Percent);
//--- Check all trading objects parameters
   if(!ExtExpert.ValidationSettings())
     {
      //--- failed
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators())
     {
      //--- failed
      printf(__FUNCTION__+": error initializing indicators");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- ok
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   ExtExpert.OnTick();
  }
//+------------------------------------------------------------------+
//| "Trade" event handler function                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
   ExtExpert.OnTrade();
  }
//+------------------------------------------------------------------+
//| "Timer" event handler function                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   ExtExpert.OnTimer();
  }
//+------------------------------------------------------------------+
Hello. Could you please tell me what market entry signal this EA has and where is it located in the code?
Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
The market entry signal is in the 'filter', right?
 
Why different class declarations? Why sometimes stacked memory and sometimes not ? With and without asterisk?
 
I need a spread filter and would like to understand what is being done here. Did I understand correctly that the strategy here is that if the price is higher by any figure from the average, then a trade is made?
 
Ivan_Invanov:
Hello. Can you please tell me what is the market entry signal of this EA and where it is located in the code?

You have to use a debugger to deal with such issues.

When a tick comes, the OnTick() function is called. It is where all the processing takes place, the signals are identified if necessary, and trading actions are performed if necessary.

As you can see, in this function the ExtExpert. Everything happens within this function, there is nothing else in the code.

Accordingly, you put a breakpoint at it and run the Expert Advisor in the debugger. As soon as the first tick comes, the breakpoint triggers and you stop the code in this position. And then you move through the code step by step, figuring out why and what actions are performed.

Reason: