No result found by backtesting my code

Created at 04 Apr 2024, 09:21
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
GY

gyoy

Joined 04.04.2024

No result found by backtesting my code
04 Apr 2024, 09:21


Dear CTrader Developers and Programmers,

I've written a small code that should reverse position (scalping) whenever 2 indicators ( SMA and EMA ) cross each other. I built the code without the system giving me any error message, however when I run my cbot using backtesting I don't get any result, I mean no capital gain or loss. It finishes the test and stays 0.00$ (0%).

What am I doing wrong? Can you help me please?

Thank you for everyone who gives me any idea!

Here is my code.

 

 using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; namespace cAlgo.Robots {     // Scalping when 2 indicators (SMA and EMA) cross each other.     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]     public class SMAEMACross : Robot     {         private SimpleMovingAverage MySMA;         private ExponentialMovingAverage MyEMA;         [Parameter("Source", Group = "Simple MA")]         public DataSeries SimpleMaPrice { get; set; }         [Parameter("Period", DefaultValue = 14, Group = "Simple MA")]         public int SimpleMaPeriod { get; set; }         [Parameter("Source", Group = "Exponential MA")]         public DataSeries ExponentialMaPrice { get; set; }         [Parameter("Period", DefaultValue = 14, Group = "Exponential MA")]         public int ExponentialMaPeriod { get; set; }         private double MyUnitVolume;         [Parameter("Volume (Lots)", DefaultValue = 0.01)]         public double MyVolumeInLots { get; set; }                  public Position[] BotPositions         {             get             {                 return Positions.FindAll(“”,SymbolName);             }         }         protected override void OnStart()         {             MyUnitVolume = Symbol.QuantityToVolumeInUnits(MyVolumeInLots);             MySMA = Indicators.SimpleMovingAverage(SimpleMaPrice, SimpleMaPeriod);             MyEMA = Indicators.ExponentialMovingAverage(ExponentialMaPrice, ExponentialMaPeriod);         }         protected override void OnBar()         {             if (SimpleMaPrice.Last(1) > ExponentialMaPrice.Last(1) && SimpleMaPrice.Last(2) <= ExponentialMaPrice.Last(2))             {                 ClosePositions(TradeType.Buy);                 ExecuteMarketOrder(TradeType.Sell, SymbolName, MyUnitVolume);             }             else if (SimpleMaPrice.Last(1) < ExponentialMaPrice.Last(1) && SimpleMaPrice.Last(2) >= ExponentialMaPrice.Last(2))             {                 ClosePositions(TradeType.Sell);                 ExecuteMarketOrder(TradeType.Buy, SymbolName, MyUnitVolume);             }         }         private void ClosePositions(TradeType tradeType)         {             foreach (var position in BotPositions)             {                 if (position.TradeType != tradeType) continue;                 ClosePosition(position);             }         }              } }

@gyoy