Max Draw Down Report (single position)

stable
By Firetron in Trading Bots Published April 2020 👁 1,369 views 💬 1 comments

Description

Add this code to your existing script to report max draw down of positions after a back test completes. You will have to supply the trading code.
HaasScript
local maxDrawDownAmount  = Load('maxDrawDownAmount',  0)
local maxDrawDownPercent = Load('maxDrawDownPercent', 0)
 
function CheckMaxDrawDown()
 
  if GetPositionDirection() == NoPosition then
    return
  end
 
  local drawDownAmount  = GetPositionProfit()
  local drawDownPercent = GetPositionROI()
  
  maxDrawDownAmount  = ArrayGet(Min(maxDrawDownAmount,  drawDownAmount),  1)
  maxDrawDownPercent = ArrayGet(Min(maxDrawDownPercent, drawDownPercent), 1)
 
  Save('maxDrawDownAmount',  maxDrawDownAmount)
  Save('maxDrawDownPercent', maxDrawDownPercent)
 
end
 
CheckMaxDrawDown()
 
Finalize(function()
  CustomReport('Max. Draw Down Amount',  maxDrawDownAmount..' '..QuoteCurrency(), 'Draw Down Report')
  CustomReport('Max. Draw Down Percent', maxDrawDownPercent..' %',                'Draw Down Report')
end)

1 Comment

Sign in to leave a comment.

F
Firetron about 6 years ago

Draw Down was an inaccurate term for this. Please use the new one here: https://www.haasscripts.com/t/max-risk-point-report-single-position/