Account Management

 

Hello everyone,

I'd like to ask you all for some hints and tips on creating a professional style code to help maintain my trading account. I don't know there to start, but so fair this is all I have.

void ACCOUNT_MANAGEMENT()
  {
   int AllOrders=OrdersTotal(),TotalAskOrders=OrderSelect(OP_BUY || No,No,No),TotalBidOrders=OrderSelect(OP_SELL || No,No,No);
   ACCname=AccountName();AccMargin=AccountMargin();ACCPROFIT=AccountProfit();ACCcredit=AccountCredit();
   AccEquity=AccountEquity();AccountBal=AccountBalance();AccCurrency=AccountCurrency();ACCleverage=AccountLeverage();
   AccFreeMargin=AccountFreeMargin();ASOM=AccountStopoutMode();ASOL=AccountStopoutLevel();AFMM=AccountFreeMarginMode();
  }
 
GrumpyDuckMan: I'd like to ask you all for some hints and tips on creating a professional style code to help maintain my trading account. I don't know there to start, but so fair this is all I have.

I think you should first concentrate on learning the basics of the language, its structure, its syntax, code layout and readability, etc.

Then learn about the various functions that are available, how they work and how to use them properly.

The code you provided, will not even compile, because you are basically mixing apples, oranges, tomatoes, carrots, and anything else that fits in the basket.

For example, the OrderSelect() function is for selecting a particular Order either by Index or by Ticket Number. It does not by itself return the number of Orders of a certain type.

So, before you even think about "professional account management", first you need to learn the language, by reading the documentation and researching the example code in the CodeBase.

If you want or prefer, you can even get yourself a good book and follow it from start to end:

OrderSelect - Trade Functions - MQL4 Reference
OrderSelect - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderSelect - Trade Functions - MQL4 Reference
 
Fernando Carreiro:

I think you should first concentrate on learning the basics of the language, its structure, its syntax, code layout and readability, etc.

Then learn about the various functions that are available, how they work and how to use them properly.

The code you provided, will not even compile, because you are basically mixing apples, oranges, tomatoes, carrots, and anything else that fits in the basket.

For example, the OrderSelect() function is for selecting a particular Order either by Index or by Ticket Number. It does not by itself return the number of Orders of a certain type.

So, before you even think about "professional account management", first you need the learn the language, by reading the documentation and researching the example code in the code base.

If you want or prefer, you can even get yourself a good book and follow it from start to end:

Hello Fernando,

I'm not sure about this, I believe you are trying to compile my MQL4 code in MQL5. I am using MQL4 currently.

 
GrumpyDuckMan: I'm not sure about this, I believe you are trying to compile my MQL4 code in MQL5. I am using MQL4 currently.

I know very well, that your code is MQL4! Is the link for OrderSelect() not to MQL4 documentation?

The question however, is how well do you know MQL4 yourself?

As an example exercise, lets compare your use of OrderSelect() with that of the documentation ...

// Your usage ...
int TotalAskOrders = // You are using "int", but OrderSelect() returns a "bool"
   OrderSelect(
      OP_BUY || No,  // This is supposed to be a "int" type for an Index or a Ticket, but you are using a resulting "bool" (of OrderType logically or'ed with an unknown variable "No")
      No,            // This is supposed to be a "int" for a select flag (SELECT_BY_POS or SELECT_BY_TICKET), yet you are using the same unknown variable "No" as above
      No             // This is supposed to be a "int" for a pool type (MODE_TRADES or MODE_HISTORY), yet again you are using the same unknown variable "No" as above
   );

// Reference documentation ... "The function selects an order for further processing."
bool
   OrderSelect(
      int     index,            // index or order ticket
      int     select,           // flag
      int     pool=MODE_TRADES  // mode
   );
OrderSelect - Trade Functions - MQL4 Reference
OrderSelect - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderSelect - Trade Functions - MQL4 Reference
 
Fernando Carreiro:

I know very well, that your code is MQL4! Is the link for OrderSelect() not to MQL4 documentation?

The question however, is how well do you know MQL4 yourself?

As an example exercise, lets compare your use of OrderSelect() with that of the documentation ...

Thank you, Fernando

 

bool No=false,Yes=true;

May I ask you about writing an account management code?

I am not asking for anyone to code it for me, I just would like to know some of the basic requirements to achieve very important code.

I found some code written by whroeder which is providing some clues. However I need a mentor to guide me.  

 
GrumpyDuckMan: May I ask you about writing an account management code? I am not asking for anyone to code it for me, I just would like to know some of the basic requirements to achieve very important code.

I found some code written by whroeder which is providing some clues. However I need a mentor to guide me.  

For hiring a coder or a tutor, you may use the Freelance section.

But, as I stated:

So, before you even think about "professional account management", first you need to learn the language, by reading the documentation and researching the example code in the CodeBase.

If you want or prefer, you can even get yourself a good book and follow it from start to end:

Reason: