Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1908

 
novichok2018 #:

The platform does not allow the installation of two EAs on the same chart. You probably need an indicator.

So what's the problem, open any chart and install an EA.

Just call the function with the right parameters symbol, magik.

Or copy it into your EA, is the code of EA 2 open?

 


novichok2018 #
:

Maybe it sees them, I haven't read the EA code, but maybe it only sees what is reflected on the chart where it is installed. And the Take Profit, Stop Loss and Open Price lines are displayed, but there is no open time. Therefore, I think that if EA #2 only sees what is shown on its chart, it will not be able to read information correctly from EA #1. Hence my desire to reflect on his chart all the information about the position opened by EA #1: price, open time and stops.

No, it is not.

The EA can see everything, on all open charts, and any symbols.

 

Good afternoon, all. Added an extension to the template name in the scripts. The scripts now look like this.

First for d1 and medium term.

//+------------------------------------------------------------------+
//|                                               D1_AND_SHABLON.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright " КОПИЯ 1 "
#property link      "https://vk.com/danila_mastep"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
string tplName = "FIBOmAGIC СРЕДНЕСРОК.tpl";
void OnStart()
 {
  long prevChart = ChartFirst();
  while(prevChart >= 0 && IsStopped())
   {
    if(ChartPeriod(prevChart) != PERIOD_D1)
      ChartSetSymbolPeriod(prevChart, ChartSymbol(prevChart), PERIOD_D1);
      ChartApplyTemplate(prevChart, tplName);
    prevChart = ChartNext(prevChart);
   }
 }/******************************************************************/
/*****************************End program****************************/

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+


For n1 and scalping this is how it looks like.

//+------------------------------------------------------------------+
//|                                               H1_AND_SHABLON.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright " КОПИЯ 1"
#property link      "https://vk.com/danila_mastep"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
string tplName = "FIBOmAGIC СКАЛЬПИНГ.tpl";
void OnStart()
 {
  long prevChart = ChartFirst();
  while(prevChart >= 0 && IsStopped())
   {
    if(ChartPeriod(prevChart) != PERIOD_H1)
      ChartSetSymbolPeriod(prevChart, ChartSymbol(prevChart), PERIOD_H1);
      ChartApplyTemplate(prevChart, tplName);
    prevChart = ChartNext(prevChart);
   }
 }/******************************************************************/
/*****************************End program****************************/

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+


The terminal still has 7 open charts, the screenshot below.

7 open charts with scalping pattern on all

I have moved the script for d1 and the mid-term chart template to the chart, but nothing happens, as before. I have tried to drag and drop it on the leftmost chart and on the rightmost one, nothing happens. I thought it was because I had saved everything in Scripts/ SCRIPT OF APPLYING THE SHABLET TO ALL CHARTS. I moved the files to the Scripts folder - compiled, I'm adding them again and nothing happens. What could be the problem?

 
DanilaMactep #:

Good afternoon, all. Added an extension to the template name in the scripts. The scripts now look like this.

First for d1 and medium term.


For n1 and scalping this is how it looks like.


The terminal still has 7 open charts, the screenshot below.

I have moved the script for d1 and the mid-term chart template to the chart, but nothing happens, as before. I have tried to drag and drop it on the leftmost chart and on the rightmost one, nothing happens. I thought it was because I had saved everything in Scripts/ SCRIPT OF APPLYING THE SHABLET TO ALL CHARTS. I copied the files to the folder Scripts-compiled, then I put them back and nothing happens. What could be the problem?

Do you know how to use debugging? Go step by step and see where the script is not correctly executed.

Отладка кода - Разработка программ - Справка по MetaEditor
Отладка кода - Разработка программ - Справка по MetaEditor
  • www.metatrader5.com
В MetaEditor встроен отладчик — инструмент, который позволяет проверить работу программы по шагам (по отдельным функциям). Вы расставляете в коде...
 
Tretyakov Rostyslav #:

Just to be clear...

Lines of set orders are not objects on the chart and no EA can count order lines

We can see that we have an order but there are no objects on the chart


You have been convinced. Thank you.

 
Alekseu Fedotov #:

No, it isn't.

The EA can see everything, on all open charts, and any symbols.

Thank you, got it.

 
Alexey Viktorov #:

Do you know how to use the debugger? Go step by step and see where the script is going wrong.

I've never dealt with a debugger - I'll try to figure it out, but it's unlikely with my eyesight :-(
 

Good afternoon!!!!

Here is the Profit calculation function for a grid of orders

//+----------------------------------------------------------------------------+
//| Калькуляция сетки ордеров                                                  |
//+----------------------------------------------------------------------------+
double CalculiteProfit()
  {
   double oProfit = 0;
   for(int i = OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
           {
            if(OrderType() == OP_BUY || OrderType() == OP_SELL)
              {
               oProfit += OrderProfit();
              }
           }
        }
     }
   return(oProfit);
  }

Can you please tell us if you can calculate separately

Calculation of orders with profit

Calculate orders with a loss

Thank you

 
EVGENII SHELIPOV #:

Good afternoon!!!!

Here is the order grid profit calculation function

Can you please tell us if you can calculate separately

Calculation of orders with profit

Calculate orders with a loss

Thank you

You may do it.

 
Maxim Kuznetsov #:

You may, you may.

You're an ostyak??????

Reason: