[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 157

 

Friends, can you tell me what I need to do to output a 5-digit price? For example, I'm writing a case like this:

int Quant_Bars=15;

int Ind_max =ArrayMaximum(High,Quant_Bars,1);

double Maximum=High[Ind_max];

Alert("Максимум = ",Maximum);

And it prints out the price with four decimal places.

Thank you in advance))

 
rid >> :

And you put this function in which place of the code?

I'm in the early stages of writing my code... So there's nowhere to put it in....

Can you explain me childishly how to calculate the number of orders with magic number?))


 
Alex5757000 писал(а) >>

Friends, can you tell me what I need to do to output a 5-digit price? For example, I'm writing a case like this:

int Quant_Bars=15;

int Ind_max =ArrayMaximum(High,Quant_Bars,1);

double Maximum=High[Ind_max];

Alert("Максимум = ",Maximum);

And it prints out the price with four decimal places.

Thank you in advance))

Have you tried DoubleToStr()?

 
ArtY0m писал(а) >>

I'm in the early stages of writing my code... So there's nowhere to put it in....

Can you explain me childishly how to calculate the number of orders with magic number?))


The easiest way is to look here https://book.mql4.com/ru/

 

Please help me. I don't understand a damn thing.

If during the visual testing of the EA 1.mq4 (attached) I put a 3-cci indicator (attached) on the chart, then, as it seems, with exactly the same parameters of calculated cci signals of the indicator and the actual cci (object text in the upper right corner) do not coincide.

WHY?

And for some reason the alerts in this indicator don't work.

Files:
pack_1.rar  2 kb
 
I can't find a reference to an indicator that draws a high timeframe candle on a low timeframe chart (i.e. both candles at the same time). Who can tell me?
 
ArtY0m >> :

I'm in the early stages of writing my code... So there's nowhere to put it in....

Can you explain me childishly how to calculate the number of orders with magic number?)


An Expert Advisor (in its simplest form) consists of several parts.

First, the external parameters and global variables are set.

After that, the initialize and deinitialize functions usually come.

After that, the START function is executed, in which the main working algorithm of the Expert Advisor is set.

Second, the auxiliary, user-defined functions come next.

These user-defined functions are used (called) in the START function as required.

Here is something like this:

//+------------------------------------------------------------------+
//|                                                    ZZ expert.mq4 |
//|                                        Copyright © 2008, Rid     |
//|                                            Rid                   |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Rid ."
#property link      "Rid "

extern string     _  = "---- ОБЩИЕ ПАРАМЕТРЫ -----"; 
extern int       MAGIC = 777;
extern double    lots=0.1;

extern string     __  = "---- ПАРАМЕТРЫ BUY -----"; 
extern int       StopLossBuy=110;
extern int       TakeProfitBuy=55;

extern string     ___  = "---- ПАРАМЕТРЫ SELL -----"; 
extern int       StopLossSell=110;
extern int       TakeProfitSell=55;

extern string    _____= "Параметры функции ТРЕЙЛИНГ СТОП";
extern bool   UseTrailing = true;//Выключатель трейлинг стопа
extern int    MinProfit = 25;    //порог включения трейлин стопа
extern int    TrailingStop = 25;// величина трейлинг стопа
extern int    TrailingStep = 5; // шаг трейлинг стопа


int ticket;
bool  gbDisabled  = False;             // Флаг блокировки советника
bool  gbNoInit    = False;             // Флаг неудачной инициализации
//-- Подключаемые модули --
#include <stderror.mqh>
#include <stdlib.mqh>

//+------------------------------------------------------------------+
//| initialization function                                          |
//+------------------------------------------------------------------+
int init()
  {
gbNoInit= False;  
if (!IsTradeAllowed()) {
    Message("Для нормальной работы советника необходимо\n"+
            "Разрешить советнику торговать");
    gbNoInit= True; return;
  }
  if (!IsLibrariesAllowed()) {
    Message("Для нормальной работы советника необходимо\n"+
            "Разрешить импорт из внешних экспертов");
    gbNoInit= True; return;
  }
  }

//жжжжжжжжжжжжж ФУНКЦИЯ СТАРТ жжжжжжжжжжжжжжжжжж+

int start()
  {
//Отображаем на графике число открытых позиций
// с задааным магиком "MAGIC"
Comment("Число бай позиций = ", NumberOfPositions(NULL,OP_BUY, MAGIC), "\n",
"Число селл позиций = ", NumberOfPositions(NULL,OP_SELL, MAGIC),"\n",
"Хи-Хи, тра-ля-ля");

if ( UseTrailing) TrailPositions(); // выключатель трейлинг стопа 
  
//-------- открываем позиции 
if ( NumberOfPositions(NULL, OP_BUY, MAGIC)< 1){//если нет открытыз бай-поз
//открываем позицию бай:
ticket=OrderSend(Symbol(),OP_BUY, lots,Ask,3,Ask-Point* StopLossBuy,
Ask+Point* TakeProfitBuy,"Хи-Хи, тра-ля-ля", MAGIC,0,Blue);
                                             } 
//--------------------------------------------------------------
    return(0);//конец функции int start()
  }
//жжжжжжжжжжж КОНЕЦ ФУНКЦИИ СТАРТ жжжжжжжжжжжжжжжж+


//жжжжжжж ПОЛЬЗОВАТЕЛЬСКИЕ ФУНКЦИИ жжжжжжжжжжжжжжж+
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает количество позиций.                                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
int NumberOfPositions(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), kp=0;

  if ( sy=="0") sy=Symbol();
  for ( i=0; i< k; i++)                                    {
    if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES))      {
      if (OrderSymbol()== sy || sy=="")                   {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if ( op<0 || OrderType()== op)                   {
            if ( mn<0 || OrderMagicNumber()== mn) kp++;
          }}}}}  return( kp);}

//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж+
void TrailPositions() // функция трейлинг стоп
{
  int Orders = OrdersTotal();
  for (int i=0; i< Orders; i++) {
    if (!(OrderSelect( i, SELECT_BY_POS, MODE_TRADES))) continue;
    if (OrderSymbol() != Symbol()) continue;    
     if (OrderType() == OP_BUY && OrderMagicNumber()== MAGIC)  {
      if (Bid-OrderOpenPrice() > MinProfit*Point) {
        if (OrderStopLoss() < Bid-( TrailingStop+ TrailingStep-1)*Point) {
          OrderModify(OrderTicket(), OrderOpenPrice(), Bid- TrailingStop*Point,
                                                     OrderTakeProfit(), 0, Blue);
        } } }
    if (OrderType() == OP_SELL && OrderMagicNumber()== MAGIC)  {
      if (OrderOpenPrice()-Ask > MinProfit*Point) {
        if (OrderStopLoss() > Ask+( TrailingStop+ TrailingStep-1)*Point 
                                                       || OrderStopLoss() == 0) {
          OrderModify(OrderTicket(), OrderOpenPrice(), Ask+ TrailingStop*Point,
                                                      OrderTakeProfit(), 0, Blue);
        } } }      } }

//+----------------------------------------------------------------------------+
//|  Вывод сообщения в коммент и в журнал                                      |
//+----------------------------------------------------------------------------+
void Message(string m) {
  Comment( m);
  if (StringLen( m)>0) Print( m);
}        

I hope you don't have any questions like this now!

 

One more question: is it possible to place a pending order from an open position, not from the current price?

Thanks in advance)

 

Of course you can. We only need to make sure that this pending order is placed at such a distance from the current price so as to meet the Stop Levels set by brokerage companies.

For example, if a pending order is placed 100 pips away from the last order opening price, but it gets too close to the current price, the log will return an error 130 to open the order.

 
rid >> :

You can do it of course. We only need to make sure that this pending order is placed at such a distance from the current price so as to meet the Stop Levels set by brokerage companies.

For example, if the order is set at the distance of 100 points from the last position opening price, but it gets too close to the current price, the log will return an error 130 to open the order.

How, if it's not a secret?