This ProBuilder code snippet demonstrates how to calculate an equity curve for a trading strategy, taking into account the deduction of overnight fees. The equity curve represents the value of a trading account over time, providing insights into the performance of the trading strategy.
// Initial account balance
account_balance = 10000
// Simulated daily returns
daily_returns = [0.01, -0.005, 0.007, -0.002, 0.003]
// Overnight fee percentage
overnight_fee = 0.0002
// Calculate equity curve
FOR i = 0 TO SIZEOF(daily_returns) - 1
account_balance = account_balance + (account_balance * daily_returns[i])
account_balance = account_balance - (account_balance * overnight_fee)
NEXT
RETURN account_balance
This code snippet is structured to simulate the impact of daily returns and overnight fees on an initial trading account balance. Here’s a step-by-step breakdown:
This example helps illustrate how to manage and calculate changes in an equity curve with the inclusion of costs such as overnight fees, which are common in trading scenarios.
Check out this related content for more information:
https://www.prorealcode.com/topic/more-accurate-equity-curve-with-overnight-fees-deducted/
Visit Link