Backtesting doesn't work as expected with the Indicator api

Created at 02 May 2022, 16:12
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!
CN

cnnhean

Joined 02.05.2022

Backtesting doesn't work as expected with the Indicator api
02 May 2022, 16:12


Backtesting doesn't work as expected with the Indicator api. 

Take "FreeMargin"(freemargin api page reference) for example,
If you try to read the value while backtesting, it really doesn't returns the value seen in the simulation. 
As you can see here:


From my speculation, it has to do with "account" not referencing the "temp", simulated account from the backtesting session. 
Any way i can have an indicator that access this information?
I'm trying to test my bot, while analyzing the situation and his actions with an indicator, in the backtesting visual mode.  


Feel free to use this to test it yourself. 

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
    public class MarginLevel : Indicator
    {


        public override void Calculate(int index)
        {

            ChartObjects.DrawText("Margin Level", "Current Margin Level " + Account.MarginLevel.Value, StaticPosition.TopLeft, Colors.Lime);

        }


    }

}


 


@cnnhean
Replies

amusleh
03 May 2022, 12:08

Hi,

We are aware of this issue, it's already fixed on cTrader 4.2.

Please wait for cTrader 4.2 release.


@amusleh