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

 
Artyom Trishkin:

Copied. And how much is copied is checked?

If you are using an indicator with smoothing, it requires a few more bars than you expect to calculate. Therefore, just because you have copied does not mean that the data is copied and fully available.

It is easier to check the size of the array and exit OnTick() if it does not have the required size.

And how to do it, if in optimization mode no output is given, but in normal mode everything works?
output to file will work?

 
Sergey Likho:
Can you give me a universal formula for calculating the breakeven price if there are commissions and swaps in a trade?

There is a simple formula that works for quotes with 5 digits and deposit in usd

Lot x profit in pips = profit in $.

If it is buy, and there are swaps and commissions in deal, then breakeven price will be a bit higher than open price
(If there are no swaps and commissions, the breakeven is the opening price)

But if the instrument is exotic or the quote is 4 or 2 figures or the deposit currency is pounds. The above formula is not helpful.
Is there a universal formula?

If you are interested, here is a great code that takes everything into account - https://www.mql5.com/ru/forum/58229#comment_1603761

Как получить усредненную цену позиции по двум (или более) лотам с разными ценами?
Как получить усредненную цену позиции по двум (или более) лотам с разными ценами?
  • 2015.05.01
  • www.mql5.com
Другими словами среднюю цену открытия позиции, при наличии нескольких лотов по разной цене.
 
Please tell me why the furthest open order is not closed? I've done everything I should have done but it just takes the order out of the list
int TimeSec;
//+------------------------------------------------------------------+
void start(){
if(NewSecRun()==false){return;} 
fOrderClose();}
//+------------------------------------------------------------------+
bool NewSecRun(){
if(TimeSec!=TimeSeconds(TimeCurrent())){
    TimeSec=TimeSeconds(TimeCurrent());
return (true);}   return (false);}  
//+------------------------------------------------------------------+
int fMarketOrders(int type){
   int c=0,aBuyCount=0,aSellCount=0;
     for(int i=0;i<OrdersTotal();i++){
       if(OrderSelect(i,SELECT_BY_POS)){
            switch(OrderType()){
               case OP_BUY:aBuyCount++;break;
               case OP_SELL:aBuyCount++;break;
              }}else{return(-1);}}
   if(type==OP_BUY)c=aBuyCount;if(type==OP_SELL)c=aSellCount;
   return(c);}
//+------------------------------------------------------------------+
void fOrderClose(){     Comment("       ",fMarketOrders(OP_BUY)+fMarketOrders(OP_SELL) );
      if((fMarketOrders(OP_BUY)+fMarketOrders(OP_SELL))>=500){
          for(int i=0;i<OrdersTotal();i++){
          if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
          if(OrderType()==OP_SELL || OrderType()==OP_BUY){
    if( OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE) || OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE)){return;} }}} }  }
    
 
void fOrderClose()...
for
(int i=0;i<OrdersTotal();i++){           if(OrderSelect(i

Here, I guess.

 
Galim_V:

Here, I guess.

this function seems to select the very first transaction. That's the way I want it. Is something wrong?

 
Rustam Bikbulatov:

this function seems to select the very first transaction. That's the way I want it. Is something wrong?

I'm no master, but I don't see any other closure here. Selecting from Total.
 
            switch(OrderType()){
               case OP_BUY:aBuyCount++;break;
               case OP_SELL:aBuyCount++;break;

This is where aBuyCount builds up "heavily" and aSellCount does not build up at all.

 
Vladimir:

This is where aBuyCount builds up "heavily" and aSellCount does not build up at all.

Thank you! I didn't even notice! I don't think so, but maybe that's why!

 

Afternoon!

I bought an indicator on the mql5 website, for the MT4 terminal, installed it, everything worked... but some time ago it stopped working... I've been talking to the developer, technical support from Forex Club (I have their terminal), they were not able to help me. They couldn't help me. Technical support has sent me to mql.5 forum.

 
paka76:

Afternoon!

I bought an indicator on the mql5 website, for the MT4 terminal, installed it, everything worked... but some time ago it stopped working... I've been talking to the developer, technical support from Forex Club (I have their terminal), they were not able to help me. They couldn't help me. Technical support has sent me to mql.5 forum.

To the seller of this indicator.

Reason: