How to run script with prefix and suffix pair?

 

Hello, can someone help me?

I'm newbie on mql programming, how to run script with prefix and suffix pair?
This script has been run successfully on basic pair ( no prefix and suffix). Thank you

#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

input bool UseCloseBy = false;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   QnClose();
  }
//+------------------------------------------------------------------+

void QnClose()
{
   if(!OrderSelect(OrdersTotal()-1,SELECT_BY_POS)) return;
   double OCP = OrderClosePrice();
   int    OTK = OrderTicket();
   
   if(UseCloseBy){
   //closed order by hedging
   int    OTY = OrderType();
   double OLT = OrderLots();
   string OSY = OrderSymbol();
   int    CBT = 0;
   double CBP = 0;
   int    CBC = -1;
   string CBN = "Fake Spread";
   bool   CBR = false;
   
   if(OTY>1) return;
   if(OTY==0) {
      CBP = MarketInfo(OSY,MODE_BID);
      CBC = 1;
      CBT = OrderSend(OSY,CBC,OLT,CBP,0,0,0,CBN);
   }
   if(OTY==1) {
      CBP = MarketInfo(OSY,MODE_ASK);
      CBC = 0;
      CBT = OrderSend(OSY,CBC,OLT,CBP,0,0,0,CBN);
   }
   if(CBT>0) {
      Sleep(2000);
      int try = 10;
      while(try>0) {
         try--;
         CBR = OrderCloseBy(OTK,CBT);
         if(CBR) break;
         Sleep(500);
      }
   }
   if(!CBR) {
      Alert("Gagal Close By. Err: ",GetLastError());
      return;
   }
   
   } else {
   bool  rCls= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0);
   if(!rCls) {
      Alert("Gagal Close. Err: ",GetLastError());
      return;
   }//*/
   }
   if(!OrderSelect(OTK,SELECT_BY_TICKET,MODE_HISTORY)){
      Alert("Gagal check history close. Err: ",GetLastError());
      return;
   }
   double OCPH = OrderClosePrice();
   int    Gap = 0;
   if(OrderType()%2==0){
      Gap = int((OCPH-OCP)/MarketInfo(OrderSymbol(),MODE_POINT));
   } else {
      Gap = int((OCP-OCPH)/MarketInfo(OrderSymbol(),MODE_POINT));
   }
   Alert("spread added: ",Gap);
}
   
   
      
   
 
spirit:

Hello, can someone help me?

I'm newbie on mql programming, how to run script with prefix and suffix pair?
This script has been run successfully on basic pair ( no prefix and suffix). Thank you

I don't think this script needs to take into account prefixes and suffixes, what's the problem?

 
  1. You already have the OrderSymbol. What more do you need?

  2. if(!OrderSelect(OrdersTotal()-1,SELECT_BY_POS)) return;
    This selects the most recent order. Not the order on the current chart.
 
 
Ahmet Metin Yilmaz:
use StringSubstr

Why?

 
To determine prefix and suffix.
 
Ahmet Metin Yilmaz:
To determine prefix and suffix.

I don't see how you can do that withStringSubstr().

 
Keith Watford:

I don't see how you can do that withStringSubstr().

Use Symbol () as the string value and decide from which pos to read it from.

 
Ahmet Metin Yilmaz:

Use Symbol () as the string value and decide from which pos to read it from.

That's what I don't understand. How do you decide which position to read from?

Yes, it is easy to know for a prefix as that will be 0, but how do you determine...

a. Is there a prefix?

b. The length of the prefix?

For a suffix, how do you determine...

a. Is there a suffix?

b. The start position of the suffix?

 
Keith Watford:

That's what I don't understand. How do you decide which position to read from?

Yes, it is easy to know for a prefix as that will be 0, but how do you determine...

a. Is there a prefix?

b. The length of the prefix?

For a suffix, how do you determine...

a. Is there a suffix?

b. The start position of the suffix?

I never tried for prefix but you can find to suffix easily ( if there )

if there is no suffix it returns nothing

 
Ahmet Metin Yilmaz:

I never tried for prefix but you can find to suffix easily ( if there )

if there is no suffix it returns nothing

Ok, so it is not possible for a prefix then.

I still don't understand....

For a suffix, how do you determine...

a. Is there a suffix?

b. The start position of the suffix?