Problesm with Visual vs non Visual Backtesting

Created at 02 May 2024, 11:15
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!
TR

trading1

Joined 17.09.2019

Problesm with Visual vs non Visual Backtesting
02 May 2024, 11:15


I made a bot which works on 1 min.

When I run a backtest on the bot in non visual mode over 6 months, it makes a 45k profit.

When I run exactly the same bot with the same parameters in visual mode, it looses money.

I have Ctrader 4.8.30.

This is a big problem in my opinion which makes the platform unsuitable  for bot development as it has not testing integrity.

Here ae the chartshots.


@trading1
Replies

PanagiotisCharalampous
02 May 2024, 12:15

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis


@PanagiotisCharalampous

trading1
02 May 2024, 12:30

RE: Problesm with Visual vs non Visual Backtesting

PanagiotisCharalampous said: 

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis

Here is the Bot Code .

You can find the parameters I used in the pictures above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
 {

    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class EBOTTRADEIRL: Robot
     {
       
        [Parameter("Risk %", Group = "Risk",DefaultValue = 0.02)]
          public double RiskPCT { get; set; }
        
        [Parameter("ATR MA Type",Group = "ATR")]
        public MovingAverageType ATRMAType { get; set; }
        
        [Parameter("ATR Period", Group = "ATR", DefaultValue = 14)]
            public int ATRPeriod { get; set; }
        
                  
        [Parameter("RSI MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIPeriod { get; set; }
        [Parameter("RSI Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIType { get; set; }
             
          [Parameter("RSIMA MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIMAPeriod { get; set; }
        
        [Parameter("RSIMA Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIMAType { get; set; }    
             
        [Parameter("SSL Period", Group = " SSL ", DefaultValue = 8)]
            public int SSLPeriod{ get; set; }
         
         
         [Parameter("SSL Type", Group = " SSL" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType SSLMAType { get; set; }
            
        [Parameter("Baseline Period", Group = " Baseline ", DefaultValue = 8)]
            public int BLMAPeriod{ get; set; }
         [Parameter("Baseline MA", Group = " Baseline" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType BLMAType { get; set; }    
            
        
        [Parameter("MACD Long Cycle", Group = " MACD ", DefaultValue = 21)]
            public int MACDLong{ get; set; }
       
        [Parameter("MACD Short Cycle", Group = " MACD ", DefaultValue = 8)]
            public int MACDShort{ get; set; }
        [Parameter("MACD Signal", Group = " MACD ", DefaultValue = 12)]
            public int MACDSignal{ get; set; }
                
        
            
       [Parameter("StopLoss Factor", Group = "Risk", DefaultValue = 1)]
        public double SLM { get; set; }
       [Parameter("TakeProfit Factor", Group = "Risk", DefaultValue = 1)]
        public double TPM { get; set; }
        
      
      //Declare Indicators and name them
       
         private AverageTrueRange atr;
         
         private SSLChannel ssl;
         private MovingAverage rsiMA, bl; 
         private RelativeStrengthIndex rsi;
         private MacdCrossOver macd;
         
         public string botName;
         
       
                      

        protected override void OnStart()
        
        
        
       
        
            {  atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Exponential);
               ssl = Indicators.GetIndicator<SSLChannel>(SSLPeriod,SSLMAType);
               rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RSIPeriod);
               rsiMA = Indicators.MovingAverage(rsi.Result, RSIMAPeriod, RSIMAType);
               macd = Indicators.MacdCrossOver(MACDLong, MACDShort, MACDSignal);
               bl = Indicators.MovingAverage(Bars.MedianPrices, BLMAPeriod, BLMAType);
            
            }

        protected override void OnBarClosed()
        {
            
            
                       
            var C2 = ssl._sslUp.Last(0) - ssl._sslDown.Last(0);
            var PrefC2 = ssl._sslUp.Last(1)-ssl._sslDown.Last(1);
            var C2U = ssl._sslUp.Last(0);
            var C2D = ssl._sslDown.Last(0);
            
            
                      
            var C6 = rsi.Result.Last(0);
            var PrefC6 = rsi.Result.Last(1);
            
            var C7 = rsiMA.Result.Last(0);
            var C8 = rsiMA.Result.Last(1);

            var BaseLine = bl.Result.Last(0);                           
           
            var Macd = macd.MACD.Last(0);
            var MacdSig = macd.Signal.Last(0);
               
                 
            
            if (C2 > 0  & Symbol.Bid > BaseLine &  C7 > 50  & Macd > MacdSig & Macd > 0 ) 
                  {  Open ( TradeType.Buy, "SSL Buy");        
                      
                   } 
                 
             else if(C2 < 0  & Symbol.Ask < BaseLine & C7 < 50  & Macd < MacdSig & Macd < 0)  
                  {      Open(TradeType.Sell, "SSL Sell");
             
                  
                       
                   }                     
                       
              if (C2 < 0) // & C6 < C7) 
                   {    
                        Close (TradeType.Buy, "SSL Buy");
                   }
                       
               else if (C2 > 0) // & C6 > C7)  
                     {    
                         Close (TradeType.Sell, "SSL Sell");
                         
                     }
    }
           
            // New Function for Opening  trades
                                 
            private void Open(TradeType tradeType, string Label)
                
              { 
                   var ATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
                  
                
                       
                    var position = Positions.Find( Label, SymbolName, tradeType);
        
                  if (position == null & Server.Time.Hour > 1 & Server.Time.Hour < 23)
                        
                    {
                        ExecuteMarketOrder (tradeType , SymbolName ,20, Label, SLM * ATR, TPM * ATR );  //TradeAmount/2
                        
                    }
            }
       
         private void Close(TradeType tradeType, string Label)
       
               {
                        foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
                     
                        ClosePosition(position);
               }
        
       
       
       
        
        
            // Handle cBot stop here
     }
       
    
 }
        
    

 


@trading1

trading1
02 May 2024, 13:10

RE: RE: Problesm with Visual vs non Visual Backtesting

trading1 said: 

PanagiotisCharalampous said: 

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis

Here is the Bot Code .

You can find the parameters I used in the pictures above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
 {

    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class EBOTTRADEIRL: Robot
     {
       
        [Parameter("Risk %", Group = "Risk",DefaultValue = 0.02)]
          public double RiskPCT { get; set; }
        
        [Parameter("ATR MA Type",Group = "ATR")]
        public MovingAverageType ATRMAType { get; set; }
        
        [Parameter("ATR Period", Group = "ATR", DefaultValue = 14)]
            public int ATRPeriod { get; set; }
        
                  
        [Parameter("RSI MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIPeriod { get; set; }
        [Parameter("RSI Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIType { get; set; }
             
          [Parameter("RSIMA MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIMAPeriod { get; set; }
        
        [Parameter("RSIMA Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIMAType { get; set; }    
             
        [Parameter("SSL Period", Group = " SSL ", DefaultValue = 8)]
            public int SSLPeriod{ get; set; }
         
         
         [Parameter("SSL Type", Group = " SSL" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType SSLMAType { get; set; }
            
        [Parameter("Baseline Period", Group = " Baseline ", DefaultValue = 8)]
            public int BLMAPeriod{ get; set; }
         [Parameter("Baseline MA", Group = " Baseline" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType BLMAType { get; set; }    
            
        
        [Parameter("MACD Long Cycle", Group = " MACD ", DefaultValue = 21)]
            public int MACDLong{ get; set; }
       
        [Parameter("MACD Short Cycle", Group = " MACD ", DefaultValue = 8)]
            public int MACDShort{ get; set; }
        [Parameter("MACD Signal", Group = " MACD ", DefaultValue = 12)]
            public int MACDSignal{ get; set; }
                
        
            
       [Parameter("StopLoss Factor", Group = "Risk", DefaultValue = 1)]
        public double SLM { get; set; }
       [Parameter("TakeProfit Factor", Group = "Risk", DefaultValue = 1)]
        public double TPM { get; set; }
        
      
      //Declare Indicators and name them
       
         private AverageTrueRange atr;
         
         private SSLChannel ssl;
         private MovingAverage rsiMA, bl; 
         private RelativeStrengthIndex rsi;
         private MacdCrossOver macd;
         
         public string botName;
         
       
                      

        protected override void OnStart()
        
        
        
       
        
            {  atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Exponential);
               ssl = Indicators.GetIndicator<SSLChannel>(SSLPeriod,SSLMAType);
               rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RSIPeriod);
               rsiMA = Indicators.MovingAverage(rsi.Result, RSIMAPeriod, RSIMAType);
               macd = Indicators.MacdCrossOver(MACDLong, MACDShort, MACDSignal);
               bl = Indicators.MovingAverage(Bars.MedianPrices, BLMAPeriod, BLMAType);
            
            }

        protected override void OnBarClosed()
        {
            
            
                       
            var C2 = ssl._sslUp.Last(0) - ssl._sslDown.Last(0);
            var PrefC2 = ssl._sslUp.Last(1)-ssl._sslDown.Last(1);
            var C2U = ssl._sslUp.Last(0);
            var C2D = ssl._sslDown.Last(0);
            
            
                      
            var C6 = rsi.Result.Last(0);
            var PrefC6 = rsi.Result.Last(1);
            
            var C7 = rsiMA.Result.Last(0);
            var C8 = rsiMA.Result.Last(1);

            var BaseLine = bl.Result.Last(0);                           
           
            var Macd = macd.MACD.Last(0);
            var MacdSig = macd.Signal.Last(0);
               
                 
            
            if (C2 > 0  & Symbol.Bid > BaseLine &  C7 > 50  & Macd > MacdSig & Macd > 0 ) 
                  {  Open ( TradeType.Buy, "SSL Buy");        
                      
                   } 
                 
             else if(C2 < 0  & Symbol.Ask < BaseLine & C7 < 50  & Macd < MacdSig & Macd < 0)  
                  {      Open(TradeType.Sell, "SSL Sell");
             
                  
                       
                   }                     
                       
              if (C2 < 0) // & C6 < C7) 
                   {    
                        Close (TradeType.Buy, "SSL Buy");
                   }
                       
               else if (C2 > 0) // & C6 > C7)  
                     {    
                         Close (TradeType.Sell, "SSL Sell");
                         
                     }
    }
           
            // New Function for Opening  trades
                                 
            private void Open(TradeType tradeType, string Label)
                
              { 
                   var ATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
                  
                
                       
                    var position = Positions.Find( Label, SymbolName, tradeType);
        
                  if (position == null & Server.Time.Hour > 1 & Server.Time.Hour < 23)
                        
                    {
                        ExecuteMarketOrder (tradeType , SymbolName ,20, Label, SLM * ATR, TPM * ATR );  //TradeAmount/2
                        
                    }
            }
       
         private void Close(TradeType tradeType, string Label)
       
               {
                        foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
                     
                        ClosePosition(position);
               }
        
       
       
       
        
        
            // Handle cBot stop here
     }
       
    
 }
        
    

 

As per your suggestion , I ran the bot with Tick data and also found that there is no consistency  in the Visual and non visual testing.

The bot now did not show a profit with the Tick data, but it made 2000 trades more with the non visual vs visual testing and it stopped 2 weeks later when the balance ran to zero.

This is a problem which CTrader must address because it leaves a situation where no algo supplier can be be trusted with their bots on any broker platform.


@trading1

PanagiotisCharalampous
08 May 2024, 05:55

RE: RE: RE: Problesm with Visual vs non Visual Backtesting

trading1 said: 

trading1 said: 

PanagiotisCharalampous said: 

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis

Here is the Bot Code .

You can find the parameters I used in the pictures above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
 {

    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class EBOTTRADEIRL: Robot
     {
       
        [Parameter("Risk %", Group = "Risk",DefaultValue = 0.02)]
          public double RiskPCT { get; set; }
        
        [Parameter("ATR MA Type",Group = "ATR")]
        public MovingAverageType ATRMAType { get; set; }
        
        [Parameter("ATR Period", Group = "ATR", DefaultValue = 14)]
            public int ATRPeriod { get; set; }
        
                  
        [Parameter("RSI MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIPeriod { get; set; }
        [Parameter("RSI Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIType { get; set; }
             
          [Parameter("RSIMA MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIMAPeriod { get; set; }
        
        [Parameter("RSIMA Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIMAType { get; set; }    
             
        [Parameter("SSL Period", Group = " SSL ", DefaultValue = 8)]
            public int SSLPeriod{ get; set; }
         
         
         [Parameter("SSL Type", Group = " SSL" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType SSLMAType { get; set; }
            
        [Parameter("Baseline Period", Group = " Baseline ", DefaultValue = 8)]
            public int BLMAPeriod{ get; set; }
         [Parameter("Baseline MA", Group = " Baseline" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType BLMAType { get; set; }    
            
        
        [Parameter("MACD Long Cycle", Group = " MACD ", DefaultValue = 21)]
            public int MACDLong{ get; set; }
       
        [Parameter("MACD Short Cycle", Group = " MACD ", DefaultValue = 8)]
            public int MACDShort{ get; set; }
        [Parameter("MACD Signal", Group = " MACD ", DefaultValue = 12)]
            public int MACDSignal{ get; set; }
                
        
            
       [Parameter("StopLoss Factor", Group = "Risk", DefaultValue = 1)]
        public double SLM { get; set; }
       [Parameter("TakeProfit Factor", Group = "Risk", DefaultValue = 1)]
        public double TPM { get; set; }
        
      
      //Declare Indicators and name them
       
         private AverageTrueRange atr;
         
         private SSLChannel ssl;
         private MovingAverage rsiMA, bl; 
         private RelativeStrengthIndex rsi;
         private MacdCrossOver macd;
         
         public string botName;
         
       
                      

        protected override void OnStart()
        
        
        
       
        
            {  atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Exponential);
               ssl = Indicators.GetIndicator<SSLChannel>(SSLPeriod,SSLMAType);
               rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RSIPeriod);
               rsiMA = Indicators.MovingAverage(rsi.Result, RSIMAPeriod, RSIMAType);
               macd = Indicators.MacdCrossOver(MACDLong, MACDShort, MACDSignal);
               bl = Indicators.MovingAverage(Bars.MedianPrices, BLMAPeriod, BLMAType);
            
            }

        protected override void OnBarClosed()
        {
            
            
                       
            var C2 = ssl._sslUp.Last(0) - ssl._sslDown.Last(0);
            var PrefC2 = ssl._sslUp.Last(1)-ssl._sslDown.Last(1);
            var C2U = ssl._sslUp.Last(0);
            var C2D = ssl._sslDown.Last(0);
            
            
                      
            var C6 = rsi.Result.Last(0);
            var PrefC6 = rsi.Result.Last(1);
            
            var C7 = rsiMA.Result.Last(0);
            var C8 = rsiMA.Result.Last(1);

            var BaseLine = bl.Result.Last(0);                           
           
            var Macd = macd.MACD.Last(0);
            var MacdSig = macd.Signal.Last(0);
               
                 
            
            if (C2 > 0  & Symbol.Bid > BaseLine &  C7 > 50  & Macd > MacdSig & Macd > 0 ) 
                  {  Open ( TradeType.Buy, "SSL Buy");        
                      
                   } 
                 
             else if(C2 < 0  & Symbol.Ask < BaseLine & C7 < 50  & Macd < MacdSig & Macd < 0)  
                  {      Open(TradeType.Sell, "SSL Sell");
             
                  
                       
                   }                     
                       
              if (C2 < 0) // & C6 < C7) 
                   {    
                        Close (TradeType.Buy, "SSL Buy");
                   }
                       
               else if (C2 > 0) // & C6 > C7)  
                     {    
                         Close (TradeType.Sell, "SSL Sell");
                         
                     }
    }
           
            // New Function for Opening  trades
                                 
            private void Open(TradeType tradeType, string Label)
                
              { 
                   var ATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
                  
                
                       
                    var position = Positions.Find( Label, SymbolName, tradeType);
        
                  if (position == null & Server.Time.Hour > 1 & Server.Time.Hour < 23)
                        
                    {
                        ExecuteMarketOrder (tradeType , SymbolName ,20, Label, SLM * ATR, TPM * ATR );  //TradeAmount/2
                        
                    }
            }
       
         private void Close(TradeType tradeType, string Label)
       
               {
                        foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
                     
                        ClosePosition(position);
               }
        
       
       
       
        
        
            // Handle cBot stop here
     }
       
    
 }
        
    

 

As per your suggestion , I ran the bot with Tick data and also found that there is no consistency  in the Visual and non visual testing.

The bot now did not show a profit with the Tick data, but it made 2000 trades more with the non visual vs visual testing and it stopped 2 weeks later when the balance ran to zero.

This is a problem which CTrader must address because it leaves a situation where no algo supplier can be be trusted with their bots on any broker platform.

Hi there,

We are still missing the SSL Channel indicator you are using. Can you please share it with us?

Best regards,

Panagiotis


@PanagiotisCharalampous

trading1
08 May 2024, 19:29

RE: RE: RE: RE: Problesm with Visual vs non Visual Backtesting

PanagiotisCharalampous said: 

trading1 said: 

trading1 said: 

PanagiotisCharalampous said: 

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis

Here is the Bot Code .

You can find the parameters I used in the pictures above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
 {

    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class EBOTTRADEIRL: Robot
     {
       
        [Parameter("Risk %", Group = "Risk",DefaultValue = 0.02)]
          public double RiskPCT { get; set; }
        
        [Parameter("ATR MA Type",Group = "ATR")]
        public MovingAverageType ATRMAType { get; set; }
        
        [Parameter("ATR Period", Group = "ATR", DefaultValue = 14)]
            public int ATRPeriod { get; set; }
        
                  
        [Parameter("RSI MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIPeriod { get; set; }
        [Parameter("RSI Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIType { get; set; }
             
          [Parameter("RSIMA MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIMAPeriod { get; set; }
        
        [Parameter("RSIMA Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIMAType { get; set; }    
             
        [Parameter("SSL Period", Group = " SSL ", DefaultValue = 8)]
            public int SSLPeriod{ get; set; }
         
         
         [Parameter("SSL Type", Group = " SSL" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType SSLMAType { get; set; }
            
        [Parameter("Baseline Period", Group = " Baseline ", DefaultValue = 8)]
            public int BLMAPeriod{ get; set; }
         [Parameter("Baseline MA", Group = " Baseline" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType BLMAType { get; set; }    
            
        
        [Parameter("MACD Long Cycle", Group = " MACD ", DefaultValue = 21)]
            public int MACDLong{ get; set; }
       
        [Parameter("MACD Short Cycle", Group = " MACD ", DefaultValue = 8)]
            public int MACDShort{ get; set; }
        [Parameter("MACD Signal", Group = " MACD ", DefaultValue = 12)]
            public int MACDSignal{ get; set; }
                
        
            
       [Parameter("StopLoss Factor", Group = "Risk", DefaultValue = 1)]
        public double SLM { get; set; }
       [Parameter("TakeProfit Factor", Group = "Risk", DefaultValue = 1)]
        public double TPM { get; set; }
        
      
      //Declare Indicators and name them
       
         private AverageTrueRange atr;
         
         private SSLChannel ssl;
         private MovingAverage rsiMA, bl; 
         private RelativeStrengthIndex rsi;
         private MacdCrossOver macd;
         
         public string botName;
         
       
                      

        protected override void OnStart()
        
        
        
       
        
            {  atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Exponential);
               ssl = Indicators.GetIndicator<SSLChannel>(SSLPeriod,SSLMAType);
               rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RSIPeriod);
               rsiMA = Indicators.MovingAverage(rsi.Result, RSIMAPeriod, RSIMAType);
               macd = Indicators.MacdCrossOver(MACDLong, MACDShort, MACDSignal);
               bl = Indicators.MovingAverage(Bars.MedianPrices, BLMAPeriod, BLMAType);
            
            }

        protected override void OnBarClosed()
        {
            
            
                       
            var C2 = ssl._sslUp.Last(0) - ssl._sslDown.Last(0);
            var PrefC2 = ssl._sslUp.Last(1)-ssl._sslDown.Last(1);
            var C2U = ssl._sslUp.Last(0);
            var C2D = ssl._sslDown.Last(0);
            
            
                      
            var C6 = rsi.Result.Last(0);
            var PrefC6 = rsi.Result.Last(1);
            
            var C7 = rsiMA.Result.Last(0);
            var C8 = rsiMA.Result.Last(1);

            var BaseLine = bl.Result.Last(0);                           
           
            var Macd = macd.MACD.Last(0);
            var MacdSig = macd.Signal.Last(0);
               
                 
            
            if (C2 > 0  & Symbol.Bid > BaseLine &  C7 > 50  & Macd > MacdSig & Macd > 0 ) 
                  {  Open ( TradeType.Buy, "SSL Buy");        
                      
                   } 
                 
             else if(C2 < 0  & Symbol.Ask < BaseLine & C7 < 50  & Macd < MacdSig & Macd < 0)  
                  {      Open(TradeType.Sell, "SSL Sell");
             
                  
                       
                   }                     
                       
              if (C2 < 0) // & C6 < C7) 
                   {    
                        Close (TradeType.Buy, "SSL Buy");
                   }
                       
               else if (C2 > 0) // & C6 > C7)  
                     {    
                         Close (TradeType.Sell, "SSL Sell");
                         
                     }
    }
           
            // New Function for Opening  trades
                                 
            private void Open(TradeType tradeType, string Label)
                
              { 
                   var ATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
                  
                
                       
                    var position = Positions.Find( Label, SymbolName, tradeType);
        
                  if (position == null & Server.Time.Hour > 1 & Server.Time.Hour < 23)
                        
                    {
                        ExecuteMarketOrder (tradeType , SymbolName ,20, Label, SLM * ATR, TPM * ATR );  //TradeAmount/2
                        
                    }
            }
       
         private void Close(TradeType tradeType, string Label)
       
               {
                        foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
                     
                        ClosePosition(position);
               }
        
       
       
       
        
        
            // Handle cBot stop here
     }
       
    
 }
        
    

 

As per your suggestion , I ran the bot with Tick data and also found that there is no consistency  in the Visual and non visual testing.

The bot now did not show a profit with the Tick data, but it made 2000 trades more with the non visual vs visual testing and it stopped 2 weeks later when the balance ran to zero.

This is a problem which CTrader must address because it leaves a situation where no algo supplier can be be trusted with their bots on any broker platform.

Hi there,

We are still missing the SSL Channel indicator you are using. Can you please share it with us?

Best regards,

Panagiotis

You can find the SSL indicator on the community indicators forum at Spotware. but as you can see from the code I did not use it.


@trading1

PanagiotisCharalampous
09 May 2024, 05:38

RE: RE: RE: RE: RE: Problesm with Visual vs non Visual Backtesting

trading1 said: 

PanagiotisCharalampous said: 

trading1 said: 

trading1 said: 

PanagiotisCharalampous said: 

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis

Here is the Bot Code .

You can find the parameters I used in the pictures above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
 {

    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class EBOTTRADEIRL: Robot
     {
       
        [Parameter("Risk %", Group = "Risk",DefaultValue = 0.02)]
          public double RiskPCT { get; set; }
        
        [Parameter("ATR MA Type",Group = "ATR")]
        public MovingAverageType ATRMAType { get; set; }
        
        [Parameter("ATR Period", Group = "ATR", DefaultValue = 14)]
            public int ATRPeriod { get; set; }
        
                  
        [Parameter("RSI MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIPeriod { get; set; }
        [Parameter("RSI Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIType { get; set; }
             
          [Parameter("RSIMA MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIMAPeriod { get; set; }
        
        [Parameter("RSIMA Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIMAType { get; set; }    
             
        [Parameter("SSL Period", Group = " SSL ", DefaultValue = 8)]
            public int SSLPeriod{ get; set; }
         
         
         [Parameter("SSL Type", Group = " SSL" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType SSLMAType { get; set; }
            
        [Parameter("Baseline Period", Group = " Baseline ", DefaultValue = 8)]
            public int BLMAPeriod{ get; set; }
         [Parameter("Baseline MA", Group = " Baseline" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType BLMAType { get; set; }    
            
        
        [Parameter("MACD Long Cycle", Group = " MACD ", DefaultValue = 21)]
            public int MACDLong{ get; set; }
       
        [Parameter("MACD Short Cycle", Group = " MACD ", DefaultValue = 8)]
            public int MACDShort{ get; set; }
        [Parameter("MACD Signal", Group = " MACD ", DefaultValue = 12)]
            public int MACDSignal{ get; set; }
                
        
            
       [Parameter("StopLoss Factor", Group = "Risk", DefaultValue = 1)]
        public double SLM { get; set; }
       [Parameter("TakeProfit Factor", Group = "Risk", DefaultValue = 1)]
        public double TPM { get; set; }
        
      
      //Declare Indicators and name them
       
         private AverageTrueRange atr;
         
         private SSLChannel ssl;
         private MovingAverage rsiMA, bl; 
         private RelativeStrengthIndex rsi;
         private MacdCrossOver macd;
         
         public string botName;
         
       
                      

        protected override void OnStart()
        
        
        
       
        
            {  atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Exponential);
               ssl = Indicators.GetIndicator<SSLChannel>(SSLPeriod,SSLMAType);
               rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RSIPeriod);
               rsiMA = Indicators.MovingAverage(rsi.Result, RSIMAPeriod, RSIMAType);
               macd = Indicators.MacdCrossOver(MACDLong, MACDShort, MACDSignal);
               bl = Indicators.MovingAverage(Bars.MedianPrices, BLMAPeriod, BLMAType);
            
            }

        protected override void OnBarClosed()
        {
            
            
                       
            var C2 = ssl._sslUp.Last(0) - ssl._sslDown.Last(0);
            var PrefC2 = ssl._sslUp.Last(1)-ssl._sslDown.Last(1);
            var C2U = ssl._sslUp.Last(0);
            var C2D = ssl._sslDown.Last(0);
            
            
                      
            var C6 = rsi.Result.Last(0);
            var PrefC6 = rsi.Result.Last(1);
            
            var C7 = rsiMA.Result.Last(0);
            var C8 = rsiMA.Result.Last(1);

            var BaseLine = bl.Result.Last(0);                           
           
            var Macd = macd.MACD.Last(0);
            var MacdSig = macd.Signal.Last(0);
               
                 
            
            if (C2 > 0  & Symbol.Bid > BaseLine &  C7 > 50  & Macd > MacdSig & Macd > 0 ) 
                  {  Open ( TradeType.Buy, "SSL Buy");        
                      
                   } 
                 
             else if(C2 < 0  & Symbol.Ask < BaseLine & C7 < 50  & Macd < MacdSig & Macd < 0)  
                  {      Open(TradeType.Sell, "SSL Sell");
             
                  
                       
                   }                     
                       
              if (C2 < 0) // & C6 < C7) 
                   {    
                        Close (TradeType.Buy, "SSL Buy");
                   }
                       
               else if (C2 > 0) // & C6 > C7)  
                     {    
                         Close (TradeType.Sell, "SSL Sell");
                         
                     }
    }
           
            // New Function for Opening  trades
                                 
            private void Open(TradeType tradeType, string Label)
                
              { 
                   var ATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
                  
                
                       
                    var position = Positions.Find( Label, SymbolName, tradeType);
        
                  if (position == null & Server.Time.Hour > 1 & Server.Time.Hour < 23)
                        
                    {
                        ExecuteMarketOrder (tradeType , SymbolName ,20, Label, SLM * ATR, TPM * ATR );  //TradeAmount/2
                        
                    }
            }
       
         private void Close(TradeType tradeType, string Label)
       
               {
                        foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
                     
                        ClosePosition(position);
               }
        
       
       
       
        
        
            // Handle cBot stop here
     }
       
    
 }
        
    

 

As per your suggestion , I ran the bot with Tick data and also found that there is no consistency  in the Visual and non visual testing.

The bot now did not show a profit with the Tick data, but it made 2000 trades more with the non visual vs visual testing and it stopped 2 weeks later when the balance ran to zero.

This is a problem which CTrader must address because it leaves a situation where no algo supplier can be be trusted with their bots on any broker platform.

Hi there,

We are still missing the SSL Channel indicator you are using. Can you please share it with us?

Best regards,

Panagiotis

You can find the SSL indicator on the community indicators forum at Spotware. but as you can see from the code I did not use it.

The code does not build without the indicator. Please either provide a link to the actual indicator or provide cBot code that builds without the need of a reference


@PanagiotisCharalampous

trading1
09 May 2024, 08:24

RE: RE: RE: RE: RE: RE: Problesm with Visual vs non Visual Backtesting

PanagiotisCharalampous said: 

trading1 said: 

PanagiotisCharalampous said: 

trading1 said: 

trading1 said: 

PanagiotisCharalampous said: 

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis

Here is the Bot Code .

You can find the parameters I used in the pictures above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
 {

    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class EBOTTRADEIRL: Robot
     {
       
        [Parameter("Risk %", Group = "Risk",DefaultValue = 0.02)]
          public double RiskPCT { get; set; }
        
        [Parameter("ATR MA Type",Group = "ATR")]
        public MovingAverageType ATRMAType { get; set; }
        
        [Parameter("ATR Period", Group = "ATR", DefaultValue = 14)]
            public int ATRPeriod { get; set; }
        
                  
        [Parameter("RSI MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIPeriod { get; set; }
        [Parameter("RSI Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIType { get; set; }
             
          [Parameter("RSIMA MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIMAPeriod { get; set; }
        
        [Parameter("RSIMA Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIMAType { get; set; }    
             
        [Parameter("SSL Period", Group = " SSL ", DefaultValue = 8)]
            public int SSLPeriod{ get; set; }
         
         
         [Parameter("SSL Type", Group = " SSL" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType SSLMAType { get; set; }
            
        [Parameter("Baseline Period", Group = " Baseline ", DefaultValue = 8)]
            public int BLMAPeriod{ get; set; }
         [Parameter("Baseline MA", Group = " Baseline" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType BLMAType { get; set; }    
            
        
        [Parameter("MACD Long Cycle", Group = " MACD ", DefaultValue = 21)]
            public int MACDLong{ get; set; }
       
        [Parameter("MACD Short Cycle", Group = " MACD ", DefaultValue = 8)]
            public int MACDShort{ get; set; }
        [Parameter("MACD Signal", Group = " MACD ", DefaultValue = 12)]
            public int MACDSignal{ get; set; }
                
        
            
       [Parameter("StopLoss Factor", Group = "Risk", DefaultValue = 1)]
        public double SLM { get; set; }
       [Parameter("TakeProfit Factor", Group = "Risk", DefaultValue = 1)]
        public double TPM { get; set; }
        
      
      //Declare Indicators and name them
       
         private AverageTrueRange atr;
         
         private SSLChannel ssl;
         private MovingAverage rsiMA, bl; 
         private RelativeStrengthIndex rsi;
         private MacdCrossOver macd;
         
         public string botName;
         
       
                      

        protected override void OnStart()
        
        
        
       
        
            {  atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Exponential);
               ssl = Indicators.GetIndicator<SSLChannel>(SSLPeriod,SSLMAType);
               rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RSIPeriod);
               rsiMA = Indicators.MovingAverage(rsi.Result, RSIMAPeriod, RSIMAType);
               macd = Indicators.MacdCrossOver(MACDLong, MACDShort, MACDSignal);
               bl = Indicators.MovingAverage(Bars.MedianPrices, BLMAPeriod, BLMAType);
            
            }

        protected override void OnBarClosed()
        {
            
            
                       
            var C2 = ssl._sslUp.Last(0) - ssl._sslDown.Last(0);
            var PrefC2 = ssl._sslUp.Last(1)-ssl._sslDown.Last(1);
            var C2U = ssl._sslUp.Last(0);
            var C2D = ssl._sslDown.Last(0);
            
            
                      
            var C6 = rsi.Result.Last(0);
            var PrefC6 = rsi.Result.Last(1);
            
            var C7 = rsiMA.Result.Last(0);
            var C8 = rsiMA.Result.Last(1);

            var BaseLine = bl.Result.Last(0);                           
           
            var Macd = macd.MACD.Last(0);
            var MacdSig = macd.Signal.Last(0);
               
                 
            
            if (C2 > 0  & Symbol.Bid > BaseLine &  C7 > 50  & Macd > MacdSig & Macd > 0 ) 
                  {  Open ( TradeType.Buy, "SSL Buy");        
                      
                   } 
                 
             else if(C2 < 0  & Symbol.Ask < BaseLine & C7 < 50  & Macd < MacdSig & Macd < 0)  
                  {      Open(TradeType.Sell, "SSL Sell");
             
                  
                       
                   }                     
                       
              if (C2 < 0) // & C6 < C7) 
                   {    
                        Close (TradeType.Buy, "SSL Buy");
                   }
                       
               else if (C2 > 0) // & C6 > C7)  
                     {    
                         Close (TradeType.Sell, "SSL Sell");
                         
                     }
    }
           
            // New Function for Opening  trades
                                 
            private void Open(TradeType tradeType, string Label)
                
              { 
                   var ATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
                  
                
                       
                    var position = Positions.Find( Label, SymbolName, tradeType);
        
                  if (position == null & Server.Time.Hour > 1 & Server.Time.Hour < 23)
                        
                    {
                        ExecuteMarketOrder (tradeType , SymbolName ,20, Label, SLM * ATR, TPM * ATR );  //TradeAmount/2
                        
                    }
            }
       
         private void Close(TradeType tradeType, string Label)
       
               {
                        foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
                     
                        ClosePosition(position);
               }
        
       
       
       
        
        
            // Handle cBot stop here
     }
       
    
 }
        
    

 

As per your suggestion , I ran the bot with Tick data and also found that there is no consistency  in the Visual and non visual testing.

The bot now did not show a profit with the Tick data, but it made 2000 trades more with the non visual vs visual testing and it stopped 2 weeks later when the balance ran to zero.

This is a problem which CTrader must address because it leaves a situation where no algo supplier can be be trusted with their bots on any broker platform.

Hi there,

We are still missing the SSL Channel indicator you are using. Can you please share it with us?

Best regards,

Panagiotis

You can find the SSL indicator on the community indicators forum at Spotware. but as you can see from the code I did not use it.

The code does not build without the indicator. Please either provide a link to the actual indicator or provide cBot code that builds without the need of a reference

Apologies I see I used it. You can get the SSL Channel indicator on the CTrader indicators pages.


@trading1

... Deleted by UFO ...

PanagiotisCharalampous
09 May 2024, 12:33

RE: RE: RE: RE: RE: RE: RE: Problesm with Visual vs non Visual Backtesting

trading1 said: 

PanagiotisCharalampous said: 

trading1 said: 

PanagiotisCharalampous said: 

trading1 said: 

trading1 said: 

PanagiotisCharalampous said: 

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis

Here is the Bot Code .

You can find the parameters I used in the pictures above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
 {

    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class EBOTTRADEIRL: Robot
     {
       
        [Parameter("Risk %", Group = "Risk",DefaultValue = 0.02)]
          public double RiskPCT { get; set; }
        
        [Parameter("ATR MA Type",Group = "ATR")]
        public MovingAverageType ATRMAType { get; set; }
        
        [Parameter("ATR Period", Group = "ATR", DefaultValue = 14)]
            public int ATRPeriod { get; set; }
        
                  
        [Parameter("RSI MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIPeriod { get; set; }
        [Parameter("RSI Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIType { get; set; }
             
          [Parameter("RSIMA MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIMAPeriod { get; set; }
        
        [Parameter("RSIMA Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIMAType { get; set; }    
             
        [Parameter("SSL Period", Group = " SSL ", DefaultValue = 8)]
            public int SSLPeriod{ get; set; }
         
         
         [Parameter("SSL Type", Group = " SSL" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType SSLMAType { get; set; }
            
        [Parameter("Baseline Period", Group = " Baseline ", DefaultValue = 8)]
            public int BLMAPeriod{ get; set; }
         [Parameter("Baseline MA", Group = " Baseline" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType BLMAType { get; set; }    
            
        
        [Parameter("MACD Long Cycle", Group = " MACD ", DefaultValue = 21)]
            public int MACDLong{ get; set; }
       
        [Parameter("MACD Short Cycle", Group = " MACD ", DefaultValue = 8)]
            public int MACDShort{ get; set; }
        [Parameter("MACD Signal", Group = " MACD ", DefaultValue = 12)]
            public int MACDSignal{ get; set; }
                
        
            
       [Parameter("StopLoss Factor", Group = "Risk", DefaultValue = 1)]
        public double SLM { get; set; }
       [Parameter("TakeProfit Factor", Group = "Risk", DefaultValue = 1)]
        public double TPM { get; set; }
        
      
      //Declare Indicators and name them
       
         private AverageTrueRange atr;
         
         private SSLChannel ssl;
         private MovingAverage rsiMA, bl; 
         private RelativeStrengthIndex rsi;
         private MacdCrossOver macd;
         
         public string botName;
         
       
                      

        protected override void OnStart()
        
        
        
       
        
            {  atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Exponential);
               ssl = Indicators.GetIndicator<SSLChannel>(SSLPeriod,SSLMAType);
               rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RSIPeriod);
               rsiMA = Indicators.MovingAverage(rsi.Result, RSIMAPeriod, RSIMAType);
               macd = Indicators.MacdCrossOver(MACDLong, MACDShort, MACDSignal);
               bl = Indicators.MovingAverage(Bars.MedianPrices, BLMAPeriod, BLMAType);
            
            }

        protected override void OnBarClosed()
        {
            
            
                       
            var C2 = ssl._sslUp.Last(0) - ssl._sslDown.Last(0);
            var PrefC2 = ssl._sslUp.Last(1)-ssl._sslDown.Last(1);
            var C2U = ssl._sslUp.Last(0);
            var C2D = ssl._sslDown.Last(0);
            
            
                      
            var C6 = rsi.Result.Last(0);
            var PrefC6 = rsi.Result.Last(1);
            
            var C7 = rsiMA.Result.Last(0);
            var C8 = rsiMA.Result.Last(1);

            var BaseLine = bl.Result.Last(0);                           
           
            var Macd = macd.MACD.Last(0);
            var MacdSig = macd.Signal.Last(0);
               
                 
            
            if (C2 > 0  & Symbol.Bid > BaseLine &  C7 > 50  & Macd > MacdSig & Macd > 0 ) 
                  {  Open ( TradeType.Buy, "SSL Buy");        
                      
                   } 
                 
             else if(C2 < 0  & Symbol.Ask < BaseLine & C7 < 50  & Macd < MacdSig & Macd < 0)  
                  {      Open(TradeType.Sell, "SSL Sell");
             
                  
                       
                   }                     
                       
              if (C2 < 0) // & C6 < C7) 
                   {    
                        Close (TradeType.Buy, "SSL Buy");
                   }
                       
               else if (C2 > 0) // & C6 > C7)  
                     {    
                         Close (TradeType.Sell, "SSL Sell");
                         
                     }
    }
           
            // New Function for Opening  trades
                                 
            private void Open(TradeType tradeType, string Label)
                
              { 
                   var ATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
                  
                
                       
                    var position = Positions.Find( Label, SymbolName, tradeType);
        
                  if (position == null & Server.Time.Hour > 1 & Server.Time.Hour < 23)
                        
                    {
                        ExecuteMarketOrder (tradeType , SymbolName ,20, Label, SLM * ATR, TPM * ATR );  //TradeAmount/2
                        
                    }
            }
       
         private void Close(TradeType tradeType, string Label)
       
               {
                        foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
                     
                        ClosePosition(position);
               }
        
       
       
       
        
        
            // Handle cBot stop here
     }
       
    
 }
        
    

 

As per your suggestion , I ran the bot with Tick data and also found that there is no consistency  in the Visual and non visual testing.

The bot now did not show a profit with the Tick data, but it made 2000 trades more with the non visual vs visual testing and it stopped 2 weeks later when the balance ran to zero.

This is a problem which CTrader must address because it leaves a situation where no algo supplier can be be trusted with their bots on any broker platform.

Hi there,

We are still missing the SSL Channel indicator you are using. Can you please share it with us?

Best regards,

Panagiotis

You can find the SSL indicator on the community indicators forum at Spotware. but as you can see from the code I did not use it.

The code does not build without the indicator. Please either provide a link to the actual indicator or provide cBot code that builds without the need of a reference

Apologies I see I used it. You can get the SSL Channel indicator on the CTrader indicators pages.

I need the link please


@PanagiotisCharalampous

trading1
10 May 2024, 07:29 ( Updated at: 10 May 2024, 13:57 )

RE: RE: RE: RE: RE: RE: RE: RE: Problesm with Visual vs non Visual Backtesting

PanagiotisCharalampous said: 

trading1 said: 

PanagiotisCharalampous said: 

trading1 said: 

PanagiotisCharalampous said: 

trading1 said: 

trading1 said: 

PanagiotisCharalampous said: 

Hi there,

If you can share the cBot code, we can have a look. Also make sure you use tick data for your backtesting.

Best regards,

Panagiotis

Here is the Bot Code .

You can find the parameters I used in the pictures above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
 {

    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class EBOTTRADEIRL: Robot
     {
       
        [Parameter("Risk %", Group = "Risk",DefaultValue = 0.02)]
          public double RiskPCT { get; set; }
        
        [Parameter("ATR MA Type",Group = "ATR")]
        public MovingAverageType ATRMAType { get; set; }
        
        [Parameter("ATR Period", Group = "ATR", DefaultValue = 14)]
            public int ATRPeriod { get; set; }
        
                  
        [Parameter("RSI MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIPeriod { get; set; }
        [Parameter("RSI Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIType { get; set; }
             
          [Parameter("RSIMA MA Period", Group = " RSI", DefaultValue = 8)]
            public int RSIMAPeriod { get; set; }
        
        [Parameter("RSIMA Type", Group = " RSI" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType RSIMAType { get; set; }    
             
        [Parameter("SSL Period", Group = " SSL ", DefaultValue = 8)]
            public int SSLPeriod{ get; set; }
         
         
         [Parameter("SSL Type", Group = " SSL" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType SSLMAType { get; set; }
            
        [Parameter("Baseline Period", Group = " Baseline ", DefaultValue = 8)]
            public int BLMAPeriod{ get; set; }
         [Parameter("Baseline MA", Group = " Baseline" , DefaultValue = MovingAverageType.Exponential)]
             public MovingAverageType BLMAType { get; set; }    
            
        
        [Parameter("MACD Long Cycle", Group = " MACD ", DefaultValue = 21)]
            public int MACDLong{ get; set; }
       
        [Parameter("MACD Short Cycle", Group = " MACD ", DefaultValue = 8)]
            public int MACDShort{ get; set; }
        [Parameter("MACD Signal", Group = " MACD ", DefaultValue = 12)]
            public int MACDSignal{ get; set; }
                
        
            
       [Parameter("StopLoss Factor", Group = "Risk", DefaultValue = 1)]
        public double SLM { get; set; }
       [Parameter("TakeProfit Factor", Group = "Risk", DefaultValue = 1)]
        public double TPM { get; set; }
        
      
      //Declare Indicators and name them
       
         private AverageTrueRange atr;
         
         private SSLChannel ssl;
         private MovingAverage rsiMA, bl; 
         private RelativeStrengthIndex rsi;
         private MacdCrossOver macd;
         
         public string botName;
         
       
                      

        protected override void OnStart()
        
        
        
       
        
            {  atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.Exponential);
               ssl = Indicators.GetIndicator<SSLChannel>(SSLPeriod,SSLMAType);
               rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, RSIPeriod);
               rsiMA = Indicators.MovingAverage(rsi.Result, RSIMAPeriod, RSIMAType);
               macd = Indicators.MacdCrossOver(MACDLong, MACDShort, MACDSignal);
               bl = Indicators.MovingAverage(Bars.MedianPrices, BLMAPeriod, BLMAType);
            
            }

        protected override void OnBarClosed()
        {
            
            
                       
            var C2 = ssl._sslUp.Last(0) - ssl._sslDown.Last(0);
            var PrefC2 = ssl._sslUp.Last(1)-ssl._sslDown.Last(1);
            var C2U = ssl._sslUp.Last(0);
            var C2D = ssl._sslDown.Last(0);
            
            
                      
            var C6 = rsi.Result.Last(0);
            var PrefC6 = rsi.Result.Last(1);
            
            var C7 = rsiMA.Result.Last(0);
            var C8 = rsiMA.Result.Last(1);

            var BaseLine = bl.Result.Last(0);                           
           
            var Macd = macd.MACD.Last(0);
            var MacdSig = macd.Signal.Last(0);
               
                 
            
            if (C2 > 0  & Symbol.Bid > BaseLine &  C7 > 50  & Macd > MacdSig & Macd > 0 ) 
                  {  Open ( TradeType.Buy, "SSL Buy");        
                      
                   } 
                 
             else if(C2 < 0  & Symbol.Ask < BaseLine & C7 < 50  & Macd < MacdSig & Macd < 0)  
                  {      Open(TradeType.Sell, "SSL Sell");
             
                  
                       
                   }                     
                       
              if (C2 < 0) // & C6 < C7) 
                   {    
                        Close (TradeType.Buy, "SSL Buy");
                   }
                       
               else if (C2 > 0) // & C6 > C7)  
                     {    
                         Close (TradeType.Sell, "SSL Sell");
                         
                     }
    }
           
            // New Function for Opening  trades
                                 
            private void Open(TradeType tradeType, string Label)
                
              { 
                   var ATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
                  
                
                       
                    var position = Positions.Find( Label, SymbolName, tradeType);
        
                  if (position == null & Server.Time.Hour > 1 & Server.Time.Hour < 23)
                        
                    {
                        ExecuteMarketOrder (tradeType , SymbolName ,20, Label, SLM * ATR, TPM * ATR );  //TradeAmount/2
                        
                    }
            }
       
         private void Close(TradeType tradeType, string Label)
       
               {
                        foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
                     
                        ClosePosition(position);
               }
        
       
       
       
        
        
            // Handle cBot stop here
     }
       
    
 }
        
    

 

As per your suggestion , I ran the bot with Tick data and also found that there is no consistency  in the Visual and non visual testing.

The bot now did not show a profit with the Tick data, but it made 2000 trades more with the non visual vs visual testing and it stopped 2 weeks later when the balance ran to zero.

This is a problem which CTrader must address because it leaves a situation where no algo supplier can be be trusted with their bots on any broker platform.

Hi there,

We are still missing the SSL Channel indicator you are using. Can you please share it with us?

Best regards,

Panagiotis

You can find the SSL indicator on the community indicators forum at Spotware. but as you can see from the code I did not use it.

The code does not build without the indicator. Please either provide a link to the actual indicator or provide cBot code that builds without the need of a reference

Apologies I see I used it. You can get the SSL Channel indicator on the CTrader indicators pages.

I need the link please

https://ctrader.com/algos/indicators/show/2151


@trading1

PanagiotisCharalampous
11 May 2024, 07:01

I checked both cases with tick data and the results are identical

Best  regards,


@PanagiotisCharalampous

ncel01
16 May 2024, 19:15

Hi Panagiotis,

Apparently this issue is still in present in v5.0.19.

Aren't the results suppose to match 100% regardless of which data bars are selected, on condition that the same data is used in both visual/non-visual modes?
Anyway, running backtests on tick data for every strategy iteration can be impractical.

It doesn't seem logical (at all) to me that checking/unchecking the visual mode box should affect results when the all the underlying data remains the same.
Given this, it is highly unlikely that this is a user or cBot issue, suggesting an issue within cTrader's backtesting logic.

As you know, backtesting is crucial for traders to evaluate cBot logic accurately.
Solving this inconsistency is central for traders to have confidence in their backtesting and, as a result, being confident about their cBot development process.

Last but not least, this issue has been reported multiple times.
When will this finally be addressed?

Thanks for your understanding.


@ncel01

PanagiotisCharalampous
17 May 2024, 06:30

RE: Problesm with Visual vs non Visual Backtesting

ncel01 said: 

Hi Panagiotis,

Apparently this issue is still in present in v5.0.19.

Aren't the results suppose to match 100% regardless of which data bars are selected, on condition that the same data is used in both visual/non-visual modes?
Anyway, running backtests on tick data for every strategy iteration can be impractical.

It doesn't seem logical (at all) to me that checking/unchecking the visual mode box should affect results when the all the underlying data remains the same.
Given this, it is highly unlikely that this is a user or cBot issue, suggesting an issue within cTrader's backtesting logic.

As you know, backtesting is crucial for traders to evaluate cBot logic accurately.
Solving this inconsistency is central for traders to have confidence in their backtesting and, as a result, being confident about their cBot development process.

Last but not least, this issue has been reported multiple times.
When will this finally be addressed?

Thanks for your understanding.

Hi ncel01,

The plan is to fix this issue in 5.1

Best regards,

Panagiotis


@PanagiotisCharalampous

ncel01
17 May 2024, 11:12

RE: RE: Problesm with Visual vs non Visual Backtesting

PanagiotisCharalampous said: 

ncel01 said: 

Hi Panagiotis,

Apparently this issue is still in present in v5.0.19.

Aren't the results suppose to match 100% regardless of which data bars are selected, on condition that the same data is used in both visual/non-visual modes?
Anyway, running backtests on tick data for every strategy iteration can be impractical.

It doesn't seem logical (at all) to me that checking/unchecking the visual mode box should affect results when the all the underlying data remains the same.
Given this, it is highly unlikely that this is a user or cBot issue, suggesting an issue within cTrader's backtesting logic.

As you know, backtesting is crucial for traders to evaluate cBot logic accurately.
Solving this inconsistency is central for traders to have confidence in their backtesting and, as a result, being confident about their cBot development process.

Last but not least, this issue has been reported multiple times.
When will this finally be addressed?

Thanks for your understanding.

Hi ncel01,

The plan is to fix this issue in 5.1

Best regards,

Panagiotis

Panagiotis,

That's good to hear!

Thanks for informing.


@ncel01