STRATEGYPROFIT is a built-in variable in the ProBuilder language used to track the cumulative profit or loss in money generated by the closed trades of a currently running trading strategy. This variable is essential for analyzing the effectiveness of a strategy over time by providing real-time feedback on its financial performance.
myCurrentProfit = STRATEGYPROFIT
To utilize the STRATEGYPROFIT variable, you can assign its value to another variable to keep track of the strategy’s profit. Below is a simple example:
DEFPARAM CumulateOrders = true // Cumulating positions
myCurrentProfit = STRATEGYPROFIT
IF myCurrentProfit > 1000 THEN
SELL 100 SHARES AT MARKET
ENDIF
In this example, the strategy checks if the current profit exceeds 1000 units. If it does, it triggers a sell order for 100 shares at the market price. This demonstrates how STRATEGYPROFIT can be used to make decisions based on the profitability of the strategy up to that point.
DEFPARAM CumulateOrders = true if you want to keep positions open across multiple bars and cumulatively calculate the profit.Understanding and utilizing STRATEGYPROFIT can significantly aid in the management and adjustment of trading strategies based on their historical performance.