Topics
Replies

firemyst
26 Jan 2025, 06:35 ( Updated at: 14 Feb 2025, 18:19 )

RE: RE: Parameter stopLossPips and takeProfitPips in PendingOrder

ysftrades said: 

PanagiotisCharalampous said: 

Hi all,

You just need to use the new parameter called protectionType and set explicitly what the protection type is.

public TradeResult PlaceStopOrder(TradeType tradeType, string symbolName, double volume, double targetPrice, string label, double? stopLoss, double? takeProfit, ProtectionType? protectionType)

Best regards,

Panagiotis

Hi Panagiotis,

Thank you for sharing that.
This a new parameter that is added. 
I looked up the Help section to try and understand what does the ProtectionType parameter do. 
I understand that they are three values to choose from; ProtectionType.None, ProtectionType.Relative and ProtectionType.Absolute
I couldn't understand what is their effect. Could you be kind enough to elaborate what do they do to an order or position?

Thank you

Seems like even @Panagiotis doesn't know since there's been no response… he's been awfully quiet. Wonder if he's still around or on vacation or something?


@firemyst

firemyst
25 Jan 2025, 09:59 ( Updated at: 14 Feb 2025, 18:19 )

RE: RE: Help with error code

jaydcrowe1989 said: 

 

Thank you. I have submitted a report. Surely the error code must mean something? Why isn't there a list of error codes somewhere?

Who are you expecting the list to be from?

Can you guarantee it's a Spotware cTrader error and not

  • a Microsoft one? They control the underlying operating system and .Net architecture that could be throwing the error code back to cTrader.
  • Who's the hardware provider you're running your software on? Dell? HP? It could have been one of their drivers that threw the error code to Microsoft's OS that bubbled up to cTrader.
  • Do you have an nVidia graphics card? Intel graphics? AMD? It could have been a video card error depending on what was trying to be displayed. 

My point being - hardly any hardware/software provider is going to publish a list of all the possible error codes their product will throw. Half the times, you won't even know what's throwing/causing the underlying error (because of the way some errors “bubble up” through various hardware/software components to even know which vendor's error codes you'd have to research. For instance, Dell could have thrown one error, which was received by Windows .Net and given another error, which cTrader captured and reported as a third error code.


@firemyst

firemyst
25 Jan 2025, 09:48 ( Updated at: 14 Feb 2025, 18:17 )

Maybe you should consider posting your code and/or other information that will help people.

Seriously, how do you expect anyone to be able to help if you don't show your algorithm's code? There could be all sorts of bugs in it.

You might also be testing on 1 minute bars for data whereas your bot reacts to every tick, and thus you actually should be testing on tick-data.


@firemyst

firemyst
25 Jan 2025, 09:45 ( Updated at: 14 Feb 2025, 18:17 )

Easy.

You go to another broker's website, like Fusion Markets, (who also support cTrader) and sign up.

It really is that simple.


@firemyst

firemyst
25 Jan 2025, 09:43

Take your screen capture, copy it, and then paste it in your post.

Or click on the icon that inserts an image:

 


@firemyst

firemyst
25 Jan 2025, 09:42

Right click on the chart and under viewing options (1), select “show deal map” (2):


@firemyst

firemyst
25 Jan 2025, 09:39

All brokers differ because they have different price feeds. 

Open an account with another broker like ThinkMarkets and you'll see that their trading platform differs from cTrader brokers by several points either side as well. 

 

Same with Oanda.

 

What's important is that the candles and pricing moves the same. 

 


@firemyst

firemyst
25 Jan 2025, 09:36

PLease post this under the “Suggestions” forum as this is a tech-support forum - they won't come here looking for ways to improve their product. That's what the Suggestions forum is for.


@firemyst

firemyst
25 Jan 2025, 09:36

PLease post this under the “Suggestions” forum as this is a tech-support forum - they won't come here looking for ways to improve their product. That's what the Suggestions forum is for.


@firemyst

firemyst
24 Jan 2025, 10:35

Maybe it's a language barrier, but nowhere in the code you posted does it show you trying to get the SL or TP from the position that was opened. 

If you are trying to set the SL or TP of the current position, nowhere in the code you posted are you doing that either.

You need to do something like :

ModifyPosition(_positionToModify, _positionToModify.VolumeInUnits, slLevel, tpLevel, ....)

@firemyst

firemyst
24 Jan 2025, 10:24

Definitely would be a nice feature


@firemyst

firemyst
24 Jan 2025, 10:23

Have you actually tried your cTrader ID? Note that it's not the same as your email.

 


@firemyst

firemyst
24 Jan 2025, 01:49

I believe with the event listeners, they will only work for the current running instance. That's it.

So if you have your bot under AUDUSD for example, it will only respond when bars are opened for AUDUSD.

Your code is only getting the information for the current symbol instance the bot is running under.

Thus, you need to change your code to handle multiple symbols. Example guidance below:

// We get a symbol array for the following for symbols
MySymbols = Symbols.GetSymbols("EURUSD", "GBPUSD");

//You need to get the bars data for each symbol now
Bars[] SymbolBars = new Bars[MySymbols.Length];

//You need create a variable array to keep track of the symbol's current index
int[] Indexes = new int[MySymbols.Length];

//You need create a variable array to keep track of when a new bar is opened
int[] _previousIndexes = new int[MySymbols.Length];

//Loop to initialize all the data
for (int x = 0; x < MySymbols.Length; x++)
{
	//get the bars data for each symbol
	SymbolBars[x] = MarketData.GetBars(<the time frame you want>, MySymbols[x]);

	//define your onTick method in your code that every symbol will use to check for ticks
	MySymbols[x].Tick += OnTickEventMethod;

	//Initialize all these
	Indexes[x] = 0;
	_previousIndexes[x] = 0;
}



//You need to define and write your OnTickEventMethod 
private void OnTickEventMethod(SymbolTickEventArgs stea)
{
	//Get the symbol the tick event came from
	int x = Array.FindIndex(MySymbols, element => element == stea.SymbolName);

	//Skip any bar symbols that may not have loaded yet.
	if (SymbolBars[x] == null)
		return;
	else
 	{
		Indexes[x] = SymbolBars[x].ClosePrices.Count - 1;

		//check if a new bar has formed
     		if (Indexes[x] > _previousIndexes[x])
     		{
			//we have a new bar
			//write your onBar logic here

			//update our bar trackers
			_previousIndexes[x] = Indexes[x];
		}

		//from here down is where you would put your normal tick event code

		//if you want anything for the specific symbol, you have to reference it through the arrays and create arrays for your variables.
		//For example, you can't do this any more:
		//countLabelFuerte++

		//You need to make it an array as well and do this because you only want to increase the counter for the specific symbol,
		//not across all symbols:
		countLabelFuerte[x]++;

		//Welcome to the big leagues :-)

		//If you're a beginning programmer, what I would suggest you do is get your bot working as you want it for one
		//symbol only. And then when it's working to your satisfaction, convert everything to arrays to handle multiple symbols
		//under one bot instance.

	}
}

@firemyst

firemyst
24 Jan 2025, 00:50

Why would results differ so much with only 3 trades been opened all within 17  days of each other?

One possibility is because of the market moves within those 17 days? That's how the markets work :-)

 

I'm not sure how you expect anyone to help you when you haven't described the strategy, shown any code, why you're using one-minute bar data as opposed to tick-data doing your testing, what time frame the bot is running under, the trade entries/exits on the back test with and without the optimized parameters, etc etc.

 

For instance, the bot could make decisions on every tick, but by running on one-minute bars you only get the bar data, not every tick.

Within bars they could be huge spikes not captured in bar data but would be with tick data.


@firemyst

firemyst
24 Jan 2025, 00:36

Yes, it's a C# language construct just like it is in C++. It's not specific to cTrader.

Google “c# multidimensional array”


@firemyst

firemyst
23 Jan 2025, 11:56

RE: RE: Positions Tab Removed for cTrader Copy live trades monitoring AGAIN!!!

tbssecurett said: 

firemyst said: 

Is there a reason you haven't posted a screen capture showing the issue? 

Normally when I am copying a strategist, when they open trades I can see their positions live under the positions tab after the recent updates, it returned for two days and then disappeared again. Enter the image below, the red arrow shows where it's usually located.

 

 

I can't help you because I don't use cTrader Copy. However, at least you clarified where the tab missing from, because for most people, the “Positions” tab is on the “Trade” window. Lesson learned - you need to be more specific when posting issues :-)

 

 

 


@firemyst

firemyst
23 Jan 2025, 01:26

Next time it happens report it as a technical issue within cTrader and put a link to this thread in the details section along with other pertinent information such as:

  1. using Windows/Mac
  2. running locally or cloud
  3. using .NET6 or .Net Framework
  4. cTrader version
  5. what exactly you do when you notice the error

@firemyst

firemyst
23 Jan 2025, 01:23

Write the author of the bot and ask them for the code.

 


@firemyst

firemyst
23 Jan 2025, 01:21

Is there a reason you haven't posted a screen capture showing the issue? 


@firemyst