FORTS: To help beginners - page 7

 
TYRBO:
Anyone have any tips on the right way?
Is it too lazy to read the handbook?
 
TYRBO:
Anyone have any tips on how to do it right?

You are missing a stoplimit price in the request,

  double    stoplimit;        // Уровень StopLimit ордера

Use SRC to insert your code (the button at the top).

 
Sergey Chalyshev:

You are missing a stoplimit price in the request,

  double    stoplimit;        // Уровень StopLimit ордера

Insert the code via SRC (the button at the top).

You're wasting your time.

The man didn't even bother to look at the help...

 
prostotrader:

You're wasting your time.

The man didn't even bother to look at the certificate...

it's nice to be able to rub other people's noses in it
 
Sergey Chalyshev:

You are missing a stoplimit price in the request,

  double    stoplimit;        // Уровень StopLimit ордера

Insert the code via the SRC (button at the top).

Sergey thank you very much I got it
 
Sergey Chalyshev:

You are missing a stoplimit price in the request,

  double    stoplimit;        // Уровень StopLimit ордера

Use SRC (the button at the top) to insert your code.

interesting thing is in real world buy stop limit or sell stop limit is executed when you set it with F9 the price makes it market when it passes through, in tester this is a limit when the price passes through and executes when it returns to it i.e. is not a tester

Files:
1.JPG  147 kb
 

Hello, everyone.

I have this problem. When I turn on the glass, everything seems normal, but when some time passes it starts to behave inadequately, i.e. the chart flies up or down, then the price glass stops updating completely and until you close it and do not open it again it stays frozen. I do not know what to do. I do not know what to do.

 

Functions for obtaining the futures code

