Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1939

 
Valeriy Yastremskiy #:
The general metaquotes folder is the terminal folder, it contains the general terminal folders, there the terminal logs, data and the tester folder, it has its own logs and file folders. The mcl folder contains logs of EAs, scripts, indicators, windows, subwindows.
everything. Spc. Yesterday I cleaned it. I will check it again today. Cleaned out 30GB. From about 10 terminals and history mostly on tools and logs...
 
Artyom Trishkin:

In this thread I want to begin to help those who really want to understand and learn programming in the new MQL4 and want to easily switch to MQL5 - the languages are very similar.

This blog will be a good place to discuss problems, algorithms of their solution and any other questions concerning MT programming one way or another.

I hope that other experienced members of our forum will join the discussion and the branch will be interesting to all.

Hello, no one can help me with the close order function, I am trying the following,

for (int i=1; i<=OrdersTotal(); i++)

{

if(OrderSelect(i-1,SELECT_BY_POS)==true)

{

if( Ask<= OrderOpenPrice())CloseBay();

}

}

When Ask is above the order Bay, everything is fine, as soon as Bid becomes above the order Bay the order is removed, and should be removed when Ask is below the open price. Please help me, I will be very grateful to you. Sincerely Alexander.

 
Alexandr Spravchikov #:

Hello, no one can help me with the close order function, I'm trying it this way,

Have you tried it this way?

void CloseBuy()
{
   for(int i= OrdersTotal()-1; i>=0; i--)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
         if((OrderSymbol()==_Symbol) && (OrderMagicNumber()==Magic) && (OrderType()==OP_BUY))
         {
            if( Ask<= OrderOpenPrice())
            if(!OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Green))
            {
               Print("Error closing a buy order!"+  IntegerToString(_Period,0) +" Error code = " + IntegerToString(GetLastError(),0));
            }
         }
      }
   }
   return;
}
 

Greetings. Can you please tell me how to make a trade api query for "BTCUSDT" to indicate the number of lots not in BTC but in USDT?

 

Hi all! A word of advice, please.


The idea is simple. To write an EA that will open a position and close the opposite one when breaking through one of the global channel borders. The channel is plotted by the indicator.

I have made a variant using Internet guides. This bot opens/closes positions in the strategy tester, but if you look at the chart, it does not meet my conditions at all. I have checked all the variables in the buffer and checked for errors. I did not get any results.


If someone can, please advise me what's wrong, what direction to dig. :3


I attached a file with variables from buffer, demonstration of indicator, its initial variables, my variant of Expert Advisor.

Files:
9.png  14 kb
f2.png  26 kb
second.mq4  15 kb
 
E1Macho1 #:

Hi all! Can you give me a hint, please?

Which way to go. :3

Dig in the direction of using the debugger

 
Hello all. Could you please tell me how indicator call in mql4 works. I change period for CCI in loop, but if number of iterations becomes more than 205, then CCI starts drawing zeros, and in another buffer. If num=204, then the period may be even 500, but if num=205, then the maximum period may be 207, and then it will contain zero. There are several thousand bars on the chart. If we do not change the period in the loop, everything is OK, of course. What may be the reason? I constantly face problems with multiple indicator calls. Please advise how to deal with it, maybe read some articles?
   if(rates_total>prev_calculated)
   {
      int num=205;
      period =2;   

         for(int i=0; i<=num; i++)
         {
            cci[i] = iCCI(NULL,0,period,PRICE_CLOSE,i);   
            period++;
         }
      ////////////
      period=208;

      for(int i=0; i<100; i++)
      {
         CCI[i] = iCCI(NULL,0,period,PRICE_CLOSE,i);
      }
    
   }
If num=300, the maximum period is 66
Files:
iCCI.mq4  10 kb
 
From time to time I try to run the indicator and it works, but the terminal hangs.
 
At least tell me which way to dig as they say?
 
Aleksandr Kononov #:
At least tell me which way to dig, as they say?

and what are you doing this kind of research for? Does it make practical sense? Or just for the sake of interest?

Reason: