Account.Balance and Account.Equity

Created at 26 Nov 2024, 12:41
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!
TU

tuuguu177

Joined 22.05.2024

Account.Balance and Account.Equity
26 Nov 2024, 12:41


hello is there anyone know this kind of issue? There are errors at Account.Balance and Account.Equity at below code.

 

        private void ExecuteMarketOrderAsync(TradeType tradeType)
        {       
            var lots = GetValueFromInput(LotsInputKey, 0);
            if (lots <= 0)
            {
                _robot.Print(string.Format("{0} failed, invalid Lots", tradeType));
                return;
            }

            var stopLossPips = GetValueFromInput(StopLossInputKey, 0);
            var takeProfitPips = GetValueFromInput(TakeProfitInputKey, 0);

            _robot.Print(string.Format("Open position with: LotsParameter: {0}, StopLossPipsParameter: {1}, TakeProfitPipsParameter: {2}", lots, stopLossPips, takeProfitPips));
            
            //var netProfit = Account.UnrealizedNetProfit;
            //var PercentProfit = Math.Round(netProfit / Account.Balance * 100, 2);
            
            var volume = _symbol.QuantityToVolumeInUnits(lots);
            
            if (Account.Equity < Account.Balance * ((100 - 50) / 100))
            {
                //foreach (var position in Positions)
                    //ClosePositionAsync(position);
            }
            
            _robot.ExecuteMarketOrderAsync(tradeType, _symbol.Name, volume, "Trade Panel Sample", stopLossPips, takeProfitPips);
                    
        }

But there is not error at  Account.Balance, Account.Equity at below code when compile. How to solve error of the first code?

@PanagiotisCharalampous Pls advise me my friend

 

        protected override void OnTick()
        {
            // Put your core logic here
            if (Account.Equity < Account.Balance * ((100 - maxDrawDown) / 100))
            {
                foreach (var position in Positions)
                    ClosePositionAsync(position);
            }

 


@tuuguu177