Can I limit positions for Multi Symbols ?

 

#include <Trade\Trade.mqh>
CTrade trade;


input double kaldirac =0.1;
input ulong mn =0;

void OnTick()
  {
   trade.SetExpertMagicNumber(mn);
   double ADXArray14[];
   double RSIArray14[];
   double DIPlus[];
   double DIMinus[];
   
   int ADX20 = iADX(_Symbol,_Period,14);
   int RSI20 = iRSI(_Symbol,_Period,14,PRICE_CLOSE);
   int time = PeriodSeconds()*1000;
   
   ArraySetAsSeries(ADXArray14,true);
   ArraySetAsSeries(RSIArray14,true);
   ArraySetAsSeries(DIMinus,true);
   ArraySetAsSeries(DIPlus,true);
  
   
   CopyBuffer(ADX20,0,0,14,ADXArray14);
   CopyBuffer(ADX20,1,0,14,DIPlus);
   CopyBuffer(ADX20,2,0,14,DIMinus);
   CopyBuffer(RSI20,0,0,14,RSIArray14);
   
   
   double ADXval = NormalizeDouble(ADXArray14[0],1);
   double RSIval = NormalizeDouble(RSIArray14[0],1);
   double DIPval = NormalizeDouble(DIPlus[0],1);
   double DIMval = NormalizeDouble(DIMinus[0],1);
   
  
   Comment("ADX Değeri: ", ADXval," ","RSI Değeri: ", RSIval," ","+DI değeri: ", DIPval," ","-DI Değeri: ", DIMval);
   
    if(DIPval>DIMval && ADXval>20 && RSIval>50 && PositionsTotal() <= 0)
   {
   double ask = SymbolInfoDouble(NULL,SYMBOL_ASK);
   trade.Buy(kaldirac,NULL,ask,0,0,"BUY");
   Sleep(60000);
 
   } 
   
   else if(DIPval<DIMval && ADXval>20 && RSIval<50 && PositionsTotal() <= 0)
   {
   double bid = SymbolInfoDouble(NULL,SYMBOL_BID);
   trade.Sell(kaldirac,NULL,bid,0,0,"SELL");
   Sleep(60000);

   } 
   
   else 
 
   {
   if(DIPval > DIMval && PositionGetInteger(POSITION_TYPE)==1)
   {ulong ticket = PositionGetTicket(PositionsTotal()-1);
   PositionSelectByTicket(ticket);
   trade.PositionClose(ticket);}
   
   if(DIPval < DIMval && PositionGetInteger(POSITION_TYPE)==0){
   {ulong ticket = PositionGetTicket(PositionsTotal()-1);
   PositionSelectByTicket(ticket);
   trade.PositionClose(ticket);}
   }
   
   }
   
   }

Hello, I'm trying to use my EA on multiple Symbols with limiting positions by 1 for every of them, like 1 position for EURUSD, 1 position for XAUUSD (as much as I use my EA)...


I'm just having a problem about limiting positions for symbols can anyone help me to understand what can I do ?

 
  1. Find if you have an open position for the given symbol.

  2. You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help 2017.04.21

 
William Roeder:
  1. Find if you have an open position for the given symbol.

  2. You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help 2017.04.21

which part of my code should I add here sir?
 
Talha Baran #:
which part of my code should I add here sir?

Could you find any solutions?

 
Talha Baran #: which part of my code should I add here sir?

None. You have to add code that fixes the problem.

Reason: