Can we have the cBot that reproduces this problem?
Best regards,
Panagiotis
Hi @PanagiotisCharalampous :
I've reproduced the issue again. It's in my log files:
I sent through a private YouTube video link to the Community Spotware email address referencing this thread so your team can watch the video and see exactly what's happening.
Can we have the cBot that reproduces this problem?
Best regards,
Panagiotis
I have managed to create a cBot which caused this issue for me today. It doesn't print out the “Unexpectedly terminated” error, but the bot instances stop responding.
I'll email it through to the “community” email address shortly.
I had to let the bot run over the weekend and noticed certain symbols stopped ticking over today.
My guess now is it's being caused by an async callback not working properly as when I added one into the code, that's when things broke. Eg, I stripped out all the code and started to gradually add things back in to see what would cause it to break.
I'll try and make notes of that in the code.
I discovered this issue by looking at the logs. I hav einformation printed out for every tick – some symbols like AUDUSD were still printing to the log today; others like AUDCHF stopped printing to the log yesterday. Both bot instances were running off the same bot code.
There is a way to do it, but you have to code it into your bots. Here's an example:
//Get historical tradePosition p1 = args.Position;//Running Totals_runningTotalsPipsGainedLost += p1.Pips;_runningTotalsNetGainLoss += p1.NetProfit//Stop the bot if the running net gain/loss pips falls below our specified amountif (_runningTotalsPipsGainedLost < StopBotWhenPipLossesFallBelow){ //stop bot Stop();}//Stop the bot if the running net gain/loss total falls below our specified amountif (_runningTotalsNetGainLoss < StopBotWhenLossesFallBelow){ //stop bot Stop();}
Note that this only works on each individual bot instance for each bot.
If you want the running totals to be across all instances of a particular bot, then you need to set static variables that are public that all bot code would have access to.
Have your bots check that value every time they start, and before entering any positions. If that global static amount is below a certain threshold, either stop your bot, or don't allow it to enter a new position.
I assume that the trader wants to block trading for the entire account.
They don't make that clear, but their initial post does say “limit” as opposed to “block”.
firemyst
11 Aug 2024, 11:43
( Updated at: 11 Aug 2024, 15:29 )
There is a way to do it, but you have to code it into your bots. Here's an example:
//Get historical trade
Position p1 = args.Position;
//Running Totals
_runningTotalsPipsGainedLost += p1.Pips;
_runningTotalsNetGainLoss += p1.NetProfit
//Stop the bot if the running net gain/loss pips falls below our specified amount
if (_runningTotalsPipsGainedLost < StopBotWhenPipLossesFallBelow)
{
//stop bot
Stop();
}
//Stop the bot if the running net gain/loss total falls below our specified amount
if (_runningTotalsNetGainLoss < StopBotWhenLossesFallBelow)
{
//stop bot
Stop();
}
Note that this only works on each individual bot instance for each bot.
If you want the running totals to be across all instances of a particular bot, then you need to set static variables that are public that all bot code would have access to.
Have your bots check that value every time they start, and before entering any positions. If that global static amount is below a certain threshold, either stop your bot, or don't allow it to enter a new position.
Can we have the cBot that reproduces this problem?
Best regards,
Panagiotis
On a separate issue, I'm not receiving email notifications when someone responds to a post in the forums. Are they working?
The issue reported above happened again to me today. AGain the button won't click, I can't stop it. The only way for me to get out of this is to kill cTrader and restart.
When I do that, I do know the “OnStop” even doesn't happen or register, because in my code when a bot instance stops, I have it write information to a text file. All the forex pairs (such as NZDUSD below) don't write anything out when this happens. So whatever terminates the process doesn't cause the “OnStop” even to fire.
I can't figure out exactly how to reproduce it, so am not sending through the full bot code. I do know it happens when I have 26 bot instances running under one instance of cTrader on a VPS using 4GB of memory making all sorts of trades and managing them. Maybe it gets hung when too many ticks come through and it can't handle them? Kind of like when debugging in Visual Studio and if we wait too long it kills the process to safeguard data.
I'm trying to figure out code to send you that easily reproduces this behaviour all the time.
Hi firemyst,
If you want to receive notifications for responses, make sure you subscribe to the thread
Best regards,
Panagiotis
I started this post, thus I'm automatically subscribed. I should have received your response, but nothing. I didn't know until I was browsing today. That's why I was asking. I know about the subscribe feature.
However, I received a notification about your most recent response, so that tells me 1) either you somehow responded differently over the weekend (being an admin and all) that cause me to not receive anything or 2) the service was down for some reason.
Can we have the cBot that reproduces this problem?
Best regards,
Panagiotis
On a separate issue, I'm not receiving email notifications when someone responds to a post in the forums. Are they working?
The issue reported above happened again to me today. AGain the button won't click, I can't stop it. The only way for me to get out of this is to kill cTrader and restart.
When I do that, I do know the “OnStop” even doesn't happen or register, because in my code when a bot instance stops, I have it write information to a text file. All the forex pairs (such as NZDUSD below) don't write anything out when this happens. So whatever terminates the process doesn't cause the “OnStop” even to fire.
I can't figure out exactly how to reproduce it, so am not sending through the full bot code. I do know it happens when I have 26 bot instances running under one instance of cTrader on a VPS using 4GB of memory making all sorts of trades and managing them. Maybe it gets hung when too many ticks come through and it can't handle them? Kind of like when debugging in Visual Studio and if we wait too long it kills the process to safeguard data.
I'm trying to figure out code to send you that easily reproduces this behaviour all the time.
Spotware won't look here for suggestions because this is for technical support.
However, you could accomplish what you want now in a round-about way. Just build your own structures and put the relevant symbol in each structure.
For instance, in C# code, create a HashTable with all the Indices you want to trade, or could trade. Call the HashTable AssetCategory_Indices; similarly, do one for all the forex pairs you might trade.
Then you can check which asset category the current symbol is in by checking each of your HashTables.
You can do it, but it might not be 100% accurate on when it happens when calculating previous candles.
This is because on the higher timeframe, it'll be seen as crossing at the opening time of that bar. So like 1pm, 2pm, 3pm,. etc.
So on your 15M chart, you can:
have it shown on the 4 15-minute bars that make up the hour
or it'll probably just be shown on the first 15-minute bar of the corresponding hour. That is, if it crossed at 1:20pm, yesterday, when the indicator opens and calculates previous bars, it only goes by closing prices, not actual ticks, so it'll show as closing at 1pm and not the 15-minute bar that represents 1:20pm.
OTherwise, for example code, check out Spotware's online documentation:
firemyst
22 Aug 2024, 07:56 ( Updated at: 22 Aug 2024, 07:57 )
You're using a Mac ;-)
@firemyst