Hi, I'm playing with simple Martingale strategy, no indicators, nothing.

  • remember current account state
  • set MarketOrder with StopLoss
  • if StopLoss was hit in previous trade, increase number of contracts to trade and revert the direction of the next order
  • if profit in currently open position is greater than last account state, close position with profit, repeat actions

StopLoss woks as expected, but when I close open position with profit my account continues going down because my function, that calculates current account balance, is missing something, maybe some fee. How to get resulting value of all open positions + closed positions + fees?

protected decimal GetBalance() { return iBalance + // static value = 10000 Portfolio.TotalUnrealizedProfit + Portfolio.TotalProfit - Portfolio.TotalFees; }

The main idea is that open position can be closed only by StopLoss, or when total account equity is greater than it was after last succesful trade.

Example.

  • initial balance = 10000, save it as succesful state
  • place MarketOrder, StopLoss triggered, so I lost $1 commission + $1 by stop order, balance = 10000 - 2 = 9998
  • increase next lot by 2 and place new MarketOrder, this time profit is $4, so it covers previous loss + commission, balance = 9998 + 4 = 10002
  • at this point 10002 > 10000, so we save it as a new succesful balance, decrease lot size back to 1 and repeat

In the attached back test switch to 3m or 6m chart and see that in some reason last profitable trade doesn'r cover all previous losses. Can't understand why...