[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 548

 
gheka:

The MA is used in the EA, I need it for visualisation as well.

If you do not know when to open and close the order, then I want to be able to see it on the chart and know when the order triggers

Then the library will help. But it will only help with loading the indicator from the EA. The calculations are up to you as you do them.

See the library section " 7. FUNCTIONS FOR CONTROLLING MQL4 PROGRAMS".

 
Zhunko:

Then the library will help. But it will only help with loading the indicator from the Expert Advisor. You can do the calculations on your own.

See the library section " 7. FUNCTIONS FOR CONTROLLING MQL4 PROGRAMS".



404

The page you requested was not found

Try to use the search or find the information you need in one of the sections of MQL4.com

 

I wanted to consolidate the issue with the transfer of parameters from the link.

To write a simple expert so to speak.

//+------------------------------------------------------------------+
//|                                                        links.mq4 |
//|                                                              hoz |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "hoz"
#property link      ""

double firstBarClosed,
       secondsBarClosed;
       
int a = 1;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+-------------------------------------------------------------------------------------+
//| Получение цены установки отложенного ордера                                         |
//+-------------------------------------------------------------------------------------+
double GetPriceToInput()
{ 
  double firstBarClosed = iClose(Symbol(),1440,2);                          // Цена закрытия предпоследнего дня
  double secondBarClosed = iClose(Symbol(),1440,1);                         // Цена закрытия последнего дня
  
  if(firstBarClosed > secondBarClosed)                                      // Если закрытие вчерашнего дня ниже закрытия предыдущего..
  {                                                                         //.. (линия по ценам закрытий направлена вниз), то..
    double deltaForSell = (firstBarClosed - secondBarClosed)/2;             // Находим дельту изменения цены до 12 часов текущего дня
    double priceForSell = secondBarClosed - deltaForSell;                   // Вычисляем цену продажи
    return(priceForSell);
  }

  if(firstBarClosed < secondBarClosed)                                      // Если закрытие предыдущего днях ниже закрытия вчерашнего..
  {                                                                         //..(линия по ценам закрытий направлена вверх), то..
    double deltaForBuy = (secondBarClosed - firstBarClosed)/2;              // Находим дельту изменения цены до 12 часов текущего дня
    double priceForBuy = secondBarClosed + deltaForBuy;                     // Вычисляем цену покупки
    return(priceForBuy);
  }
}

void Test(double& a, double& b)
      {
         Print("firstBarClosed = ", firstBarClosed);
         Print("secondsBarClosed = ", secondsBarClosed);
      }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
   GetPriceToInput();
   
   if(a > 0)
   {
     Test(firstBarClosed, secondsBarClosed);
   }

   return(0);
}
//+------------------------------------------------------------------+

In the log, 0 is constantly being output. Why?

On the line:

void Test(double& a, double& b)

I didn't put "firstBarClosed" and "secondBarClosed" because these are formal parameters. This is already in the start function

if(a > 0)
   {
     Test(firstBarClosed, secondsBarClosed);
   }
 
kolospav:

New account made for metatrader! money loaded from Market trader! on the website in the account statement - there is money. I don't understand it at all. technical support is also in a stupor... Trying to understand it myself!


Some DCs require a copy of your passport or something similar... Try to open a demo account for the sake of interest.
 
gheka:


404

The page you requested was not found

Try to use the search or find the information you need in one of the sections of MQL4.com

Fixed the link. You should have figured it out yourself. It was a private link. You should have removed my.
 
Zhunko:
Corrected the link. You could have figured it out on your own. It was private. You should have removed my.


Thanks to .
 
gheka:

how to make an indicator on a chart (line) in an EA

If you will run in the tester and check "Visualisation", the MA will automatically be displayed.
If you need to watch in the current mode, just put the MA on the chart with the parameters you have in the EA. They will not relate to each other, but it will be obvious
 
Arles:

Can you give me a hint? I am writing lines like this:

I want High to be counted by MA, not by price. This code doesn't work. I need something similar to iMAOnArray, only iHIGHOnArray. But as far as I know, there is no such thing. Help...


The question is not quite clear: "I want High not to be counted by price". High[] is a predefined value, we can't change it, maybe we want MA by price High ?
 
pu6ka:

The question is not quite clear: "I want High not to be counted by price". High[] is a predefined value, we can't change it. Maybe we want MA by price High ?


No, we want to know the maximum value of the MA itself for the period.
 
Arles:

No, you need to know the maximum value of the MA itself over the period.
Now I see. Most likely, we have to create an array for MA values and then a second array to store the max values, or a variable if only the last max value is needed.
Reason: