goodday
goodday's avatar

Info

Username:goodday
Name:goodday
Member since: 30 Mar 2020

About

None

Signature

None

Last Forum Posts

@API Account.Equity and Account.Balance return wrong value in ctrader 4.2.15 and later update:  14 Aug 2022, 10:22


And Hi PanagiotisCharalampous

I also test to add this line to check the value of Account.UnrealizedNetProfit
                Print("Account.UnrealizedNetProfit = " + Account.UnrealizedNetProfit );
and the result is this

I notice that Account.UnrealizedNetProfit from API still retrun the right value but in backtest info screen show the wrong value.
but Account.Equity always retrun wrong value both in API and in backtest info screen. Please check and fix. Thanks...
I also notice some wrong or abnormal display of positions on the backtesting chat that confuse the test. I will post it here after i carefuly inspect it.
Best regard.

@API Account.Equity and Account.Balance return wrong value in ctrader 4.2.15 and later update:  14 Aug 2022, 09:38


PanagiotisCharalampous said:

Hi goodday,

  1. Can you please provide us with a complete cBot, broker and symbol where we can reproduce this?
  2. We will fix this
  3. We will fix this
  4. We won't change this. Green comments are pretty standard.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

And I found this today ... as you can see the Unr. Net Profit is wrong volue too. You can see in the test there are 4 positions left
and the sum of all positions net profit is -13.52$ but showing 10.37$ 

@API Account.Equity and Account.Balance return wrong value in ctrader 4.2.15 and later update:  14 Aug 2022, 04:43


PanagiotisCharalampous said:

Hi goodday,

  1. Can you please provide us with a complete cBot, broker and symbol where we can reproduce this?
  2. We will fix this
  3. We will fix this
  4. We won't change this. Green comments are pretty standard.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

1.) My Broker is Pepperstone
     ctrader version from Pepperstone now is 4.2.20
     I tested with cross platfrom downloaded from ctrader website and it has same issue.

This is the test cBot code. I backtest with XAUUSD at m1 using ticks data from broker. When backtest, you can compare the value of Account.Equity and Account.Balance in the log to the bottom info of backtest screen. it return wrong value.
this make the line...    var NowProfit = Account.Equity - StartEqty;  in CheckTargetProfit() miscalculated all the time.

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

    public class TestTest : Robot
    {
        const string Bgroup = "Basic Setting";

        [Parameter("Bot Label", Group = Bgroup, DefaultValue = "Goodday")]
        public string BotLabel { get; set; }

        [Parameter("Basic Lot", Group = Bgroup, DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
        public double BasicLot { get; set; }

        [Parameter("Pair Distance", Group = Bgroup, DefaultValue = 20.0, MinValue = 0, Step = 1)]
        public double PairDis { get; set; }

        [Parameter("Start At", Group = Bgroup, DefaultValue = 2, MinValue = 0, Step = 1)]
        public int StartAt { get; set; }

        [Parameter("Target Profit ($)", Group = Bgroup, DefaultValue = 5, MinValue = 1, Step = 0.01)]
        public double TargetPorfit { get; set; }

        private double StartEqty;
        private List<Position> DList;
        private List<int> CloseList;
        private bool Closing;
        private bool isOpen;
        private int OpenCount;
        private int PairNum;


        protected override void OnStart()
        {
            Print("ON START...");
            Closing = false;
            isOpen = false;
            OpenCount = 0;
            PairNum = 0;
            StartEqty = Account.Equity;
            Print("StartEqty = " + StartEqty);
            CloseList = new List<int>();
            DList = new List<Position>();
        }

        protected override void OnTick()
        {
            OpenTrade();
            ExcuteTrade();
            CheckTargetProfit();
        }

        protected override void OnBar()
        {

        }

        private void OpenTrade()
        {
            var Allpos = Positions.FindAll(BotLabel, SymbolName);

            if (Allpos.Count() == 0)
            {
                OpenPos();
            }
            if (Allpos.Count() > 0)
            {
                Position HiPos = Allpos.OrderByDescending(i => i.EntryPrice).FirstOrDefault();
                Position LoPos = Allpos.OrderByDescending(i => i.EntryPrice).LastOrDefault();
                if (HiPos != null || LoPos != null)
                {
                    if (Symbol.Ask > HiPos.EntryPrice + PairDis * Symbol.PipSize || Symbol.Bid < LoPos.EntryPrice - PairDis * Symbol.PipSize)
                    {
                        OpenPos();
                    }
                }
            }
        }

        private void OpenPos()
        {
            if (Closing == false && isOpen == false)
            {
                var volumeBase = Symbol.QuantityToVolumeInUnits(BasicLot);
                ++PairNum;
                var Tocom = PairNum.ToString();
                OpenCount = 0;
                isOpen = true;
                ExecuteMarketOrderAsync(TradeType.Buy, Symbol.Name, volumeBase, BotLabel, null, null, Tocom, OpenRes);
                ExecuteMarketOrderAsync(TradeType.Sell, Symbol.Name, volumeBase, BotLabel, null, null, Tocom, OpenRes);
            }
        }

        private void OpenRes(TradeResult tradeResult)
        {
            if (tradeResult.IsSuccessful)
            {
                ++OpenCount;
                if (OpenCount == 2)
                {
                    OpenCount = 0;
                    isOpen = false;
                }
            }
        }

        private void ExcuteTrade()
        {
            if (Closing == false)
            {
                var Allpos = Positions.FindAll(BotLabel, SymbolName);
                Position positionBL = Allpos.Where(p => !DList.Contains(p)).OrderBy(i => i.NetProfit).FirstOrDefault();
                if (positionBL != null && -positionBL.Pips >= PairDis * StartAt)
                {
                    var Toclose = Allpos.Where(p => p.Comment == positionBL.Comment && p.TradeType != positionBL.TradeType).FirstOrDefault();
                    if (Toclose != null)
                    {
                        var tradeResult = ClosePosition(Toclose);
                        if (tradeResult.IsSuccessful)
                        {
                            DList.Add(positionBL);
                        }
                    }
                }
            }
        }

        private void CheckTargetProfit()
        {
            if (Closing == false && DList.Count() != 0)
            {
                Print("Account.Equity = " + Account.Equity);
                Print("Account.Balance = " + Account.Balance);

                //*** The problem is here because Account.Equity return wrong value

                var NowProfit = Account.Equity - StartEqty;

                Print("NowProfit = " + NowProfit);

                if (NowProfit >= TargetPorfit)
                {
                    ReSetTrade();
                }
            }
        }

        private void ReSetTrade()
        {
            Closing = true;
            var Allpos = Positions.FindAll(BotLabel, SymbolName);
            foreach (var pos in Allpos)
            {
                CloseList.Add(pos.Id);
                ClosePositionAsync(pos, ReSetRes);
            }
        }

        private void ReSetRes(TradeResult tradeResult)
        {
            var position = tradeResult.Position;
            if (tradeResult.IsSuccessful)
            {
                CloseList.Remove(position.Id);
                if (CloseList.Count == 0)
                {
                    OnStart();
                }
            }
        }
    }
}




 

@API Account.Equity and Account.Balance return wrong value in ctrader 4.2.15 and later update:  31 Jul 2022, 19:38


Hi, I today just update to 4.2.15 and test the 4.3.9  found
1) Account.Equity in ctrader backtest return value of  Account.Balance instead.  And Account.Balance return wrong value.

Print("Account.Equity = " + Account.Equity);
Print("Account.Balance = " + Account.Balance);

This always return wrong in backtesting and don't know in live trading will it same or not ... Please check.

2) In backtest screen for new update version is showing account balance which is not useful as equity as before since we need to see the equity draw down during the test.





















3) The order of the events occur at the same time in the Log is sorting in wrong direction to the time sorting order.. This make confusing when we want to check the working order of the cbot.


4)  The comments section in the code editing windows in Gray color please... Green color make it hard to indicated.


Thanks.

@Fixed colors please for buy and sell buttons (Quicktrade):  06 Aug 2021, 09:43


JohnDoeDoe said:

I am using cTrader Web (but I guess it's the same for cTrader Desktop).

The fact that the buy and sell buttons are changing colors along with incoming orders is not helping distinguish between them for those of us who make split second decision (scalping for instance).

It would really help if those buttons remain the same clear colors; RED for sell and GREEN for buy (like is done in the active symbol panel).

Yes Please Fixed colors.

@What's New in cTrader Desktop 4.0:  22 Mar 2021, 05:46


Also the release inside/outside button mouse click handle make this area abit more safer than there is no handle. Can you please bring it back.

@What's New in cTrader Desktop 4.0:  22 Mar 2021, 05:28


Do you know how to set it back to like 3.8 The release mouse inside/outside button handle is very useful when trader want to change their mind in the last second, they just move mouse pointer to release it outside the button. This can also useful when trader accidentally click on the button, they can just hold the mouse and release it outside the button to cancle the action .

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.