Topics
Replies

firemyst
05 Aug 2022, 10:53

You need to submit your suggestions here:

https://ctrader.com/forum/suggestions

This is the forum where Spotware takes suggestions for improving their products.


@firemyst

firemyst
04 Aug 2022, 04:30 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE:

kurtisnauss said:

firemyst said:

Bars.ClosePrices[index] > slowMa.Result[index]

This is going to happen on every bar where the close price is greater than the MA. If you have a long uptrend, and are on a small/fast time frame over a long period of back testing, this could happen thousands of times. 

For example:

The condition will evaluate to true for every single one of those bars shown above if your slow MA is the yellow line, because the close price is above the MA.

But that's only in theory since we don't have the whole of your code and don't know what else is happening in your bot.

Yes, that makes sense that would be reading and storing data for every bar that is printed.

Therefore, when writing it as in example #1, does that tell it to only read it one time on the initial cross and then waits until the next time we see it crossover?

Yes.

In my above example, it wouldn't happen at all within the screen capture provided.

However, depending on the setting of your MA again, it could still happen quite a few times as shown here from the same chart (just a different MA period):

where you have a (any color) bar that closes below the line followed by a green bar that closes above the line. Those meet the conditions for Example #1.

In this screen capture, I see at least 11 times where that occurs.


@firemyst

firemyst
04 Aug 2022, 04:07

Try this as I believe you need to include/set the headers:

var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var result = client.PostAsync(endpoint, content).Result;

 


@firemyst

firemyst
04 Aug 2022, 03:56

Bars.ClosePrices[index] > slowMa.Result[index]

This is going to happen on every bar where the close price is greater than the MA. If you have a long uptrend, and are on a small/fast time frame over a long period of back testing, this could happen thousands of times. 

For example:

The condition will evaluate to true for every single one of those bars shown above if your slow MA is the yellow line, because the close price is above the MA.

But that's only in theory since we don't have the whole of your code and don't know what else is happening in your bot.


@firemyst

firemyst
03 Aug 2022, 11:06 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE: Thank alot :)

kuwait007 said:

PanagiotisCharalampous said:

Hi kuwait007,

If your broker does not want to configure this for cTrader, you can try another broker. Here is an example from a broker that offers fractional contracts of 0.01 lots.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

 

Many Thanks my friend :)

Pepperstone supports trading 0.1 lots on indices and 0.01 lots for forex.


@firemyst

firemyst
03 Aug 2022, 10:53 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE:

albert.isac94 said:

pantheljakob said:

I always have to keep my tablet on to take advanced profits which is really annoying!

I'd love to have the option to preset my trade with advanced take profits and breakeven distance

 

This functionality is already in cTrader, albeit after you place your order:


@firemyst

firemyst
03 Aug 2022, 06:53

RE:

amusleh said:

Hi,

Most probably we will support officially Visual Studio 2022 after cTrader 4.2 release.

Is there an official announcement on what versions of Visual Studio are still officially supported? Because there's nothing in this thread:

cTrader Desktop 4.2 Has Been Released!

 


@firemyst

firemyst
02 Aug 2022, 16:08

RE:

Anka Software said:

Hi,

   Any way to get symbol type ie forex/index/cash etc?

Regards

Vivek

Maybe create C# HashSet objects calle "forex", "index", "cash" etc. IN each Has object, add the symbols you'll be trading that you would classify as forex, index, cash, etc, respectively.


@firemyst

firemyst
02 Aug 2022, 16:06

Have you tried adding the reference through cTrader? In the bot under "Automate", there are 3 vertical dots. From those, you can select "Manage References". Add the indicator as a reference that way, and then launch your development environment.


@firemyst

firemyst
02 Aug 2022, 16:01

RE:

ctid4771555 said:

Hi

Is there any project template for Visual Studio already available to use, or it could be built in the future ?

 

Thanks

 

Not sure what you're asking for since if you're using Visual Studio you can easily create your own.

Just go into cTrader, under Automate, create a new indicator/bot, and then click to "edit in Visual Studio".

Why not save that as your template?


@firemyst

firemyst
02 Aug 2022, 03:12

RE:

PanagiotisCharalampous said:

Hi firemyst,

There is a new debugging process documented here.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook 

Thank you @PanagiotisCharalampous!

The above worked for me using Visual Studio 2017.


@firemyst

firemyst
29 Jul 2022, 03:02 ( Updated at: 21 Dec 2023, 09:22 )

Issue with cTrader 4.2 attaching to processes for debugging

Hi @Spotware  / @Panagiotis:

These are some great features and additions.

However, there's one that as an annoying drawback. Let's say you have at least 3-5 tabs open with trading charts with custom indicators. Now you have Visual Studio open trying to debug one of those indicators. You want to attach Visual Studio to the process.

How do you know which one to attach to?

Here you can see that there's at least 10 algohost processes launched, none of which have a title.

How does anyone know what process to attach the specific code they're debugging to from IDE's like Visual Studio?

