Questions from Beginners MQL5 MT5 MetaTrader 5 - page 111

 

   felidae: 
Нет, всё в порядке, просто я дал случайно свою ссылку. Ваша должна быть по идее такая: https://www.mql5.com/ru/users/vik1991/accounting/chooseout

Thanks for the reply, is there any way to increase the earnings or just wait for the demand to increase?

 

Please advise how to increase (refill) a position in an EA based on the MQL5 Wizard, where positions are opened using

virtual int LongCondition();
virtual int ShortCondition()
;

I wrote a robot based on the following article

https://www.mql5.com/ru/articles/367"Create a trading robot in 6 steps" and it works fine, but any attempt to influence the position size

(whether it increases or decreases) through repeated generation of the condition in , e.g.

LongCondition();

The already opened position remains unchanged, it can only be deleted upon triggering of sl , tp.

I like MQL5 Wizard, it's quick and easy to 'build' a multi-indicator EA, change the sl tracking module, change the money management module.

But my attempt to write an EA that opens a minimum position when a trend is confirmed by one indicator and increases (increases) the position when the trend is confirmed by another indicator

came across the previously described problem - an already open position does not change when re-issuing a signal to open through e.g.LongCondition();

Создай торговый робот за 6 шагов!
Создай торговый робот за 6 шагов!
  • 2012.06.01
  • MetaQuotes Software Corp.
  • www.mql5.com
Вы не знаете, как устроены торговые классы, и пугаетесь слов "Объектно-ориентированное программирование"? На самом деле вовсе не обязательно всё это знать, чтобы написать свой собственный модуль торговых сигналов - достаточно следовать простым правилам. Всё остальное сделает Мастер MQL5, и вы получите готовый торговый робот!
 
Hello, I can't figure out how to use the "mathematical calculation" mode, I'd like to see a code example if possible, or tell me where to find it
 

I want to leave only forex tools in the market, the code works fine

   for(int i=0;i<=SymbolsTotal(false);i++)
     {
      if(SymbolInfoInteger(SymbolName(i,false),SYMBOL_TRADE_MODE)==SYMBOL_TRADE_MODE_FULL && SymbolInfoInteger(SymbolName(i,false),SYMBOL_TRADE_CALC_MODE)==SYMBOL_CALC_MODE_FOREX && SymbolInfoDouble(SymbolName(i,false),SYMBOL_ASK)-SymbolInfoDouble(SymbolName(i,false),SYMBOL_BID)<50*SymbolInfoDouble(SymbolName(i,false),SYMBOL_POINT))
        {
         SymbolSelect(SymbolName(i,false),true);
        }
      else SymbolSelect(SymbolName(i,false),false);
     }

But as soon as I run it in the tester, it loads the history for the following instrument; it cannot be loaded. How can I disable it for the tester????????

2013.04.04 14:09:21 Core 1 GBOTEURUSD17DEC2012: history synchronization started

 
Yuriy2019:

Please advise how to increase (refill) a position in an Expert Advisor that is based on the MQL5 Wizard and where positions are opened via


Unfortunately, the case you describe falls into the category of "improvement" here (in the Forum).

To solve the problem, you need to change the behavior of the Expert Advisor. To do this:

1. We need to create a new class (for example CMyExpert) which inherits from CExpert class.

2. Reload Processing method in it, changing its behavior.

3. Replace (manually) include file in the Expert Advisor source code.

#include <Expert\Expert.mqh>

to

#include <Expert\MyExpert.mqh>

4. Replace (manually) the class name in the Expert Advisor source code.

CExpert ExtExpert;

to

CMyExpert ExtExpert;

The example of class is attached. The exit from method if there is an open position and there are no operations on it is commented (line 53).

Don't forget to follow items 3 and 4 after each "regeneration" of the Expert Advisor in the Wizard.

PS If you have any questions, please contact me.

Документация по MQL5: Стандартная библиотека / Классы торговых стратегий / Базовые классы экспертов / CExpert
Документация по MQL5: Стандартная библиотека / Классы торговых стратегий / Базовые классы экспертов / CExpert
  • www.mql5.com
Стандартная библиотека / Классы торговых стратегий / Базовые классы экспертов / CExpert - Документация по MQL5
Files:
MyExpert.mqh  4 kb
 
Hello, could you please tell me why I can't log in to the terminal. I enter the server, account number and password, but the following entry appears in the log: 2013.04.05 12:51:20 Network '68712': connection to 208.64.66.68:443 lost
I tried another server, same thing, what am I doing wrong?
 
uncleVic:

Unfortunately, the case you describe falls into the category of what is referred to here (in the Forum) as 'fine-tuning'.

To solve the problem, you need to change the behaviour of the expert. To do this:

1. You must create a new class (for example CMyExpert) which inherits from CExpert class.

2. Reload Processing method in it, changing its behavior.

3. Replace (manually) include file in the Expert Advisor source code.

to

4. Replace (manually) the class name in the Expert Advisor source code.

to

An example class is attached. Exit from method if there is an open position and there are no operations on it is commented out (line 53).

Remember to follow steps 3 and 4 after each "regeneration" of the Expert Advisor in the Wizard.

PS If you have any questions, feel free to contact me.

Thank you very much, everything works! It adds the same volume when the trend is confirmed by another indicator.

Now we have one more question - is it possible to change the size of the "add"? For example, the standard position size in the money management module is 0.1, while I want to add ("add") 0.3 or 0.35, etc. calculated by the Expert Advisor.

How can I pass the "refill" size from theLongCondition() subroutine to the trade module?

 
Yuriy2019:

Thank you so much, it's working! Adds the same volume on trend confirmation from another indicator.

Now I have one more question - is it possible to change the size of the "share"? For example, the standard position size in the money management module is 0.1, while I want to add ("add") 0.3 or 0.35, etc. calculated by the Expert Advisor.

How can I pass the "refill" size from theLongCondition() subroutine to the trade module?

The CExpert class has methods:

//+------------------------------------------------------------------+
//| Long position open or limit/stop order set                       |
//+------------------------------------------------------------------+
bool CExpert::OpenLong(double price,double sl,double tp)
  {
   if(price==EMPTY_VALUE) return(false);
//--- get lot for open
   double lot=LotOpenLong(price,sl);
//--- check lot for open
   if(lot==0.0) return(false);
//---
   return(m_trade.Buy(lot,price,sl,tp));
  }
//+------------------------------------------------------------------+
//| Short position open or limit/stop order set                      |
//+------------------------------------------------------------------+
bool CExpert::OpenShort(double price,double sl,double tp)
  {
   if(price==EMPTY_VALUE) return(false);
//--- get lot for open
   double lot=LotOpenShort(price,sl);
//--- check lot for open
   if(lot==0.0) return(false);
//---
   return(m_trade.Sell(lot,price,sl,tp));
  }

Overload in your class (similar to Processing) and change the lot determination algorithm.

Документация по MQL5: Стандартная библиотека / Классы торговых стратегий / Базовые классы экспертов / CExpert
Документация по MQL5: Стандартная библиотека / Классы торговых стратегий / Базовые классы экспертов / CExpert
  • www.mql5.com
Стандартная библиотека / Классы торговых стратегий / Базовые классы экспертов / CExpert - Документация по MQL5
 
uncleVic:

The CExpert class has methods:

Overload in your class (similar to Processing) and change the lot detection algorithm.

Thank you!
 

There is an indicator that says it works on the opening price

code

#property copyright "Ivanov A."
#property link      "aristocrat12@mail.ru"
#property version   "1.00"

#property description "TrendToTrend"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3
#property indicator_type1   DRAW_LINE
#property indicator_type2   DRAW_LINE
#property indicator_type3   DRAW_LINE


#property indicator_style1  STYLE_DASH
#property indicator_style2  STYLE_DASH
#property indicator_style3  STYLE_DASH


#property indicator_color1  Blue
#property indicator_color2  Red
#property indicator_color3  Yellow


#property indicator_applied_price PRICE_OPEN
//--- input param

input int InChPeriod = 14; //Line Trend long
input int InChPeriod2 =7; //Line Trend short

int ExChPeriod,ExChPeriod2,rCount;
//---- buffers

double CentreBuffer[],HorisontBuffer[],ShortBuffer[];
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы - Документация по MQL5
Reason: