Account Equity / Available Margin / Account balance? - page 2

 

Yea you're right.

I think I was just fishing out there to see if there was something else that's relatively simple I may have overlooked. Tbh, I have so many awesome ideas, the problem is, is my idea's are probably a little too sophisticated for my own intellect in terms of getting it down into code...

(i.e. correlation measurements / rules between the pair in topic for trading || money management system that deviates from the mean (say 1%) based upon the number of consecutive wins / loss (lower risk, 0.50% / upping risk to a max, say 1.5%, respectively). )

Are you able to suggest or point me in the right direction of any literature in an MQL4 context that I can read in relation to the above?

 
DomGilberto:


Are you able to suggest or point me in the right direction of any literature in an MQL4 context that I can read in relation to the above?

Not really, I have tended to keep my MM simple . . . MM/position sizing is not just about controlling your risk it is also about maximising your gains. MM won't make a bad strategy come good, it will allow a good strategy to fulfil it's potential though . . . firstly you need a good strategy, if all you need to concentrate on is position sizing then you are is a very, very good place.
 

Ok cool - I have been forward testing my EA over past 2 months and it's performing in line with my historical back-tests (in terms of the system metrics as a whole).

I'm convinced that in theory at this stage, that this type of money management (mentioned above - which I'd love to be able to get a handle on, in terms of logic / coding) is diamond to control volatility in returns.

So far my EA since 2010-2013 Sept (and including 2 months of forward testing), has produced an average "up" month of 6.27%, and an average down month of -2.45%. Worst month end being -6.71%, best month end close of 18.14%. Average inter-month draw-down is approx 3.84%. Maximum draw-down over this entire period was 17.84% (that's including a buffer for trades that may have carried slightly higher risk attached based upon this entire threads topic and how the lot sizing is calculated relative to multiple open positions at any one time).
Std Deviation (month-to-month end close) is 5.88%.

72.34% strike rate, 2.58% break even trades, profit factor of 1.409 and a take profit ratio of 0.539 over 1,859 trades, risking 1% of account balance a piece.


So all in all, the system is without doubt producing a reliable positive expectancy (with forward testing), it's just the money management side to squeeze the optimal out of it, is what I am looking for now.

With that said, there is no doubt I will continually evolve it anyway...

As usual, thanks Raptor.

 

Just wanted to ask one more thing on this topic, when I use this code below, the position sizing works during a back-test (as I can only open one trade at a time on each pair), but not during a forward test. No trade will ever be pushed out when it should be (as I have a VPS with multiple brokers to experiment between them all and coding)... This code below is the only thing I have changed against the other EA which is stopping it from working... I assume I would not need to normalizedouble them....?

Am I being a wolly again...

   
// Changed and non working way? 

double risk_amount;
   
   if( AccountBalance() > AccountEquity() || AccountBalance() == AccountEquity() )
      {
      risk_amount = (( AccountBalance() + AccountEquity() ) / 2 ) * RiskPercent / 100; //<<- risk percent is just "2"
      } 
   if( AccountEquity() > AccountBalance() )
      {
      risk_amount = (( AccountEquity() + AccountBalance() + AccountFreeMargin() ) / 3 ) * RiskPercent / 100;     
      }

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Working way... straight forward...

 double risk_amount = AccountEquity( )*RiskPercent/100; // <<-- RiskPercent is an extern double "2.0"
 
DomGilberto:

Just wanted to ask one more thing on this topic, when I use this code below, the position sizing works during a back-test (as I can only open one trade at a time on each pair), but not during a forward test. No trade will ever be pushed out when it should be

Why ? find out why . . .

By the way, AccountBalance() and AccountEquity() return doubles and you are yet again trying to do a simple check for equality with doubles . . .
 
WHRoeder: None. Risk = (OrderOpenPrice - OrderStopLoss) * OrderLots * DeltaValuePerLot It has nothing to do with account balance or equity.
Once you determine the risk you want, you solve the equation for lot size.
 
WHRoeder:
Once you determine the risk you want, you solve the equation for lot size.


... I dont think you're understanding what I am asking. I know how to calculate correct lot sizing based upon allocating a monetary value per trade on a percentage balance rule.... I am asking how others manage multiple open positions at the same time... I don't think you're statement there^ is relevant to what I am asking.

To make it really simple, I was just wanting to hear other peoples ideas... If I open one position with 2% risk attached, and then another 5 after that based upon the accountbalance; if they all turn into losers, the last losing trade is going to be a larger loss than just 2% of the account balance... Therefore, this provoked my thought process and was curious to see if I was missing something by simply throwing it out there... I am well aware of how to properly calculate the lot sizing based upon OrderOpenPrice - OrderStopLoss (and of course using tickvalue and ticksize...).... Want to know how people manage multiple open positions thats all...


RaptorUK, you're right. I fixed that equality checking error...

 
DomGilberto: ... I dont think you're understanding what I am asking. I know how to calculate correct lot sizing based upon allocating a monetary value per trade on a percentage balance rule.... I am asking how others manage multiple open positions at the same time...

You're the one that brought up accountBalance, equity and margin, forward testing two months, strike rate, profit factors, etc. Why didn't you just ask this question in the first place?

What I do is insure that total risk is never more then accountBalance * percent:

  1. count the number of charts that are about to open (all conditions but trigger price has been met.) Each EA sets a GV (eaName_pair_TF) I use a value of TimeCurrent()+60 as a timeout, so I can detect dead EAs (chart close)
  2. Sum max risk for all open orders (not just chart pair) (OrderOpenPrice - OrderStopLoss) * OrderLots * DeltaValuePerLot
  3. risk = (accountBalance - Sum) * percentPerOrder / count.
The idea is orders at or above breakeven have no risk (aren't counted), if I'm going to open two orders on two charts, each ea drops its own risk in half, and if I'm already at max risk don't open a new order.
 

Thanks for elaborating. I see what you've done there. Quite like it - Ill be exploring that avenue for sure.

Just to double check deltavalueperlot is simply what the value of the pip in question is (pair), on that particular trade, right?

Also, do you personally incorporate a slightly more sophisticated money management approach with regards to increase on draw-down, and decreasing on large consecutive wins (to try to control volatility in your account balance, relative to the random distribution of wins and losses?)

(p.s, when I mean decrease and increase, I mean deviating from the "mean" position / risk sizing; i.e, you may risk on average 0.50% per trade, but after you've hit a 10 streak loss, or 5% draw-down, you will start to increase to 0.75% > 1.00% > 1.25% (Max) etc. - reverse for the good times and consecutive wins - Just something I'd LOVE to get a handle on and am wondering if you have experience or any understanding with this... of course, the risk is still monitored exactly the same with regards to targeted draw-down in any given year. Just a fancy way of potentially controlling the standard deviation in returns : month end...).

Thanks!

 
Hello everyone.
I want help with this function.
My goal is to have the value of AccountBalance of the last two closed orders and then be able to print the two values of AccountBalance: the value of AccountBalance of the order just closed and the value that the AccountBalance had when the previous one order was closed.
I don't understand where I'm wrong.

Thank you

Here the function:


void   check2LastAccountBalance(){


       double CurrentAccountBalance[100];

       double PreviousAccountBalance;

       

       for(int i=1; i<=OrdersHistoryTotal(); i++){

       

          if(OrderSelect(i-1,SELECT_BY_POS, MODE_HISTORY)){

          

             if(OrderCloseTime() !=0  &&  OrderProfit() >0){

                           

                    CurrentAccountBalance[i] = AccountBalance();

                    PreviousAccountBalance = CurrentAccountBalance[i-1];

                    

                    Print("CurrentAccountBalance[i]: "+DoubleToString(CurrentAccountBalance[i],2));

                    Print("PreviousAccountBalance: "+DoubleToString(PreviousAccountBalance,2));

                                 

             }

          }       

       }

     }  


Reason: