[Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate oltre. Non potrei andare da nessuna parte senza di te - 2. - pagina 405

 
Некоторые ДЦ на реальных счетах именам символов присваивают всякие префиксы типа "." или "FXF".

Как мне подставлять эти префиксы?

Prova la stringa StringConcatenate(...)

 
Dimka-novitsek:

Capito, lo farò...

Inoltre, la condizione non funziona.

Non "non funziona", semplicemente non ci arriva per la stessa ragione di X

Questo può essere visto chiaramente dal fatto che non ci sono segnali da i in Alert

 
ilunga:

non "non funziona", semplicemente non ci arriva per la stessa ragione di X

questo può essere chiaramente visto dal fatto che non ci sono segnali da i in Alert


Sì, proprio così...
 
Urrà, dico!!!!!!
//+------------------------------------------------------------------+
//|                                                    для лавин.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
extern double stoploss=0; extern double takeprofit=20;extern int otstup=20; extern datetime expiration=0;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
 int tiket,tikett;double volume=0.1;int i=0,R1=0,R2=0,A=1 ;double price=PRICE_OPEN;
   //  R1=((PRICE_OPEN- stoploss*Point)*stoploss)/stoploss;R2=((PRICE_OPEN+ stoploss*Point)*stoploss)/stoploss;
     
     
int start()
  {       int X,Y; double price=(Ask+Bid)/2;            
//----
       Alert ("OrdersTotal()",OrdersTotal());


 for(int i=OrdersTotal();i>0;i--){Alert ("i", i);if(OrderSymbol()==Symbol()&&OrderMagicNumber( )==1000){
OrderSelect(i,SELECT_BY_POS );if(OrderType( )==OP_BUYSTOP){X++;}}}Alert ("X", X);
if (X==0){


   tiket= OrderSend( Symbol(), OP_BUYSTOP,  volume*A, price +otstup*Point, Point* 3, R1, price+takeprofit*Point+otstup*Point, "OP_BUYSTOP", 1000,  expiration, Red); 
   Alert ("OP_BUYSTOP", GetLastError( )); }
   

 for ( i=OrdersTotal();i>0;i--){Alert ("i", i); OrderSelect(i,SELECT_BY_POS );if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()) { 
if(OrderType( ) ==OP_SELLSTOP) { Y++;}}}Alert ("Y", Y);
 if (Y==0){ 
   tikett= OrderSend( Symbol(), OP_SELLSTOP,  volume*A, price -otstup*Point, Point* 3,R2, price-takeprofit*Point-otstup*Point, "OP_SELLSTOP" , 2000,  expiration,C'0,128,255' );
    Alert ("OP_SELLSTOP", GetLastError( )); 
    }       
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
ilunga:

Beh, l'opzione "al volo" ha funzionato:

Sì, è così che funziona. Grazie!
 
Uff!!! Urrà!!! Ce l'abbiamo fatta!!! Bene!!!
 

Buon pomeriggio. Questo è un problema, l'Expert Advisor che ho scritto si blocca dopo una certa quantità di tempo? Quando lo disinstallo, dice che si spegne per timeout. Qual è la ragione di questo?

//+------------------------------------------------------------------+
//|                                                      RSITest.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  int deal, cnt;
  double TotalProfit;
//----
   // Проверяем, сободен ли торговый поток
if (!IsTradeAllowed())
{
return(0);
}


if (OrdersTotal() == 0)
   {
      while(true)
      {
         //*********************************** Открываем Buy ордер  ***********************************
         if (iRSI(NULL,0,14,PRICE_CLOSE,0) > iRSI(NULL,0,14,PRICE_CLOSE,1))
         { 
            if (iRSI(NULL,0,14,PRICE_CLOSE,0) > 60 && iRSI(NULL,0,14,PRICE_CLOSE,1) < 60)
            {
               deal = OrderSend(Symbol(),OP_BUY,0.1,Ask,0,iLow(NULL,0,0)-20*Point,0,"Long EUR/USD",0,0,CLR_NONE);
               if (deal > 0) Print("Long");
               else Print(GetLastError());
               return(0);
            }
         }
         //*********************************** Открываем Sell ордер  **********************************
         if (iRSI(NULL,0,14,PRICE_CLOSE,0) < iRSI(NULL,0,14,PRICE_CLOSE,1))
         { 
            if (iRSI(NULL,0,14,PRICE_CLOSE,0) < 40 && iRSI(NULL,0,14,PRICE_CLOSE,1) > 40)
            {
               deal = OrderSend(Symbol(),OP_SELL,0.1,Bid,0,iHigh(NULL,0,0)+20*Point,0,"Short EUR/USD",0,0,CLR_NONE);
               if (deal > 0) Print("Short");
               else Print(GetLastError());
               return(0);
            }
         }
      }
   }      
//else
//if
   //{
   for (cnt=0;cnt<OrdersTotal();cnt++)
      {
      if (OrderSelect(cnt, SELECT_BY_POS)==true)
      {
         TotalProfit += OrderProfit();
         if (TotalProfit>=2 || iRSI(NULL,0,14,PRICE_CLOSE,0)<iRSI(NULL,0,14,PRICE_CLOSE,1))
         {
            if (OrderType()== OP_BUY)
            {         
               // Закрываем и отдыхаем 15 минут
               OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);
           //    Sleep(900000);
               return(0);
            }
         }
         if (TotalProfit>=2 || iRSI(NULL,0,14,PRICE_CLOSE,0)>iRSI(NULL,0,14,PRICE_CLOSE,1)) 
         {  
            if (OrderType()== OP_SELL)
            {     
               // Закрываем и отдыхаем 15 минут    
               OrderClose(OrderTicket(),OrderLots(),Ask,0,CLR_NONE);
           //    Sleep(900000);
               return(0);
            }
         }
      }
      }   
    //}


//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Rimuovere il ciclo while, è superfluo.
 
Grazie mille. Un'altra domanda, ho un timeframe di 15 minuti, diciamo che un ordine è stato chiuso a 18-38-55 come posso fare in modo che il mio EA non lavori fino a 18-45-00, cioè fino alla prossima barra?
 
Guardate https://www.mql5.com/ru/forum/133552 e vedete come la variabile Timebar è implementata nel vostro caso (con alcune modifiche).