Questions from Beginners MQL4 MT4 MetaTrader 4 - page 234

 
leonerd:

OK, I see, thank you. Thought I'd try it out on an expert. But here I got 5203. In MT5, the same code works fine...

I think I figured it out. I set timeout 5000 (it worked on MT5, but not on MT4). I put 500 - it worked on MT4 as well.

 

Can you please advise how to transfer a function from an indicator to an EA to calculate directly in it?


void OnTick()

{

SovExitBuffer[0]= getValue()// }

)?


int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

//---
   int limit;
//---
   if(rates_total<=1)
      return(0);
//--- last counted bar will be recounted
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)
      limit=limit+1;

 for(int i=limit-1; i>=0; i--)
 {

  
  upDband1=iMA(NULL,0,25,0,MODE_SMA,PRICE_CLOSE,i)+iStdDev(NULL,0,25,0,MODE_EMA,PRICE_CLOSE,i)*2;
  maDbands1=iMA(NULL,0,25,0,MODE_SMA,PRICE_CLOSE,i);
  deltaDbands1=upDband1-maDbands1;

  ExitBuffer[i]=deltaDbands1; //Это значение нужно получить в советнике в Ontick()
  
  }

   return(rates_total);
  }


 

Can you tell me how to write this code 2 errors ! 1-unexpected end program 2- Unbalanced parentheses What is wrong in the sense of unbalanced parentheses?

extern double        Lot   =1;
//-------------------------------------
//----------------------------------
void start()
{
  Lot=OrderLots();
  void RefreshRates();
  CurAskPriceOne = MarketInfo("EURUSD", MODE_ASK);
  CurAskPriceTwo = MarketInfo("USDCHF", MODE_ASK);
 //----------
 //--Открытие ордера1
    Ticket=OrderSend("EURUSD",OP_BUY,Lot,CurAskPriceOne,2,0,0);
    if (Ticket > 0)
      {
       if(OrderSelect(Ticket,SELECT_BY_POS,MODE_TRADES)) Print (" One order opene : " , OrderOpenPrice());
      {
      else Print ("Eror opening BUY EURUSD order : ",GetLastError();
//-------------
//--Ордер 2
          Ticket=OrderSend("USDCHF",OP_BUY,Lot,CurAskPriceTwo,2,0,0);
    if (Ticket > 0)
      {
       if(OrderSelect(Ticket,SELECT_BY_POS,MODE_TRADES)) Print (" One order opene : " , OrderOpenPrice());
      {
      else Print ("Eror opening BUY USDCHF order : ",GetLastError());
      
//---------------------------Закрытие старт
  return;
}
 
Tenimagalon:

Can you tell me how to write this code 2 errors ! 1-unexpected end program 2- Unbalanced parentheses What's wrong?

Errors with parentheses fixed - you need to look for paired, or better - first put the brackets, and then inside the code to write:

extern double        Lot   =1;
//-------------------------------------
//----------------------------------
void start()
{
   Lot=OrderLots();
   RefreshRates();
   CurAskPriceOne = MarketInfo("EURUSD", MODE_ASK);
   CurAskPriceTwo = MarketInfo("USDCHF", MODE_ASK);
   //----------
   //--Открытие ордера1
   Ticket=OrderSend("EURUSD",OP_BUY,Lot,CurAskPriceOne,2,0,0);
   if(Ticket > 0)
     {
      if(OrderSelect(Ticket,SELECT_BY_POS,MODE_TRADES)) 
         Print(" One order opene : " , OrderOpenPrice());
      else
         Print("Eror opening BUY EURUSD order : ",GetLastError());
     }
   //-------------
   //--Ордер 2
   Ticket=OrderSend("USDCHF",OP_BUY,Lot,CurAskPriceTwo,2,0,0);
   if (Ticket > 0)
     {
      if(OrderSelect(Ticket,SELECT_BY_POS,MODE_TRADES)) 
         Print(" One order opene : " , OrderOpenPrice());
     }
   else
      Print("Eror opening BUY USDCHF order : ",GetLastError());
   //---------------------------Закрытие старт
   return;
}

... But there is no logic in your code...

 

I'll add,

this:

Lot=OrderLots();

won't work, OrderLots() function work, read the help.

variables:

CurAskPriceOne and CurAskPriceTwo

are not declared anywhere,

you need to do it roughly.

   double CurAskPriceOne = MarketInfo("EURUSD", MODE_ASK);
   double CurAskPriceTwo = MarketInfo("USDCHF", MODE_ASK);

like this

 
Well, I agree about the lot. Ah.
  double CurAskPriceTwo = MarketInfo("USDCHF", MODE_ASK);

not announced and it worked. :)

 
On several occasions I have seen minute quotations disappear retrospectively. For example, last night (12.02) several hundred records for the 10th-11th day disappeared. Sometimes it is treated by simply pressing "refresh" on M1 chart, yesterday it did not work and I had to manuallyimport quotes from another terminal. The broker on the server is fine, as the same account opened in another copy of the terminal gives a normal chart without the hole. What could be the problem?
Объем импорта - экономические данные США
Объем импорта - экономические данные США
  • www.mql5.com
Импорт (Imports) отражает объем товаров и услуг из-за рубежа, которые сразу же входят в сети потребления, склады и зоны внешней торговли. При составлении индикатора обычно используется стоимость
 
I can't figure out how to open orders, how to close them, how to take them by type, I can't figure out how to make the bot open one fucking order and that's it :) Let's take the simplest code, what do I need to put in the beginning or end to make this bastard open the order once.
extern double lot =1;
int start()
{
  int Ticket;
   Ticket=OrderSend("USDCHF",OP_BUY,Lot,Ask,2,0,0);
 return(1);
}
 
Tenimagalon:
I can't figure out how to open orders, how to close them, how to take them by type, I can't figure out how to make the bot open one fucking order and that's it :) Let's take the simplest code, what do I need to put in the beginning or end to make this bastard open the order once.
OrdersTotal() < 1
 
Iurii Tokman:
Is this before you open it?
(
)
Reason: