Panel Not Displaying in Backtest Mode with Custom Indicator

Created at 24 Oct 2024, 12:06
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!
JK

jkaran.sharma101

Joined 12.03.2024

Panel Not Displaying in Backtest Mode with Custom Indicator
24 Oct 2024, 12:06


Hello fellow traders,

I'm encountering an issue with my custom indicator in cTrader. When I add my indicator during a backtest session, the custom panel I’ve coded is not showing up. However, it works perfectly when the indicator is added during live trading.

Here’s a brief overview of my setup:

Code Structure:

  • I’m using WPF to create a custom window in cAlgo, and the window is supposed to display a message.
  • This window appears fine when I run the bot during live trading, but when I switch to backtesting, the window doesn't show.

Screenshots:

  • Live Trading (Working):
  • Backtesting (Not Working):

Code Snippet:

namespace cAlgo
{
   [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class DockPanelSample : Indicator
   {
       protected override void Initialize()
       {
           var window = new Window
           {
               Child = new TextBlock 
               {
                   Text = "Hi, This is my Window!",
                   VerticalAlignment = VerticalAlignment.Center,
                   HorizontalAlignment = HorizontalAlignment.Center,
                   FontSize = 20,
                   FontWeight = FontWeight.UltraBold
               },
               Title = "My Window",
               WindowStartupLocation = WindowStartupLocation.CenterScreen,
               Topmost = true
           };            

           window.Show();
       }

       public override void Calculate(int index)
       {
       }
   }
}


I've tried various tweaks, but the issue persists. It seems like the window isn't being initialized correctly when the indicator is run in the backtest mode. Any idea why this behavior might be happening in backtesting?

Any help would be appreciated!

Thanks in advance!


@jkaran.sharma101
Replies

PanagiotisCharalampous
24 Oct 2024, 12:36

Hi there,

Did you try Visual Mode. It will definitely not work in non Visual Mode.

Best regards,

Panagiotis


@PanagiotisCharalampous

jkaran.sharma101
24 Oct 2024, 12:53

RE: Panel Not Displaying in Backtest Mode with Custom Indicator

PanagiotisCharalampous said: 

Hi there,

Did you try Visual Mode. It will definitely not work in non Visual Mode.

Best regards,

Panagiotis

Hi Panagiotis,

Thanks for the suggestion! You’re right, the panel does show up in Visual Mode during the backtest.

However, what I’m aiming for is to have the indicator display the window after the backtest is completed, regardless of whether it's in Visual Mode or not. The idea is that once the backtest finishes, I should be able to add the indicator and have the panel/window display normally.

Currently, the window only shows up during the backtest in Visual Mode, but once the backtest is over and I try adding the indicator afterward, no window appears at all. This happens both in Visual and non-Visual modes after the backtest has been completed.

Any thoughts on why this might be happening or how I can resolve it?

Thanks again for your help!


@jkaran.sharma101