This is due to broker commission. The broker always charges you a fee for opening a trade and you need to subtract it to the real takeprofit and stoploss monetary value. Once your trade is closed, you can see the amount of commission they charged in the trade history details.
You need to be aware of spread and commissions in trading, that's basically how the broker makes money. The commission increases with bigger positions.
Best Regards,
RN
I think the point is, if you look at the value of the “SL” line on the chart, and the estimated stop loss amount in the open trade window, they are significantly different, despite having the same pips set as the stop loss.
The SL line says 10.45 Euros for 3 pips; the modify position window says 7.45 Euros for 3 pips.
Both those numbers should be relatively the same – there shouldn't be a big difference.
While different brokers charge different commissions, cTrader shouldn't be showing traders two different estimated stop loss values for the same number of pips in two different places. That is very misleading.
I would like to see you add this to the “Suggestions” forum where it belong since this is a tech support forum and they don't come here looking for ways to improve their product.
You can start by posting code, and what you expect to see happen when, and also screen captures of the differences between back testing and running when you deploy it.
Otherwise, how else do you expect people to be able to help you with nothing to go on?
I know. Such a basic feature and yet seems like they have the only development team on the planet that isn't able to implement such a feature on their mobile app unlike all the other mobile trading platforms.
Or even .Net version 8 since that's the longer term supported one for now.
Spotware obviously didn't implement the ability to upgrade supported .Net versions in a “best practice” manner or it wouldn't be so difficult for them to do so.
You can't create a cbot for “Exclusively” on any kind of chart.
However, what you can do is get code in your cbot so it only runs on heikin ashi charts.
Example:
if (!Chart.TimeFrame.Name.Contains("Heikin"))
{
Print("This bot only runs on Heikin charts.");
Stop();
}
For some reason it does not allow me to create one (build errors pop up) when using chatgpt.
Did you ever stop to think that maybe build errors pop up because there's actually build errors in the code generated by Chatgpt and not as a restriction within ctrader?
firemyst
23 Mar 2025, 02:15
( Updated at: 28 Mar 2025, 07:58 )
How do we know if you're doing anything wrong when you haven't posted any sample code demonstrating what you are doing? Or you have posted code and it's still awaiting “moderation”? :-P
And it would be ideal if you post things like this in the “suggestions” forum since this is tech support and Spotware doesn't come here looking for suggestion on their product.
Thanks, both of you, for the help and support. Making Huge changes in my code, backtesting, and strategy.
This code probably seems a bit basic but thought I'd share:
This is my Hidden StopLoss code, uses a timer, so if the price moves below that SL price for a pre-determined amount of time (I use 60 seconds), it closes the trade.
using System; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals;
namespace cAlgo.Robots { [Robot(AccessRights = AccessRights.None, AddIndicators = true)] public class HiddenSL : Robot { [Parameter(DefaultValue = 42)] public double SLPrice { get; set; }
[Parameter(DefaultValue = 60)] public int Duration { get; set; }
[Parameter(DefaultValue = true)] public bool Long { get; set; }
if(counter > Duration) { foreach(var position in Positions) { ClosePosition(position); } } } } }
2. And this one moves my Take Profit whenever the price gets too close until it gets to the price I actually want to Take Profit at. (Still in testing)
using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals;
namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class TrailingTPBot : Robot { [Parameter("Trailing Distance (pts)", DefaultValue = 10)] public int TrailingDistance { get; set; }
[Parameter("Final Take Profit (pts)", DefaultValue = 100)] public int FinalTakeProfit { get; set; }
Issues with your code samples above. The one where you wait allegedly 60 seconds. It doesn't wait 60 seconds. The amount of time it waits can vary depending on how often the ticks come through. You're also not guaranteed a tick per second. To actually wait 60 seconds, you need to create a timer event.
You're also not resetting your timer in the code you provided. That is, it will continuously count upwards, and never down if the price isn't passed your SL.
Lastly, you're bot will close every symbol, even if the price hasn't moved beyond your SL, if the counter rises above 60.
//Quick code to kinda fix your issues as you have it.
//Here is some example code on how to handle it for ONE symbol.
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimerEvent);
aTimer.Interval = 1000; // ~ 1 second
aTimer.Enabled = true;
// Specify what you want to happen when the Elapsed event is raised.
private static void OnTimerEvent(object source, ElapsedEventArgs e)
{
if (Long)
{
if (Symbol.Ask < SLPrice)
counter+=1;
else
counter -= 1;
}
else //shorts
{
if(Symbol.Ask > SLPrice)
counter+=1;
else
counter -= 1;
}
//can't have the counter go negative
if (counter < 0)
counter = 0;
if(counter > Duration)
{
ClosePosition(position);
}
}
}
//If you want it to work properly for every symbol or every position while only running ONE bot instance,
//then you'll need to put everything in arrays or dictionaries (or something) and run through every symbol in your array.
//you'll also have to provide as a parameter (or coded) the symbols you intend to have the bot watch and store those in an array.
Symbol[] _symbolsData;
int[] counter;
System.Timers.Timer[] aTimer;
Bars[] _marketSeries;
protected override void OnStart()
{
_symbolsData = new Symbol[numberOfSymbolsToWatch];
_marketSeries = new Bars[numberOfSymbolsToWatch];
for (int x=0; x < numberOfSymbolsToWatch; x++)
{
_symbolsData[x] = Symbols.GetSymbol(Bars[x].SymbolName);
//Set each SYmbol to listen to its own OnTick Method
_symbolsData[x].Tick += OnTickEventMethod;
_marketSeries[x] = MarketData.GetBars(Bars.Timeframe, _symbolsData[x]);
//set the timer and interval for each symbol we are watching
aTimer[x] = new System.Timers.Timer();
aTimer[x].Elapsed += new ElapsedEventHandler(OnTimerEvent);
aTimer[x].Interval = 1000; // ~ 1 second
aTimer[x].Enabled = true;
counter[x] = 0;
}
}
private void OnTickEventMethod(SymbolTickEventArgs stea)
{
int x = Array.FindIndex(_symbolsSymbols, element => element == stea.SymbolName);
if (x == _currentSymbolsIndex)
return;
//blah blah blah. DO your ontick stuff here
}
// Specify what you want to happen when the Elapsed event is raised.
private static void OnTimerEvent(object source, ElapsedEventArgs e)
{
//get the timer for the specific symbol
//check the counter[x] for the symbol
//close position[x] if needed
}
As for your TP code, similar issue in that it's only watching the “ticks” for the symbol that the instance is set against. So hypothetically, if the bot instance is running against EURUSD, and news comes out for either GBP or JPY, those pairs could have several more ticks within the space of one tick on EURUSD - your bot misses out on those additional ticks. Again, you're not guaranteed tick-for-tick between symbols, and that could definitely throw off your bot's ability to keep up, and the overall trade results.
PS: you misspelled my name in an interesting way. :-)
firemyst
29 Mar 2025, 14:02 ( Updated at: 03 Apr 2025, 07:30 )
/forum/ctrader-support/46731/
@firemyst