Topics
Replies
goodday
14 Aug 2022, 09:38
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi goodday,
- Can you please provide us with a complete cBot, broker and symbol where we can reproduce this?
- We will fix this
- We will fix this
- 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$
@goodday
goodday
14 Aug 2022, 04:43
( Updated at: 19 Aug 2022, 23:28 )
RE:
PanagiotisCharalampous said:
Hi goodday,
- Can you please provide us with a complete cBot, broker and symbol where we can reproduce this?
- We will fix this
- We will fix this
- 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();
}
}
}
}
}
@goodday
goodday
06 Aug 2021, 09:43
RE: UserVoice
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.
@goodday
goodday
22 Mar 2021, 05:28
( Updated at: 21 Dec 2023, 09:22 )
The Reverse, Double and Close button in Tradewatch pannel has no release mouse inside or outside the button event handle anymore
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 .
@goodday
goodday
14 Aug 2022, 10:22 ( Updated at: 21 Dec 2023, 09:22 )
RE: RE:
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.
@goodday