I have to attach to the first one. Are breakpoints hit? No? Ok, I have to try the second one. Are breakpoints hit now? No? I have to try attaching to the next process. And so on and so forth.

Is there any way to make this a bit easier for developers? Like, can't @Spotware include a "Title" (or some other identifying information) when the separate algohost processes are spawned?

Thank you.


@firemyst

firemyst
14 Jul 2022, 03:26

" am trying to make this cbot open trades exactly on the MA crossing"

This depends on when you define a MA crossing. Right now, your code doesn't check the current bar/candle to see if the MA's crossed. Rather, it checks the previous bar and the bar before that (last(1) and last(2)).

If you want it on the exact tick that it happens, then you need to check the current values of the MA against the previous bar's values. Eg, last(0) and last(1) instead of last(1) and last(2).


@firemyst

firemyst
07 Jul 2022, 16:31

RE:

safaeianmohsen said:

Hello . Can anyone guide me? I want to add a code to the Ichimoku indicator so that whenever the values of Kijunsen and Span B are equal to each other, Only on the chart that is open , a sound allert will be generated.

If possible, please send it here. 

You would do something like this (pseudo code) in your indicator's calculate method:

 

if (Kijunsen.Result.Last(0) == SpanB.Result.Last(0))

{

    System.Media.SystemSounds.Exclamation.Play();

}


@firemyst

firemyst
07 Jul 2022, 16:28

"Are there now multiple instances of the historical bars taking up memory, or is cTrader intelligent enough to know it only needs one copy of this data for reference by any number of bots that need it?"

This is a question that only @Spotware / @Panagiotis / @Amusleh can answer.

 


@firemyst

firemyst
06 Jul 2022, 03:40

If it doesn't matter, why not just look for the first OnTick that happens after your specified time and execute the order then? So instead of checking if the time matches exactly, just check if onTickTime >= your specified time and if so, execute your actions. If you want it limited to only occur within a few seconds after your specified time, then pseudo logic would be:

if (onTIckTime >= yourSpecifiedTime && onTickTime <= OnTickTime + numberOfAllowedSecondsAfter)

{

   // do what you have to do

}

 

If you do want it at the exact hour:minute:second and a tick doesn't come through, then there's nothing you can do as that's based on the market.


@firemyst

firemyst
29 Jun 2022, 05:16

RE:

cedric.boudreau said:

Do you have somewhere all founction of mathematique , document , i am litle tire to losse 1-2 hrs everytime to found the correct word...

 

i think addind that in your api guide will be appreciated.

 

in that case math.round(dsfd,2,   up)  ?

The "Math" api functions have nothing to do with Spotware as they are all part of the Microsoft .Net framework.

So you need to Google and find what you need on MIcrosoft.

For example, here's Microsoft's documentation for the Math class:

 


@firemyst

firemyst
27 Jun 2022, 07:14

//Quick example on how to sort positions by NetProfit (not gross profit)
//Change things around if you want to sort by time or something else.

foreach (Position p in Positions.FindAll(YourLabel, s.Name).OrderBy(x => x.NetProfit))
{
	ClosePositionAsync(p, (TradeResult r) =>
	{
		if (r.IsSuccessful)
		{
			Print("Closed position \"{0} {1}\".", p.Id, p.Label);
		}
		else if (!r.IsSuccessful)
		{
			Print("WARNING! Could not close position \"{0} {1}\"!", p.Id, p.Label);
			Print("Error message: {0}", r.Error.Value);
		}
	});
}

 


@firemyst

firemyst
25 Jun 2022, 17:34

RE: RE: RE: RE:

ctid2032775 said:

amusleh said:

genappsforex said:

ctid2032775 said:

 A little bit strange is that as soon as I switch to .NET 6, run any bot and close the cTrader application the cTrader process is not terminated, as well.

I noticed that too, This behaviour eats Memory and CPU . Think they're forgetting to clean up/Close old threads.

Hi,

We can only help you if we were able to reproduce the issues you are facing, if we can't then there is no way for us to know what's going wrong.

 

Hi,

after quite a frustrating time I stopped development in ctrader and migrated the project to MetaTrader 5. The trading part is written in MQL, the machine learning part was developed as an external library in C# and there everything is working as expected (on the same environment (!)).

As this part is now finished I got curious and did some further investigation...

What I found out is that it's working in any Windows 10 Home environment (both on an Acer gaming notebook and in a virtual environment (VirtualBox)) but I never got it to work on Windows 10 Professional or Enterprise (both x64 clean installations)!

The problem is that the bot needs to run on a Minix Neo with Windows 10 Pro installed where it's not possible to "downgrade" to home edition (and even if it would be possible I wouldn't do this...).

Accordingly, I kindly ask you to verify possible reasons and keep me updated about the solution.

Many thanks and regards,
Christian

I think what would help the @Spotware crew is if you can record your desktop (or whatever) while reproducing the cTrader issue. This way, their team can see it actually happening.


@firemyst

firemyst
25 Jun 2022, 17:31

Yes.

Example:

System.Media.SystemSounds.Exclamation.Play();

 


@firemyst