Calculating Maximum drawdown at specified bars

 

Does anyone knows  how to calculate maximum draw down for a specified number of bars for a given currency in mql4?

For example, i'm looking at the last 200  1 minute bars, where the currency pair did on average  increase. I want to find out within that period, the maximum draw down e.g the biggest movement down.

Your ideas will help.


Thanks.

 

The question is - how do you define "movement down". Is it enough for you to say that movement contains of a group of consecutive downbars?

Then you have to measure how far the price went from an open of a first downbar to a close of a last downbar in any given group of consecutive downbars.

 
Use lowest low or highest high for OSL and compute the loss. Risk depends on your initial stop loss and lot size.
  • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
  • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
  • Do NOT use TickValue by itself - DeltaPerLot
  • You must normalize lots properly and check against min and max.
  • You must also check FreeMargin to avoid stop out
If you have multiple open orders, use lots weighted average price for OOP and total lots. OrderOpenPrice question . - MQL4 and MetaTrader 4 - MQL4 programming forum
 
prweza:

Does anyone knows  how to calculate maximum draw down for a specified number of bars for a given currency in mql4?

For example, i'm looking at the last 200  1 minute bars, where the currency pair did on average  increase. I want to find out within that period, the maximum draw down e.g the biggest movement down.

Your ideas will help.

If you're asking about a source code that calculates drawdown using standard algorithm - why not to search through the code base? Here is one example of indicators, which calculates many metrics including drawdown (amount and percents) - https://www.mql5.com/ru/code/8752 - it's in Russian part (I don't see English version), but the code is ready to use. Of course, you can apply it on any array, which can consist of only 200 latest bars, and don't forget to adjust starting depo to real equity at the beginning of these bars.

Индикатор виртуальной эквити
Индикатор виртуальной эквити
  • votes: 4
  • 2009.03.03
  • Igor Korepin
  • www.mql5.com
Индикатор строит линию эквити по данным графических меток.
 
Stanislav Korotky:

If you're asking about a source code that calculates drawdown using standard algorithm - why not to search through the code base? Here is one example of indicators, which calculates many metrics including drawdown (amount and percents) - https://www.mql5.com/ru/code/8752 - it's in Russian part (I don't see English version), but the code is ready to use. Of course, you can apply it on any array, which can consist of only 200 latest bars, and don't forget to adjust starting depo to real equity at the beginning of these bars.


I think you both misunderstood my question. I want to enter a trade based on  maximum draw down i.e down movement  (in pips not money)  for the past 200 bars. 

 
prweza:

I think you both misunderstood my question. I want to enter a trade based on  maximum draw down i.e down movement  (in pips not money)  for the past 200 bars. 

Probably you can just use WPR?

 
Stanislav Korotky:

Probably you can just use WPR?


What is WPR?

 
prweza: What is WPR?
If you had used this you would have found this.
Reason: