Topics
Replies

firemyst
29 Mar 2025, 14:02 ( Updated at: 03 Apr 2025, 07:30 )

/forum/ctrader-support/46731/


@firemyst

firemyst
28 Mar 2025, 12:13

From playing around with it, this is what I gather on how it works:

  1. set it to “none” removes all protections
  2. set it to “relative” means the SL is in PIPs
  3. setting it to “absolutely” means the SL is a price.

I'm not sure if it affects the Take Profit as well.


@firemyst

firemyst
28 Mar 2025, 12:13

RE: same problem

gzarruk said: 

I have the same issue. My bot outputs an error but keeps on running.

I left it with the ProtectionType parameter since removing it gives warnings. 

I would be useful to get more documentation about ProtectionType and how to avoid the crash on the cloud instance.

From playing around with it, this is what I gather on how it works:

  1. set it to “none” removes all protections
  2. set it to “relative” means the SL is in PIPs
  3. setting it to “absolutely” means the SL is a price.

I'm not sure if it affects the Take Profit as well.


@firemyst

firemyst
28 Mar 2025, 00:37 ( Updated at: 28 Mar 2025, 07:16 )

RE: in Ctrader i kept 4 pips TP and 4 pips SL but profit is different and loss is different

ruben.as.nogueira said: 

Hello,

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.

 

Ubaidjr - 

if you show the active trade window at the bottom of cTrader, what does it say for “commission” and “swap” columns?

 


@firemyst

firemyst
27 Mar 2025, 00:41

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.


@firemyst

firemyst
27 Mar 2025, 00:39

Report it as an error in cTrader and when you do reference this thread for them the next time it happens.


@firemyst

firemyst
26 Mar 2025, 11:23 ( Updated at: 26 Mar 2025, 11:51 )

RE: RE: RE: RE: How do you send email notifications from within my cloud cBot?

kylej.ukr said: 

firemyst said: 

Thanks,

Emails are not supported for cloud cBots according this post:

https://community.ctrader.com/forum/ctrader-algo/45033/

Self-discovery is a wonderful thing isn't it? :-)

It sure is :-)

I could only find the post via Google with the exact date you mentioned. Is there a more advanced search here on cTrader?:

This is all I see:

 

 

I don't use their forum search because I'm sure, like cTrader, it has lots of issues :-P

I always use Google (since it'll capture pages from other sites as well), and you have to use more than 1 word. 


@firemyst

firemyst
24 Mar 2025, 23:15 ( Updated at: 26 Mar 2025, 06:16 )

RE: RE: How do you send email notifications from within my cloud cBot?

Thanks,

Emails are not supported for cloud cBots according this post:

https://community.ctrader.com/forum/ctrader-algo/45033/

Self-discovery is a wonderful thing isn't it? :-)


@firemyst

firemyst
24 Mar 2025, 11:09

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?


@firemyst

firemyst
24 Mar 2025, 11:07

Lots of ideas. Start by Googling these forums and you'll see your issue has already been answered.

For starters, a post from 23 Sep 2024.

:-)


@firemyst

firemyst
24 Mar 2025, 06:18 ( Updated at: 24 Mar 2025, 06:55 )

RE: RE: WTF is going on with the latest update.

BBMG said: 

firemyst said: 

It would be great if you could post screen captures showing the issues. 

Sure, no problem.

https://drive.google.com/file/d/129Vr2vJBuNPn8oR5Fcs28D8Tlw1BRC7y/view?usp=sharing

Interesting the few issues you point out there.

The video definitely makes it more clear what issues you have, so thanks for posting that.

Guess we'll see if Spotware monitors this forum and/or will get notified of the issue.

You can obviously tell they don't test their own product before release, because any sort of basic test, like what you did, should have picked it up. 

 


@firemyst

firemyst
23 Mar 2025, 02:39

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.


@firemyst

firemyst
23 Mar 2025, 02:36

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.


@firemyst

firemyst
23 Mar 2025, 02:33

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

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


@firemyst

firemyst
23 Mar 2025, 02:13

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.


@firemyst

firemyst
23 Mar 2025, 02:12

It would be great if you could post screen captures showing the issues. 


@firemyst

firemyst
20 Mar 2025, 01:13

Why is this indicator available on the web platform but not on the desktop version?

 

Probably for whatever reason the rick-reward tool is available for the web version but not the desktop version.


@firemyst

firemyst
20 Mar 2025, 00:43

RE: RE: RE: TICK !

mike.r.alderson said: 

mike.r.alderson said: 

 

@fyremist @gabriel.rabhi 

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:

  1. 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; }
        
        public int counter;
        
        protected override void OnBar()
        {
            counter = 0;
        }

        protected override void OnTick()
        {
            if(Long && Symbol.Ask < SLPrice)
            {
                counter+=1;
            }
            
            else if(!Long && Symbol.Ask > SLPrice)
            {
                counter+=1;
            }
            
            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; }

        protected override void OnTick()
        {
            foreach (var position in Positions)
            {
                if (position.TradeType == TradeType.Buy && position.TakeProfit.HasValue)
                {
                    double currentTP = position.TakeProfit.Value;
                    double priceToTP = currentTP - Symbol.Bid;
                    double maxTP = position.EntryPrice + FinalTakeProfit * Symbol.TickSize;
                    
                    if (priceToTP <= TrailingDistance * Symbol.TickSize && currentTP < maxTP)
                    {
                        double newTP = currentTP + TrailingDistance;
                        newTP = newTP > maxTP ? maxTP : newTP; 
                        Print("newTP: ", newTP);
                        position.ModifyTakeProfitPrice(newTP);
                    }
                }
            }
        }
    }
}

 

 

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

firemyst
19 Mar 2025, 07:05

You have to open it with your broker. Log in to Pepperstone's site and create your account.


@firemyst