I am trying to gauge what kind of underwater drawdowns (drawdowns on open positions, or drawdown on unrealized profit/loss) I may experience while running my strategy. For this I have made an indicator and an output to Excel, this seems to be working fine. What I need help with, is figuring out how I can return the lowest value out of x number of values.
Basically what I see on my underwater drawdown 'indicator' is a string of numbers like this:
0, -2,-5,-9, -21, 0. The numbers representing the entry of a position and how it currently moves against me. Now what I need is to somehow return the lowest value out of those values.
This is currently how my underwater drawdown code looks like:
// Underwater Drawdown UDD = 0; // Underwater drawdown // Long Underwater Drawdown if (Position.MarketPosition == MarketPosition.Long){ if (Open[BarsSinceEntry()] > GetCurrentAsk()) UDD = GetCurrentAsk() - Open[BarsSinceEntry()]; else UDD = 0;} // Short Underwater Drawdown if (Position.MarketPosition == MarketPosition.Short){ if (Open[BarsSinceEntry()] < GetCurrentBid()) UDD = Open[BarsSinceEntry()] - GetCurrentBid(); else UDD = 0;}
Comment