Download MetaTrader 5

Discussion of article "Writing an Expert Advisor using the MQL5 Object-Oriented Programming approach"

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
192521
MetaQuotes Software Corp.  

New article Writing an Expert Advisor using the MQL5 Object-Oriented Programming approach is published:

This article focuses on the object oriented approach to doing what we did in the article "Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners" - creating a simple expert advisor. Most people think this is difficult, but I want to assure you that by the time you finish reading through this article, you will be able to write your own Expert Advisor which is object oriented based.

Author: Samuel

Paul Anscombe
4507
Paul Anscombe  

Hi  thanks for the well laid out example.

 But I have to ask is it right?  

 In the EA it is checking for a trade opportunity at the start of each new bar. 

In the class function  getbuffers() it retrieves the last 3 bars data starting at the current bar 0 which has only just been formed and therefore the value is errornous.

 void MyExpert::getBuffers()
  {
   if(CopyBuffer(ADX_handle,0,0,3,ADX_val)<0 || CopyBuffer(ADX_handle,1,0,3,plus_DI)<0
      || CopyBuffer(ADX_handle,2,0,3,minus_DI)<0 || CopyBuffer(MA_handle,0,0,3,MA_val)<0)

 

Should it not be retrieving the last 3 bars indicator data starting at position 1?

thanks

 

 

Hamed Tabasi
151
Hamed Tabasi  

Great Article Samuel

Thank you in advance for this priceless article,

So based on this article, we could include functions such as IsNewBar or Buy_opened to the class and just calling it from EA.

Thank you again,

I hope seeing more article from you,

Hamed, 

 

 

 

spinnybobo
5
spinnybobo  

Amazing article!  I did not read entire thing yet, but already I can say that it is much much more helpful than 

anything I have seen thus far.  Thank you so very much :-)

 Spencer 

MOHAMMED SAFAR AL-OTAIBI
31
MOHAMMED SAFAR AL-OTAIBI  

   if(base_currency=="USD")

     {

      one_lot_price=contract_size/levrage;

     }

   else

     {

      double bprice= SymbolInfoDouble(symbol,SYMBOL_BID);

      one_lot_price=bprice*contract_size/levrage;

     }


Marvelous thread. thank you very much.


There is some math mistakes.

assume the pair is cadchf?? 

also you assume constant leverage for all symbols. most brokers have different leverages for some pairs.

\any way the correct rule for any pair for the margin of 1 lots is Margin in account currenct is: C*Lots*YYYDDD

YYY is the base currency, DDD: Domination currency\

things will go fine with you until you reach CADCHF for example\

YYYDDD = CADUSD. --------------- not USDCAD is whown in the Marketwacth\\\


so you have to add third condition else-if

MOHAMMED SAFAR AL-OTAIBI
31
MOHAMMED SAFAR AL-OTAIBI  

C=ContractSize/PairLeverage

Metin Kostekci
129
Metin Kostekci  
very nice article.Thank you
To add comments, please log in or register