//-------------------------------------------------------------------+
// Split string function                                             |
//+------------------------------------------------------------------+
string SplitString(const string a_str, int &a_month, int &a_year)
{
 int str_size=StringLen(a_str);
 int str_tire=StringFind(a_str, "-");
 int str_tochka=StringFind(a_str, ".", str_tire);
 if((str_tire>0) && (str_tochka>0) &&(str_size > 0))
 {
   a_month= int(StringToInteger(StringSubstr(a_str,str_tire+1,str_tochka-str_tire-1)));
   a_year = int(StringToInteger(StringSubstr(a_str,str_tochka+1,str_size-str_tochka-1)));
   if((a_month > 0) && (a_year > 0)) return(StringSubstr(a_str, 0, str_tire));
  }
 return("");
}
//+------------------------------------------------------------------+
//| Expert Get prefix function                                       |
//+------------------------------------------------------------------+
string GetPrefix(const string a_name)
{
//-- indexes ---
  if(a_name == "MIX") return("MX"); else
  if(a_name == "MXI") return("MM"); else
  if(a_name == "RTS") return("RI"); else
  if(a_name == "RTSS") return("RS"); else
  if(a_name == "ALSI") return("4B"); else
  if(a_name == "RVI") return("VI"); else
//--- SPOT ---  
  if(a_name == "AFLT") return("AF"); else
  if(a_name == "ALRS") return("AL"); else
  if(a_name == "CHMF") return("CH"); else
  if(a_name == "FEES") return("FS"); else
  if(a_name == "GAZR") return("GZ"); else
  if(a_name == "GMKN") return("GK"); else
  if(a_name == "HYDR") return("HY"); else
  if(a_name == "LKOH") return("LK"); else
  if(a_name == "MGNT") return("MN"); else
  if(a_name == "MOEX") return("ME"); else
  if(a_name == "MTSI") return("MT"); else
  if(a_name == "NLMK") return("NM"); else
  if(a_name == "NOTK") return("NK"); else
  if(a_name == "ROSN") return("RN"); else
  if(a_name == "RTKM") return("RT"); else
  if(a_name == "SBPR") return("SP"); else
  if(a_name == "SBRF") return("SR"); else
  if(a_name == "SNGP") return("SG"); else
  if(a_name == "SNGR") return("SR"); else
  if(a_name == "TATN") return("TT"); else
  if(a_name == "TRNF") return("TN"); else
  if(a_name == "VTBR") return("VB"); else
  if(a_name == "MAGN") return("MG"); else
  if(a_name == "PLZL") return("PL"); else
  if(a_name == "YNDF") return("YN"); else
  if(a_name == "AFKS") return("AK"); else
  if(a_name == "IRAO") return("IR"); else
  if(a_name == "POLY") return("PO"); else
  if(a_name == "TCSI") return("TC"); else
  if(a_name == "FIVE") return("FV"); else
  if(a_name == "MAIL") return("ML"); else
  if(a_name == "GBMW") return("BW"); else
  if(a_name == "GDAI") return("DM"); else
  if(a_name == "GDBK") return("GB"); else
  if(a_name == "GSIE") return("SM"); else
  if(a_name == "GVW3") return("VM"); else
//--- procent ---  
  if(a_name == "OF10") return("OX"); else
  if(a_name == "OF15") return("OV"); else
  if(a_name == "OFZ2") return("O2"); else
  if(a_name == "OFZ4") return("O4"); else
  if(a_name == "OFZ6") return("O6"); else
  if(a_name == "MOPR") return("MP"); else
  if(a_name == "RUON") return("RR"); else
  if(a_name == "1MFR") return("MF"); else
  if(a_name == "1MDR") return("DF"); else
//--- currency ---  
  if(a_name == "AUDU") return("AU"); else
  if(a_name == "CY") return("CY"); else
  if(a_name == "ED") return("ED"); else
  if(a_name == "Eu") return("Eu"); else
  if(a_name == "GBPU") return("GU"); else
  if(a_name == "Si") return("Si"); else
  if(a_name == "UCAD") return("CA"); else
  if(a_name == "UCHF") return("CF"); else
  if(a_name == "UJPY") return("JP"); else
  if(a_name == "UTRY") return("TR"); else
  if(a_name == "UINR") return("IN"); else
  if(a_name == "UUAH") return("UU"); else
//--- commodity ---  
  if(a_name == "BR") return("BR"); else
  if(a_name == "CU") return("CU"); else
  if(a_name == "GOLD") return("GD"); else
  if(a_name == "PLD") return("PD"); else
  if(a_name == "PLT") return("PT"); else
  if(a_name == "SILV") return("SV"); else
  if(a_name == "SUGR") return("SA"); else
  if(a_name == "SLV") return("SL"); else
  if(a_name == "ALMN") return("AM"); else
  if(a_name == "CL") return("CL"); else
  if(a_name == "Co") return("Co"); else
  if(a_name == "GLD") return("GO"); else
  if(a_name == "Nl") return("Nl"); else
  if(a_name == "Zn") return("Zn"); else
  if(a_name == "NG") return("NG"); else
  if(a_name == "WH4") return("WH"); else return("");
}  
//+------------------------------------------------------------------+
//| Expert Get future code  function                                 |
//+------------------------------------------------------------------+
string GetFutCode(const string a_str)
{
  int a_month, a_year;
  string f_name = SplitString(a_str, a_month, a_year);
  if(StringLen(f_name) > 0)
  {
    string f_pref = GetPrefix(f_name);
    if(f_pref != "")
    {
      if(a_month !=0)
      {
        switch(int(a_month))
        {
          case 1:
            f_pref += "F"; 
          break;
          case 2:
            f_pref += "G"; 
          break;
          case 3:
            f_pref += "H"; 
          break;
          case 4:
            f_pref += "J"; 
          break;
          case 5:
            f_pref += "K"; 
          break;
          case 6:
            f_pref += "M"; 
          break;
          case 7:  
            f_pref += "N";
          break;  
          case 8:
            f_pref += "Q"; 
          break;
          case 9:
            f_pref += "U"; 
          break;
          case 10:
            f_pref += "V"; 
          break;
          case 11: 
            f_pref += "X";
          break;
          case 12:
            f_pref += "Z"; 
          break;
        }
        if(a_year != 0)
        {
          int res = a_year - int((double(a_year)/10)) * 10;
          return(f_pref += IntegerToString(res));
        }
      }
    }
  } 
  return("");
}

Using

string f_code = GetFutCode(Symbol());
 
Thank you so much!
 

If it's no secret, can you tell me how to close a position on FORTS?
I wrote a function to close a position, based on yours, but it's not working, inalid requesters.

There is not much information on this subject.

void ClosePosition(ulong& ord_ticket)
  {
   if(ord_ticket >  0)
     {
      if(PositionSelectByTicket(ord_ticket))
        {
         MqlTradeRequest request = {0};
         MqlTradeResult  result  = {0};
         //---
         request.action = TRADE_ACTION_CLOSE_BY;
         request.order  = ord_ticket;
         request.position = PositionGetInteger(POSITION_TICKET);
         request.position_by=PositionGetInteger(POSITION_TICKET)+1;
         request.magic=999999;
         request.volume=1;
         request.deviation = 100;
         request.symbol = _Symbol;
         request.type_filling = ORDER_FILLING_IOC;
         request.type_time = ORDER_TIME_DAY;
         //---
         if(OrderSend(request, result))
           {

            if(result.retcode == TRADE_RETCODE_PLACED)
              {
               ord_ticket = result.order;
              }
            else
              {
               Print("RemovePosition: Удаление старой позиции не выполнено! Билет = ", ord_ticket);
              }
           }
         else
           {
            Print("RemovePosition: Ордер не отослан! Билет = ", ord_ticket);
           }
        }
     }
  }
Reason: