Need help to convert the code into MT4

 

Hello,

I want to print the list of symbols having open orders buy,sell and pending orders. I have a MT5 version of code but could not make it working in MT4.

Would very much appreciate if you can help me to convert this code into MT4 version.

Thanks.

string SyMass[];
bool Find(string aSymbol)
{
int arr = ArraySize(SyMass);
for(int i = 0; i < arr; i++)
if(SyMass[i] == aSymbol)
return false;
if(ArrayResize(SyMass, arr + 1) != -1)
SyMass[arr] = aSymbol;
return true;
}
bool FillSymbols(void)
{
int TotalPositions=PositionsTotal()-1;
for(int i = TotalPositions; i >= 0; i--)
if(Find(PositionGetSymbol(i)) == false)
{
}
int arr = ArraySize(SyMass);
for(int f = 0; f < arr; f++)
{
Print(SyMass[f]);
}
return(true);
}
 
Dilchan B M: I want to print the list of symbols having open orders buy,sell and pending orders. I have a MT5 version of code but could not make it working in MT4. Would very much appreciate if you can help me to convert this code into MT4 version.

You should start by reading the MQL4 documentation, especially the trade functions, as it is completely different to MQL5 (e.g. instead of "PositionsTotal", use OrdersTotal).

However, you will have to change the logic of your code, because MT4 handles things differently from MT5.

 
Dilchan B M:

Hello,

I want to print the list of symbols having open orders buy,sell and pending orders. I have a MT5 version of code but could not make it working in MT4.

Would very much appreciate if you can help me to convert this code into MT4 version.

Thanks.

//+------------------------------------------------------------------+
//|                                       Haskayafxstubborn goat.mq4 |
//|                                 Copyright 2019, Haskaya Software |
//|                                   https://www.haskayayazilim.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, Haskaya Software"
#property link      "https://www.haskayayazilim.net"
#property version   "1.00"
#property strict

#include <Arrays\ArrayString.mqh>

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class IntegerSet : public CArrayString
  {
public:
   bool              Add(const string element)
     {
      if(this.SearchLinear(element) < 0)
         return CArrayString::Add(element);
      return false;
     }
  };
void OnTick()
  {

 MarketEmirKontrol();
 ExpertRemove();
 }

void MarketEmirKontrol()
  {
   IntegerSet MarketEmirler;
   
   for(int i=OrdersTotal()-1; i>=0; --i)
     {
      if(OrderSelect(i, SELECT_BY_POS))
        {
         
            MarketEmirler.Add(OrderSymbol());
         
        }
     }
   for(int i=MarketEmirler.Total()-1; i>=0; --i)
     {
        Print(MarketEmirler.At(i));
       //SorgulananEmirler=MarketEmirler.SearchLinear(BekleyenEmirler.At(i));
       //Print(SorgulananEmirler," ",BekleyenEmirler.At(i));
           }

  }


https://www.mql5.com/en/forum/370952#comment_22807855

@ Dilchan B M

How To Distinct OrderSymbol() In MQL4
How To Distinct OrderSymbol() In MQL4
  • 2021.06.09
  • www.mql5.com
How to distinct OrderSymbol() in MQL4? I have data: Symbol | Type | Size GBPUSD | Buy | 1.5 GBPUSD | Buy | 0...
 

Thank You!

 

How can we achieve same in MT5?

 
Dilchan B M:

How can we achieve same in MT5?

This is the MT4 section.

Please don't confuse issues by asking about MT5.

Reason: