Topics
Forum Topics not found
Replies
amusleh
29 Nov 2021, 09:09
Hi,
In cTrader automate you can pass an order stop loss and take profit while opening the order by using their parameters.
Please check the Robot interface order execution and placement methods: cAlgo API Reference - Robot Class (ctrader.com)
@amusleh
amusleh
29 Nov 2021, 08:59
Hi,
Please try to use your indicator and cBot only on a single current chart time frame and then check the data, it might be due to data difference when you are loading multiple time frames data.
Or it can also be caused by double type precision issue, try to round and change the type to decimal if you want to use the same exact data.
@amusleh
amusleh
29 Nov 2021, 08:52
Hi.
You can get those information from Account object and Symbol object.
Please check these links:
cAlgo API Reference - IAccount Interface (ctrader.com)
cAlgo API Reference - Symbol Interface (ctrader.com)
cAlgo API Reference - PendingOrders Interface (ctrader.com)
cAlgo API Reference - Positions Interface (ctrader.com)
@amusleh
amusleh
24 Nov 2021, 09:19
Hi,
You can add a button by using Chart controls: cAlgo API Reference - Button Class (ctrader.com)
@amusleh
amusleh
23 Nov 2021, 13:42
Hi,
Right now you can't do such a thing, if you want to see this feature on cTrader you can open a thread for it on suggestions section of forum.
The simple way to verify or put that kind of limitations on parameters is to use the cBot OnStart or indicator initialize method, but if you want to do it on a more user friendly way you can use Windows Forms, get all your cBot or indicator parameters from a Windows form.
That way you can customize the form inputs based on your needs without using the cTrader parameters window.
The form will popup when user starts your cBot and it will have a button for Saving the user provided values, you can design it the way you want to.
@amusleh
amusleh
23 Nov 2021, 09:59
Hi,
Search on the site if there is already any implementation of that indicator available for cTrader or not.
If you couldn't find it then you can post a job request or ask one of the consultants to develop it for you.
@amusleh
amusleh
23 Nov 2021, 09:57
RE: RE:
firemyst said:
amusleh said:
Hi,
If you know what time zone your indicator/cBot is running on and on which time the New York session ends then you can check if the OnBar/OnTick event is triggered during that time.
To change the time zone of DateTime you can use .NET TimeZoneInfo: Converting times between time zones | Microsoft Docs
Thank you for your reply.
Because after the New York session close, the next OnTick/OnBar events for each forex pair happens at different times. So I can't just say, "check at x o'clock.
For example, if I was in New York, in an OnBar event within a bot, I'd have to check if it is occurring between 5:00pm - 5:05pm. And if I'm on a time frame that's less than 5 minutes, I'd have to have a flag to indicate that I've already checked for the first bar after the close of the session.
Is that how you would do it? Or do you have any other ideas?
Thanks again.
Hi,
Yes, that's I think the only way you can do it.
Just check if the OnBar/OnTick is triggered on your specified time period by using the Server.Time.
@amusleh
amusleh
23 Nov 2021, 09:53
Hi,
All the positions your cBot opens during back test and live is in Positions collection.
You don't have to use the FindAll method with empty label parameter, if you want to filter the current symbol positions you can do it by using Linq Where:
var positions = Positions.Where(position => position.SymbolName.Equals(SymbolName, StringComparison.OrdinalIgnoreCase));
If you have provided a label for your positions then use FindAll method.
@amusleh
amusleh
22 Nov 2021, 09:10
Hi,
You can contact any of our consultants to develop your cBot for you or you can post a job request.
@amusleh
amusleh
22 Nov 2021, 09:04
( Updated at: 22 Nov 2021, 09:08 )
Hi,
You can only set one fitness parameter not multiple, if you want to use MaxEquityDrawdownPercentages then you can't use win rate or net profit.
You can try to combine them and come up with a new metric for GetFitness, for example you can do something like this:
protected override double GetFitness(GetFitnessArgs args)
{
// Here it adds the amount of remained equity percentage to win rate
return 100 - args.MaxEquityDrawdownPercentages + (args.WinningTrades / args.TotalTrades);
}
So if MaxEquityDrawdownPercentages is 65% it will add the 35 to win rate and use this metric as your fitness.
You can add more parameters to the calculation of fitness if you want to and come up with something that covers multiple aspects of your result not just one single parameter.
If you use the optimizer standard criteria then you can set there to minimize MaxEquityDrawdownPercentages and maximize wining trades and net profit.
@amusleh
amusleh
22 Nov 2021, 08:53
Hi,
If you know what time zone your indicator/cBot is running on and on which time the New York session ends then you can check if the OnBar/OnTick event is triggered during that time.
To change the time zone of DateTime you can use .NET TimeZoneInfo: Converting times between time zones | Microsoft Docs
@amusleh
amusleh
18 Nov 2021, 10:03
Hi,
To get last four lost trades net profit you can filter the lost trades first then order them, after that take the last four:
var result = History.Where(trade => trade.SymbolName.Equals(SymbolName, StringComparison.OrdinalIgnoreCase) && trade.NetProfit < 0).OrderByDescending(trade => trade.EntryTime).Take(4).Sum(trade => trade.NetProfit);
@amusleh
amusleh
18 Nov 2021, 08:40
Hi,
To get the last four values you can use OrderByDescending and Take, but on your posted sequence the values you are looking to get aren't last four.
You can first skip the last 2 values and then use Take to get the last 4 values:
var result = History.Where(trade => trade.SymbolName.Equals(SymbolName, StringComparison.OrdinalIgnoreCase)).OrderByDescending(trade => trade.EntryTime).Skip(2).Take(4).Sum(trade => trade.NetProfit);
@amusleh
amusleh
29 Nov 2021, 09:16
Hi,
There are multiple ways to do that, here is an example by using Action delegates:
@amusleh