CRITICAL: RiskReward Tool in Backtest Erroneously Places LIVE Trades
CRITICAL: RiskReward Tool in Backtest Erroneously Places LIVE Trades
07 May 2025, 10:10
Bug Report:
The `Chart.DrawRiskReward` tool, when used in a cBot during **backtesting (visual mode)**, incorrectly places trades on the **LIVE account** instead of the backtesting sandbox.
To Reproduce:
1. Create a cBot and include the `Chart.DrawRiskReward` tool, e.g.: private void OnMouseDown(ChartMouseEventArgs obj)
{
var high = Symbol.Ask;
var chartY = Chart.YToYValue(obj.MouseY);
double entryPrice = chartY >= high ? Symbol.Ask : Symbol.Bid;
TradeStrategy = chartY > high ? TradeType.Buy : TradeType.Sell;
int barIndex = Chart.LastVisibleBarIndex;
riskReward = Chart.DrawRiskReward("RiskRewardTool", barIndex - 25, barIndex, entryPrice, OrderType.Market,
TradeStrategy, new ChartRiskRewardFixedRiskType(ChartRiskRewardAmountType.BalancePercentage, PercentageRisk));
riskReward.IsInteractive = true;
}
2. Initiate the tool's display (e.g., via a `MouseDown` event).
3. Run the cBot in **Backtesting with Visual Mode enabled**.
4. On the backtest chart, click the [Buy] or [Sell] button on the displayed RiskReward tool.
Expected Behavior:
A trade is simulated within the backtesting environment.
Actual Behavior:
A trade is executed on the **LIVE trading account**. This was confirmed when testing on an FTMO account, where an unexpected live trade was placed.
- Impact: SEVERE
This bug poses a significant risk of:
Unintended Live Trades & Financial Loss: Placing real trades without user intent.
Account Invalidation: Violating prop firm rules (e.g., FTMO drawdown/trade restrictions) due to rogue trades, potentially leading to account termination.
- Note:
The tool *displays* correctly on both Live and Backtest (visual mode) charts.
Placing trades via the tool on a LIVE chart works as expected.
The issue is specific to interacting with the tool's buttons within the **backtesting window**.
This should be straightforward to reproduce and requires urgent attention due to the potential for severe financial consequences.