Topics
Forum Topics not found
Replies
ap11
09 Jul 2018, 12:02
Hi Alexander,
It seems that you are trying to group positions by a label and get only profitable groups.
Here is the code that do that:
var groupingByLabel = Positions.GroupBy(p => p.Label); var profitableGroups = groupingByLabel.Where(g => g.Sum(p => p.NetProfit) > 0);
profitableGroups is an enumeration of groups. Each group is an enumeration of positions and it has a Key property that contains positions label.
Now you can close positions:
var positions = profitableGroups.SelectMany(g => g); foreach(var position in positions) { ClosePosition(position); }
Hope that helps.
Regards,
Andrey
@ap11
ap11
02 May 2018, 16:30
( Updated at: 21 Dec 2023, 09:20 )
Dear tinker.this,
Thank you for your feedback!
There is one more thing that will go to version 3.01 that might help with the problem that chart objects are drawn above candles. We added an alpha channel to color settings. Objects could be displayed like this:
Also, we will add an option to draw objects in the background.
Thank you,
Andrey
@ap11
ap11
02 Mar 2018, 15:38
RE:
Hi Max,
Thank you for your feedback!
Yes, we do have plans to make a market for cBots/indicators in the future.
Regarding nickname. you can change it at https://id.ctrader.com/ in profile settings.
Regards,
Andrey
dmitrievskymax@gmail.com said:
Hi, Spotware, your platform looks really sexy now
Do you plan to add a market for bots and indicators? So traders can sell their products on your market.
@ap11
ap11
02 Mar 2018, 12:58
Hi Paul,
Thank you for your suggestions!
We are planning to add methods to work with charts when we start to work on multi-currency backtesting.
Changing symbol/timeframe is in our backlog as well.
Methods for themes are planned as well. But for next version, we already have new API for chart settings that repeat settings available from UI:
- Color setting for getting and setting chart colors
- Chart display settings to show/hide chart elements
- Properties for chart type and zoom
- Events for changes in settings listed above
Regards,
Andrey
@ap11
ap11
02 Mar 2018, 11:29
RE:
Hi Afhacker,
Thank you for your feedback!
Currently, we are testing a top requested feature - Visual Backtesting. It would be in the next release.
We didn't start to work on multi-currency backtesting yet, but it is in our top priorities as a second top requested feature by the users.
We are finishing with the updated version for ChartObjects API that has the following features:
- Get a link to the object and change object properties later
- Check if an object is still on the chart
- Get existing objects on the chart or indicator panel
- Events for chart objects (added, updated, removed, hovered, selected)
Also, we have a new Color type, where you can specify transparency.
Regarding other features you mentioned.
We are planning to update .Net version in the near future. For this, we need to update cTrader to the same .Net version. Which means that we are getting rid of support for some old versions of Windows. We need to make sure that users have required .Net version installed on their machines prior to release. So we are planning to make a release with the .Net installer first, which will ask users to update. It is planned that next version will have this installer. After that we can proceed with .Net version update.
Proper parameters UI for custom enums, DateTime and Color are planned to be supported. But these tasks are not in the top priority list.
There are no plans yet to introduce new drawing objects. Your feedback on this subject is very welcome. Please tell us what do you want to see here.
Regarding TimeZone of the platform, it's a good idea to add this property and a change event.
Thank you,
Andrey
afhacker said:
First thanks for adding this new features but what about community requests? where is multi-symbol backtesting? or different parameter types like Enums, date time picker,...
And is there any property to get a collection of all available symbols? that will be a simple feature to add before releasing the new version of API.
The current API library is based on .Net framework 4 which is obsolete, please update the .Net version to > 4.6 at least.
Another main issue of current API is limited drawing, please improve the API chart drawing feature by adding:
1. Transparency
2. Different shapes drawing
3. Checking current objects on chart and modifying those objects
4. A collection of objects drawn by current indicator or cBot
And please add a property to get the user platform (not system as it's available by .Net) time zone as a .Net TimeZoneInfo object.
Adding all these features will not get much time but I don't know why Spotware is very slow in adding new features?
Multi-symbol backtesting is one of the top suggestions and most voted of the community so please add it!
@ap11
ap11
02 Mar 2018, 10:28
RE:
Hi Paul,
Thank you!
Usually, it takes a couple of weeks to test a new version on beta. After we begin to roll-out it for different brokers.
Best Regards,
Andrey
Paul_Hayes said:
Nice work people, do you know when the roll-out will take place?
These are much-needed features and most welcome, thanks.
Paul Hayes
cTrader Software Vendor
Email: contact@clickalgo.com
Phone: (44) 203 289 6573
Website: https://clickalgo.com
@ap11
ap11
28 Feb 2018, 17:40
Hi MaRCHeW,
Visual Studio Extension is now fixed. If you still experience issues with extension, please do following steps:
1. Remove current version from Visual Studio. Using Tools -> Extension and Updates, uninstall cBots and Indicators extension
2. Select 'Edit in Visual Studio' from cTrader 3.0. It will download and install Visual Studio Extension
Regarding support in older versions of cAlgo.
Edit in Visual Studio command is not supported in cAlgo 2.01 with the new version of Visual Studio Extension. You still can open cBot or indicator in Visual Studio from new cTrader or from the file system by navigating source code folder and open .sln file.
Thanks,
Andrey
@ap11
ap11
08 Jan 2018, 10:08
Dear Trader,
Please not that last point on Equity Chart added when backtesting finishes. And it shows minimum and maximum equity values for period since last position close.
It will be away from balance value (yellow line) if you have positions opened. Because positions does not close automatically when backtesting finishes.
You might want to see result for this positions. To do so you can close all positions in OnStop method:
protected override void OnStop() { foreach (var p in Positions) ClosePosition(p); }
@ap11
ap11
28 Dec 2017, 10:17
Hi Tony,
1. This bug was fixed and fix will be in released in next version
2. To avoid this behaviour, you can call MarketDate.GetSeries in OnStart method and use result later:
private MarketSeries seriesM15; protected override void OnStart() { seriesM15 = MarketData.GetSeries(TimeFrame.Minute15); } protected override void OnBar() { var close = seriesM15.Close.LastValue; }
> Surprisingly after my tests the code runs through twice on the first onbar event but then subsequent onbar only runs once, is this an anomaly or something else?
After calling MarketData.GetSeries, next call with same settings will return same MarketSeries instance. So bug affects only first OnBar event after MarketData.GetSeries call.
Kind Regards,
Andrey
@ap11
ap11
13 Dec 2017, 12:40
Hi T.,
I'm afraid you need to do it by yourself.
Now cAlgo APIs has no methods to get info about trading sessions. Next cTrader version has new Symbol.MarketSeries APIs. You will be able to get list of current sessions and check if instrument is active or not.
But we are not planning to add methods for history of trading sessions settings.
Kind Regards,
Andrey
@ap11
ap11
13 Dec 2017, 12:34
Hi T.,
1. Do you have spread > 0 when backtesting on m1 bars?
Note that when backtesting on ticks, spread is taken from history. As tick data already has spread in it.
But when testing on 1 minute bars, spread is taken from settings.
2. Did you optimize your strategy?
If you did, there is a chance that strategy settings are overfitted. In this case any change in input might show absolutely different result.
Kind Regards,
Andrey
@ap11
ap11
12 Dec 2017, 16:50
aronbara664,
You can subscribe to Positions.Close event.
Also you can use HistoricalTrade to calculate how long position was opened. It has both EntryTime and ClosingTime.
Please see example below:
protected override void OnStart() { Positions.Closed += Positions_Closed; } private void Positions_Closed(PositionClosedEventArgs args) { var position = args.Position; // Using Server.Time var time1 = Time - position.EntryTime; // Using HistoricalTrade var historicalTrade = History.FirstOrDefault(h => h.PositionId == position.Id); var time2 = historicalTrade.ClosingTime - historicalTrade.EntryTime; }
Kind Regards,
Andrey
@ap11
ap11
12 Dec 2017, 14:26
RE:
Hi aronbara664,
In backtesting you can use Server.Time or just Time property (which is the same) to get current backtesting time.
Kind Regards,
Andrey
aronbara664 said:
Hi guys,
Can anyone please help with measuring the time between opening and closing a trade on a backtest?
I tried using a Stopwatch and a Timer, but none of them worked - even though I'm sure the solution to this problem really is using a Timer. I have wasted countless of hours on this task already.
If anyone of you could give me some hints, that'd be great!
Thank you in advance :-)
@ap11
ap11
11 Dec 2017, 11:40
Hi lec0456,
You need Bar class with Open, High, Low, Close, Volume fields. You can pass collection of Bars to your method.
Also you can create an extention for MarketSeries to get Bar like this, MarketSeries.GetBar(t0):
public static class MarketSeriesGetBarExtention { public static Bar GetBar(this MarketSeries series, int index) { var bar = new Bar() { Open = series.Open[index], High = series.High[index], Low = series.Low[index], Close = series.Close[index], TickVolume = series.TickVolume[index] }; return bar; } }
Kind Regards,
Andrey
@ap11
ap11
11 Dec 2017, 11:03
RE:
Hi Christophdaube,
Do you call RF.Result[...] or RF.Result.LastValue in your cBot?
Referenced indicator using lazy evaluation. Calculate method will not be called untill cBot requests output data series value. But Initialize method is called when you creating indicator instance in cBot.
Please check if this is the issue here.
Kind Regards,
Andrey
christophdaube said:
Hello,
I try to use an self written indicator in my cbot. The initalization is working:
"RF = Indicators.GetIndicator<RaisingFalling>(MACDLC, MACDSC, MACDP, BOLMAType, BOLSD, BOLP, MAX_GEWINN_FAKTOR);" in my cbot is calling the Initialize() Methode in my indicator correctly.
But the main methode "public override void Calculate(int index)" seems to be never called. All the variables have always the inital-values and never changes. When I debug my code, the nested indicators I use in my indicator are changing, but no other variables. The wierd thing is that when I use just the indicator everthing seems to work just fine, the methods are all in use.Does anyone know where the problem coud be?
best regards
@ap11
ap11
11 Dec 2017, 10:47
( Updated at: 21 Dec 2023, 09:20 )
RE:
Hi Tmfd,
In couple months we are planing to start working on this. Currently we are finishing with top requested feature - Visual Backtesting (see image below). One of the next planned feature is multi symbol backtesting.
Best Regards,
Andrey
@ap11
ap11
08 Dec 2017, 14:35
RE:
Hi Markus,
You can use integer value for minutes in total. One day have 24 * 60 = 1440 minutes. This way:
0 = 0:00
1439 = 23:59
Example:
var timeInMinutes = 615; var timeSpan = TimeSpan.FromMinutes(timeInMinutes); var hours = timeSpan.Hours; var minutes = timeSpan.Minutes; Print("Time is {0}:{1}", hours, minutes); // Output: Time is 10:15
Kind Regards,
Andrey
cicondo said:
Good Day @all
I'm using an integer for a specific time window within the bot have to accept new orders.
Let's say EntryTime = 1005 -> means 10:00By running the optimization I use an increment by 5 which inreases the EntryTime parameter 1010... 1015 and so on.
My code make sure that only valif values are accepted but the when I'm rewriting the valid vauel to the parameter it will not
work correctly.e.g. it show a value like 1075 wich is not the rigt value I'm currently using within the pass interation of the optimization...
protected override void OnStart()
{
......Positions.Opened += new Action<PositionOpenedEventArgs>(Positions_Opened);
_oldEntryTime = NormalizeTime(_oldEntryTime, EntryTime);
_oldExitTime = NormalizeTime(_oldExitTime, ExitTime);
EntryTime = _oldEntryTime;
ExitTime = _oldExitTime;
}Maybe somebody has any idea what I should do or there is an example, demonstrating the same intention.
Cheers
Markus
@ap11
ap11
08 Dec 2017, 10:00
( Updated at: 21 Dec 2023, 09:20 )
RE: RE:
Hi,
The problem is that cAlgo does not support decimal volumes. All volumes in cAlgo API has type long. It causes following issues with BTCUSD:
- You can't open positions or create pending orders with decimal part via cAlgo APIs
- You won't get correct value for existing Position, PendingOrder or HistoricalTrade if volume has decimal part
- Backtesting for this symbols is not working as Symbol.VolumeStep is equal to 0 after casting from double to long. That's why you get DivideByZeroException
We are fixing this issues. But this fixes will be in the next release of cTrader.
nohejl027@gmail.com said:
Paul_Hayes said:
Hi Spotware,
I am attempting to submit an order through the API with the ExecuteMarketOrder method, an error is occurring which is coming from your compiled code.
Crashed in OnTick with DivideByZeroException: Attempted to divide by zero.
ExecuteMarketOrder (TradeType.Buy, Symbol, 2, String.Empty, null, null);
Please, can you help me out here.
Paul Hayes
Sales & Marketing
Email: contact@clickalgo.com
Phone: (44) 203 289 6573
Website: https://clickalgo.comI am getting the same error. Is there any news about this issue?
@ap11
ap11
09 Jul 2018, 14:31
Hi Noppanon,
Distance for Trailing Stop is taken from the distance from Stop Loss to current price when Trailing Stop is applied.
You can't specify when Trailing Stop will start working. It can be done from the the code. Here is an example:
Regards,
Andrey
@ap11