[Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate. Non posso andare da nessuna parte senza di te. - pagina 414

 
costy_ >>:

Grazie! Ne ho trovati altri qui, forse qualcuno ne avrà bisogno. Andare a finire il graal:)

 
costy_ >>:

Если массив double а нужен int? Я правильно понял?

No. Sto scrivendo il collegamento di MT4 ad altre applicazioni tramite socket. La funzione Socket restituisce un array di int:

extern "C" __declspec ( dllexport ) int* CALLBACK SendInfoBySocket(int* MessageStr, int MessageLength,int PORT);

Importo questa dll in EA. Tuttavia, per chiamare questa funzione, deve essere dichiarata nell'Expert Advisor:

int SendInfoBySocket(int str[], int len,int port);

La dichiarazione di cui sopra molto probabilmente non è corretta - una dll-option restituisce un array, mentre una funzione dichiarata in un Expert Advisor restituirà un singolo int.

Come dichiararlo in un Expert Advisor in modo che restituisca un array e non un singolo numero?

 
Grazie a tutti, il problema è risolto usando char* (c++) e string(mql4) invece di int*
 

Chi lo sa?

Come specificare una variabile doppia nel formato di precisione specificato senza arrotondare il numero, per esempio specificare Bid=1.3988 come Bid=1.398 ??

 
admin86 >>:

Кто знает?

Как указать переменную double в указаном формате точности без округление числа, к примеру Bid=1.3988 указать как Bid=1.398 ???

come questo?

 

Tutto risolto, la risposta è qui: https://forum.mql4.com/ru/25945

 

Per favore, aiutatemi...

\fine del programma" - parentesi sinistra sbilanciata


 extern double Lots = 0.1;
extern int TrailingStop=0;
extern string symbol="GBPUSD";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double ma_close,ma_close_pr,ma_open,ma_open_pr;
   double spread,sl_buy,sl_sell,high,high_n,low,low_n;
   int cnt, ticket, total;


   if(Bars<55)
     {
      Print("bars less than 55");
      return(0);  
     }

// to simplify the coding and speed up access
// data are put into internal variables
         ma_close=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,1);
         ma_close_pr=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,2);      
         ma_open=iMA(NULL,0,5,0,MODE_EMA,PRICE_OPEN,1);
         ma_open_pr=iMA(NULL,0,5,0,MODE_EMA,PRICE_OPEN,2);
         spread=MarketInfo(symbol,MODE_SPREAD);
         sl_buy=iLow(NULL,0,1)-spread*Point;
         sl_sell=iHigh(NULL,0,1)+spread*Point;
         high=iHigh(NULL,0,1);
         high_n=iHigh(NULL,0,0);
         low=iLow(NULL,0,1);
         low_n=iLow(NULL,0,0);
        
   

//----
    
   total=OrdersTotal();
   if(total<1) 
     {
      // no opened orders identified
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);  
        }
      // check for long position (BUY) possibility
      if(ma_close>ma_open && ma_close_pr<ma_open_pr && high_n>high)
        {
        ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,sl_buy,0,"FXJEDDI_MTF:Buy",16384,0,Lime);

         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
           }
         else Print("Error opening BUY order : ",GetLastError()); 
         return(0); 
        }
      // check for short position (SELL) possibility
      if(ma_close<ma_open && ma_close_pr>ma_open_pr && low_n<low)
        {
            ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,sl_sell,0,"FXJEDDI_MTF:Sell",16384,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
           }
         else Print("Error opening SELL order : ",GetLastError()); 
         return(0); 
        }
       
       
        for(int i = 0; i < OrdersTotal(); i++)
   {
      // выбор одера
      if(OrderSelect(i, SELECT_BY_POS) == false) continue;
      // not current symbol
      if(OrderSymbol() != Symbol()) continue;
  }
if(OrderType() == OP_SELL)
{
//при профите >20 pips добавится или докупится ... 
 if(OrderProfit()>20)
 OrderSend(Symbol(),OP_SELL,Lots,Bid,3,sl_sell,0,"FXJEDDI:Sell",16384,0,Red);
}
if(OrderType() == OP_BUY)
{
//при профите >20 pips добавится или докупится ... 
 if(OrderProfit()>20)
 OrderSend( (Symbol(),OP_BUY,Lots,Ask,3,sl_buy,0,"FXJEDDI:Buy",16384,0,Lime);
}
      return(0);
     }

Cosa c'è che non va?
 
Necron non ha chiuso la staffa da qualche parte, cercala...
 

Parte 2.

 // it is important to enter the market correctly, 
   // but it is more important to exit it correctly...   
   for( cnt=0; cnt< total; cnt++)
     {
      OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
 OrderSend( 
         if(OrderType()==OP_BUY)   // long position is opened
           {
            // should it be closed?
            if( ma_close< ma_open && ma_close_pr> ma_open_pr && low_n< low)
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                 return(0); // exit
                }
            // check for trailing stop
            if( TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point* TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point* TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point* TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else // go to short position
           {
            // should it be closed?
            if( ma_close> ma_open && ma_close_pr< ma_open_pr && high_n> high)
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
               return(0); // exit
              }
            // check for trailing stop
            if( TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point* TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point* TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point* TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
     }
   return(0);
   
  }
// the end.
 
Techno >>:
Necron скобку где то не закрыл, ищи...

Avete messo gli addendi nel codice corretto?

Motivazione: