need help on ctrade!

To add comments, please log in or register
m.gonnella
15
m.gonnella  

hi!

can someone help me?

when i'm writing  the CheckVolume function appears, i ve seen that some traders use it a lot in their system.

But when i try to find it in the guide, there isn't


can someone tell me where i can find this function?? and why not in the manual?

thank you very much for helping

Fernando Carreiro
3819
Fernando Carreiro  
m.gonnella: when i'm writing  the CheckVolume function appears, i ve seen that some traders use it a lot in their system.

But when i try to find it in the guide, there isn't

can someone tell me where i can find this function?? and why not in the manual?

When in doubt, analyse the contents of the source code file for the class in question. In this case: MQL5\Include\Trade\Trade.mqh

double CTrade::CheckVolume(const string symbol,double volume,double price,ENUM_ORDER_TYPE order_type)
  {
//--- check
   if(order_type!=ORDER_TYPE_BUY && order_type!=ORDER_TYPE_SELL)
      return(0.0);
   double free_margin=AccountInfoDouble(ACCOUNT_FREEMARGIN);
   if(free_margin<=0.0)
      return(0.0);
//--- clean
   ClearStructures();
//--- setting request
   m_request.action=TRADE_ACTION_DEAL;
   m_request.symbol=symbol;
   m_request.volume=volume;
   m_request.type  =order_type;
   m_request.price =price;
//--- action and return the result
   if(!::OrderCheck(m_request,m_check_result) && m_check_result.margin_free<0.0)
     {
      double coeff=free_margin/(free_margin-m_check_result.margin_free);
      double lots=NormalizeDouble(volume*coeff,2);
      if(lots<volume)
        {
         //--- normalize and check limits
         double stepvol=SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP);
         if(stepvol>0.0)
            volume=stepvol*(MathFloor(lots/stepvol)-1);
         //---
         double minvol=SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);
         if(volume<minvol)
            volume=0.0;
        }
     }
   return(volume);
  }

Please note however, that it is a virtual method:

   //--- method check
   virtual double    CheckVolume(const string symbol,double volume,double price,ENUM_ORDER_TYPE order_type);
PS! Also, please don't double post: https://www.mql5.com/en/forum/279108
CheckVolume
CheckVolume
  • 2018.09.13
  • www.mql5.com
hi, can anyone explane me why i can't find the method CheckVolume in the MQL5's guide?? please help me thanks...
m.gonnella
15
m.gonnella  
Fernando Carreiro:

When in doubt, analyse the contents of the source code file for the class in question. In this case: MQL5\Include\Trade\Trade.mqh

Please note however, that it is a virtual method:

PS! Also, please don't double post: https://www.mql5.com/en/forum/279108
i'm sorry but I redid another post because I could not find this post, thank you very much for the explanation.
Fernando Carreiro
3819
Fernando Carreiro  
m.gonnella: i'm sorry but I redid another post because I could not find this post, thank you very much for the explanation.

Just go to the "Publications" section of your own profile and you will see the list of all the threads you have created. Alternatively, when you start a thread, mark it as a "Favorite" (by clicking the "star" just under the thread name), so that you can track it later in your "favorites" list (the "star" in the top menu on the right before you profile link).

To add comments, please log in or register