Questions from Beginners MQL5 MT5 MetaTrader 5 - page 944

 
eflaer:

Hello, Could you please advise me if I set my EA to, for example, 10 currency pairs?

Can you set the maximum number of pairs on which you can open?

In other words, if advisor is set on 10 charts of different pairs and in the settings it is said that the maximum number of pairs - 5.

And the EA will work only on the first 5 pairs and the other 5 pairs will be ignored?

In general, it is possible?

If the code is in .mq format, then it is possible. Not to be confused with .ex

 

Good day to all
I have the following question, I would like to ask you for some help in clarifying the situation.

The robot netmaker places a grid of limit orders ORDER_TYPE_BUY_LIMIT(also ORDER_TYPE_BUY_STOP upwards) at startup. The grid step is 1, take 0.5, and volume is 1 lot. The problem is that I am starting to open a long position once (I bought at 10 and set the TP at 10.5) without taking the position, and then I am starting the second time (I bought at 9 and set the TP at 9.5) and I have 2 lots. Then the price starts to come in and all the volume is taken to 9.5!

Orders are placed by the structure.

      MqlTradeRequest request_={0};
      request_.action=TRADE_ACTION_PENDING;         // установка отложенного ордера 
      request_.magic=order_magic;                  // ORDER_MAGIC 
      request_.symbol=pair;                      // инструмент 
      request_.volume=v_b;                          // объем в 0.1 лот 
      request_.tp=pr_ent_tp;                                // Take Profit 
      //--- сформируем тип ордера 
      request_.type=ORDER_TYPE_BUY_LIMIT;                // тип ордера 
      //---сформируем цену для отложенного ордера 
      request_.price=pr_ent;  // цена для открытия 
      //--- отправим торговый приказ 
      MqlTradeResult result_={0};
      m_Trade.OrderSend(request_,result_);

I need every order to be at one of my own tees. I entered at 10 and waited for a price of 10.5.
And not the entire volume at the first tee.

I should adjust something with the structure?

 
ISL:

Good day to all
I have this question and I need your help in clarifying the situation.

The robot netmaker places a grid of limit orders ORDER_TYPE_BUY_LIMIT(also ORDER_TYPE_BUY_STOP upwards) at startup. The grid step is 1, take 0.5, and volume is 1 lot. The problem is that I am starting to open a long position once (I bought at 10 and set the TP at 10.5) without taking the position, and then I am starting the second time (I bought at 9 and set the TP at 9.5) and I have 2 lots. Then the price starts to come in and all the volume is taken to 9.5!

Orders are placed by the structure.

I need everyone to take out at their own tees. I entered at 10 and waited for the price of 10.5.
And not the entire volume at the first tee.

Do you need to fix something with the structure?

Use "Hedge" account type, not "Netting".

 
To change it, you have to re-MT and tick the box, Use hedge. Or can I change the existing one?
 
ISL:
To change it, you have to re-MT and tick the box, Use hedge. Or can I change the existing one?

Redo it and tick the box ...

 
Thank you!
 
Again with the same question, has anyone implemented such a takeout system for aNetting account? Maybe there is someone on the forum who has done this?
 
ISL:
I am asking the same question again, has anyone implemented such a system of TPs forNetting accounts? Maybe there is someone on the forum who has done it?

Forum on trading, automated trading systems and strategy testing

Libraries: Virtual

fxsaber, 2018.11.15 17:16

On Netting a position always has only one TP. So in particular netting TSs where each order in the netting has a different TP will not work as intended.

Below is an example of how it works.

// Пример Netting с поддержкой множества однонаправленных позиций (у каждой могут быть свои Magic, SL/TP, Comment, OpenTime и т.д.).
// Запустите этот пример на Netting-счете в Тестере с влюченной Визуализацией.

#include <MT4Orders.mqh> // https://www.mql5.com/ru/code/16006

#define  VIRTUAL_LIMITS_TP_SLIPPAGE // Лимитники и TP исполняются по первой цене акцепта - положительные проскальзывания
#include <fxsaber\Virtual\Virtual.mqh> // https://www.mql5.com/ru/code/22577
#include <fxsaber\Virtual\Sync.mqh>    // Синхронизатор

#define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

input int iAmount = 5;   // Количество ордеров в сетке
input int iOffset = 120; // На каком расстоянии (в пипсах) ставить ордера сетки
input int iTP = 120;     // TakeProfit каждого ордера сетки

// Выставляем один раз сетку из Amount ордеров на Offset-расстоянии друг от друга с заданным TP.
void System( const int Amount, const int Offset, const int TP )
{
  static bool FirstRun = true;
  
  if (FirstRun)  
  {
    for (int i = 1; i <= Amount; i++)
    {
      const double PriceOpen = Ask - i * Offset * _Point;
      const double PriceTP = PriceOpen + TP * _Point;
      
      OrderSend(_Symbol, OP_BUYLIMIT, 1, PriceOpen, 0, 0, PriceTP, (string)i); // Выставляем каждый ордер сетки
    }
    
    FirstRun = false;
  }
}

void OnTick()
{  
  static const bool Init = VIRTUAL::Select(VIRTUAL::Create()); // Система будет работать в этом виртуальном окружении
  static const bool IsVisual = MQLInfoInteger(MQL_VISUAL_MODE);
  static bool FirstRun = true;

  VIRTUAL::NewTick();            // Добавили тик в виртуальное торговое окружение
  System(iAmount, iOffset, iTP); // Запустили ТС на выбранном торговом окружении (виртуальное)
  
  SYNC::Positions<ISTIME>(); // Синхронизировли реальное торговое окружение с виртуальным

  if (IsVisual)
    Comment(VIRTUAL::ToString(true)); // Вывели на чарт состояние виртуального торгового окружения (true - вместе с историей торгов)
}


This is a very simple idea. We launch TS in a virtual one and simply synchronize it in the real one. You don't need to change the TP source (System function in the example).

 

Afternoon. I wanted to make an mqh file where the calculated arrays will lie until I close the terminal and re-download them only when there is a big time gap (3600 in my case). But if I compile the indicator, the mqh file also resets all arrays. How can I do it, so I can do everything with indicator and compile it, but mqh file is not reset until the terminal is closed?

class CMyTicks
  {
protected:
   int               countTicks;

public:
   datetime          m_TickTime[];
   datetime          m_FirstTickTime;
   //+------------------------------------------------------------------+
   //| Constructor.                                                     |
   //+------------------------------------------------------------------+      
   void CMyTicks()
     {
      countTicks=0;
     }
   //+------------------------------------------------------------------+  
   void CollectTicks(int m_getticks=1000)
     {
      MqlTick           items[];
      int received=CopyTicks(_Symbol,items,COPY_TICKS_ALL,0,m_getticks);
      
      ...
      m_FirstTickTime=items[0].time;
     }
  };
//+------------------------------------------------------------------+
#include <Test_Array_Include.mqh>
CMyTicks  Test;
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   ReloadAsk();
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
int      getticks=100000;
datetime firstticktime=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ReloadAsk()
  {
   MqlTick           items[];
   int received=CopyTicks(_Symbol,items,COPY_TICKS_ALL,0,getticks);
   firstticktime=items[0].time;

   if((int)firstticktime>(int)Test.m_FirstTickTime+3600)
     {
      Test.CollectTicks(getticks);
      int ArrSize=ArraySize(Test.m_TickTime);
      Print(" Should not apear after compilation. ArrSize: ",ArrSize); // 
     }
  }
//+------------------------------------------------------------------+
 
Please block the account for one month.
Reason: