Serious Error During Unrealized Profit Counting,

Created at 25 Aug 2022, 03:14
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!
G.

G.A.F

Joined 04.08.2022

Serious Error During Unrealized Profit Counting,
25 Aug 2022, 03:14


Serious Error During Unrealized Profit Counting, the position Net profit count does not match for the count made by the platform, as demonstrated in this photo, the sum of the positions gives me a negative of -85.7, instead in the application it gives me a positive sum of 85.6, also this error also continues in the equity line, it seems to me really a very serious error,   it's making me waste useful time in the analysis of backtests, I attach test code,

Test Datas

Broker:Ic Markets

Instrument: Eur/Usd

Timeframe Daily

Start Test :13/6/2011

StopTest 27/7/2011

 

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(AccessRights = AccessRights.None)]
    public class NewcBot4 : Robot
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }
        
        
         private int CountOf_SymbPositions()
        {
            var tradeMCount12345 = 0;
            foreach (var position in Positions)
            {
                if (position.SymbolName == SymbolName)
                {

                    tradeMCount12345++;
                }

            }

            return tradeMCount12345;
        }
        protected override void OnStart()
        {
          
        }

        protected override void OnBar()
        {
         if(CountOf_SymbPositions()<10)
            {
            ExecuteMarketOrder(TradeType.Sell, SymbolName, Symbol.VolumeInUnitsMin, "0", null, 100, "A", false);
             ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, "0", null, 100, "A", false);}
            Print("AAA____Convert.ToInt32(Symbol.UnrealizedNetProfit) ", Convert.ToInt32(Symbol.UnrealizedNetProfit));
            var SYuP = Math.Round(Symbol.UnrealizedNetProfit, 2);
            string text = string.Format("{0}", SYuP);
            ChartObjects.DrawText("Label", "Spread:", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("spread", "\t" + text, StaticPosition.TopLeft, Colors.White);
       
            if(CountOf_SymbPositions()>500)
            {
            
//

            }
        }

        protected override void OnStop()
        {
          


            
        }
    }
}

 

 

 

 


@G.A.F
Replies

PanagiotisCharalampous
25 Aug 2022, 14:41

Hi there,

This issue will be resolved in an upcoming update.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous