Topics
Replies

firemyst
22 Aug 2024, 07:56 ( Updated at: 22 Aug 2024, 07:57 )

What do i do wrong?

You're using a Mac ;-)


@firemyst

firemyst
21 Aug 2024, 06:20

RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

PanagiotisCharalampous said: 

Hi firemyst,

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.

 

 


@firemyst

firemyst
20 Aug 2024, 04:55 ( Updated at: 20 Aug 2024, 05:13 )

RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

PanagiotisCharalampous said: 

Hi firemyst,

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.


@firemyst

firemyst
20 Aug 2024, 01:19 ( Updated at: 20 Aug 2024, 04:33 )

Have you considered that there might not be any more history to be loaded, especially if you're not scrolling to the left on the charts? 

See this thread:

https://ctrader.com/forum/cbot-support/38020/

 


@firemyst

firemyst
20 Aug 2024, 01:09

Do as it says – install the latest version of ctrader. 

If you're using a broker's version of cTrader, they might not be updated to version 5.0.x yet. 

If the template file you have came from a version made in 5.x, it won't work in the broker versions that are still 4.x


@firemyst

firemyst
15 Aug 2024, 01:04 ( Updated at: 15 Aug 2024, 05:20 )

Stop making it hard on yourself.

Change your parameter “EMA Color” to a “Color” parameter and use that. 

Examples here: https://help.ctrader.com/ctrader-algo/guides/parameter-types/#cbot-examples

 


@firemyst

firemyst
13 Aug 2024, 00:06

Do you have time to change your default trade settings?

 


@firemyst

firemyst
13 Aug 2024, 00:01

You can't.

Emails aren't allowed to be sent from bots running in the cloud.

 


@firemyst

firemyst
12 Aug 2024, 05:34

RE: RE: Daily Limit on loss and Win

PanagiotisCharalampous said: 

firemyst said: 

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

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.

 

 


@firemyst

firemyst
11 Aug 2024, 11:02 ( Updated at: 11 Aug 2024, 15:29 )

Your bot probably won't work as you want because if you read this page:

https://help.ctrader.com/ctrader-algo/synchronisation/requirements-for-cbots/#compile-time-references

http requests aren't sent when bots run in the cloud.

 


@firemyst

firemyst
08 Aug 2024, 01:44

Yes. 

2 options:

  1. configure 3 instances of the bot, and for each bot, select a different demo account
  2. launch 3 instances of cTrader with each cTrader set to a different account.

 


@firemyst

firemyst
05 Aug 2024, 12:55

RE: RE: RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

PanagiotisCharalampous said: 

firemyst said: 

PanagiotisCharalampous said: 

Hi firemyst,

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.

Thank you


@firemyst

firemyst
05 Aug 2024, 06:31 ( Updated at: 05 Aug 2024, 06:34 )

RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

PanagiotisCharalampous said: 

Hi firemyst,

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.

 

 


@firemyst

firemyst
01 Aug 2024, 07:02 ( Updated at: 01 Aug 2024, 12:15 )

Here's pseudo code to help you with the top band. You can do something similar for the bottom.

If (

    (last price ≥ top bollinger band) and (current closing price ≤ top bollinger band)

    or

    (last price ≤ top bollinger band) and (current closing price ≥ top bollinger band)

)

{

   ///then you know it either touched or crossed

}


@firemyst

firemyst
01 Aug 2024, 06:58 ( Updated at: 01 Aug 2024, 12:15 )

If you have a suggestion, you need to post it in the Suggestion forum:

https://ctrader.com/forum/suggestions/

 

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.

 


@firemyst

firemyst
01 Aug 2024, 06:55

Yes. I do it with my bots.

You just need to save the information in your code and keep track of it yourself.

 


@firemyst

firemyst
28 Jul 2024, 05:24 ( Updated at: 28 Jul 2024, 06:43 )

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:

  1. have it shown on the 4 15-minute bars that make up the hour
  2. 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:

https://help.ctrader.com/ctrader-algo/indicator-code-samples/#multiple-timeframes

 


@firemyst

firemyst
27 Jul 2024, 03:58 ( Updated at: 28 Jul 2024, 06:43 )

You need to post this in the Suggestions forum:

https://ctrader.com/forum/suggestions/

THis is technical support forum - Spotware doesn't come here, more or less looking for suggestions here.


@firemyst