Topics
25 Apr 2023, 19:06
 749
 5
10 Feb 2023, 15:16
 1739
 13
08 Jan 2023, 13:41
 1072
 3
25 Oct 2022, 12:41
 1982
 17
07 Sep 2022, 13:02
 1743
 12
06 Sep 2022, 15:25
 3131
 26
01 Sep 2022, 00:00
 1587
 5
24 Sep 2021, 17:56
 961
 4
07 Jul 2021, 07:53
 1989
 13
23 Jun 2021, 19:15
 1148
 3
23 Jun 2021, 09:29
 1648
 1
Replies

Xammo
25 Sep 2022, 11:42

I don't know if this is related but I am also unable to build in VS2019 on one of my VPS's (other one same setup works fine) after I accidentally/unknowingly installed 4.2 when trying to set my 4.1 install to 'Startup -> Multiple Profiles' (I had no idea creating a profile would install a new version of cTrader or why it chose to install 4.2) but now no matter what I do (uninstalled the 4.2 uninstalled the 4.1 uninstalled VS reinstalled it all and the VS Extension countless times) the build in VS just hangs and never completes/have to kill VS in TaskManager - have tried on a newly created cBot and same thing just hangs will never build...

(Panagiotis if you see this please can you let us know if there is some way you will be communicating the fixes as they are completed for 4.2? If the OnBar and Server.Time issues are resolved I should be able to use 4.2 or 4.3 for that matter but yeh please is there somewhere we can get updated on the fixes as they come out? Thanks)


@Xammo

Xammo
14 Sep 2022, 15:25

Hi

No that was just a random number - it depends how long you want to wait/how you are running things in your code/strategy

Do you want to wait 100 ticks before a closing trade(s) has allowed one single trade to open before allowing another closing trade(s) to allow the next single trade to open or 100 bars - or 10000 ticks etc.

Basically what is the delay between a bunch of trades closing that allowed the one trade you wanted open to open that you will allow the next bunch of closing trades to allow a single trade to be opened?

Either that or my suggested approach isn't going to work for you I dunno but yeh it was more to give you an idea how you could go about getting to where you want to be but I would guess you haven't much experience (fine no problem we've all been there etc.) if you don't know you can set the 100 to whatever you want so I would also guess you need to get clue'd up more on how things work and really think on what it is you want your strategy to do - for example it might work in one way you are thinking but many things can happen and you need to think what you would want to do if x y z happened and how it could all fit in the code if that makes sense... best o luck!

Oh also if/when you reply -> to prevent the thread here getting majorly long just use the reply button at the top then you don't get all the previous messages displayed in your post - or just delete all the previous messages unless you wanted to quote something or whatever - cheers


@Xammo

Xammo
14 Sep 2022, 12:02

OK I get it now... 4.1 does not seem to be a proper full install rather it unpacks the .exe into a folder in the same directory, creates a few settings folders in appdata\roaming, the usual folders in documents (plus all the sample indi's/bots again that I delete... again... would be good to have an option to choose not to install the sample files btw have deleted them more times than I care to think of) and no 2.0 folder is created

So to really really uninstall 4.1 you just delete all the folders I guess (mine had been running from my downloads folder before I worked all this out! not too happy about that but anyway moved it now...)


@Xammo

Xammo
12 Sep 2022, 14:01

Hi

I've installed 4.1 on both VPS's now (was going to keep one at 4.2 or 4.3 to keep an eye out for when things get sorted but actually realised I'd rather concentrate on trading and send good vibes Spotware's way in the hope they manage to nail the issue(s) quickly instead ;)

NOT urgent but neither VPS is showing 4.1 in add/remove programs - there is no 2.0 folder and when I went to install 4.1 on the second server that had at one time had 4.1 (which I couldn't uninstall for the above reasons) when I kicked off the install it opened 4.1 straight up rather than installing!

So yeh just for future reference is there some way to really ummm really really uninstall 4.1?

Thanks

Max 


@Xammo

Xammo
12 Sep 2022, 13:53

Hi Marcin

Just a few suggestions that might help/give you some ideas - obviously you'd most likely want to knit them into your logic rather than having them as hard set parameters and checking every OnTick with ClosePositionAsync creates additional headaches trying to work out how to not try and close a position that is already in the process of closing! (same goes for ExecuteMarketOrderAsync - I've still yet to work out a graceful/rock solid way to deal with Async stuff!)  but yeh hopefully it helps and best of luck!

 

using cAlgo.API;
using System.Collections.Generic;
using System.Linq;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter("StopLoss_Amount", DefaultValue = 100)]
        public double Param_double_StopLoss_Amount { get; set; }

        [Parameter("StopLoss_Pips", DefaultValue = -10)]
        public double Param_double_StopLoss_Pips { get; set; }

        [Parameter("StopLoss_Price_Sell")]
        public double Param_double_StopLoss_Price_Sell { get; set; }

        [Parameter("StopLoss_Price_Buy")]
        public double Param_double_StopLoss_Price_Buy { get; set; }

        protected override void OnTick()
        {
            Check_StopLoss(TradeType.Sell);
            Check_StopLoss(TradeType.Buy);
        }

        private void Check_StopLoss(TradeType tradeType)
        {
            IEnumerable<Position> pos_All_TradeType = Positions.Where(x => x.SymbolName == SymbolName && x.TradeType == tradeType);

            //THIS
            if (pos_All_TradeType.Sum(x => x.NetProfit) <= Param_double_StopLoss_Amount)
            {
                CloseAll_TradeType(pos_All_TradeType);
            }

            //OR THIS
            if (pos_All_TradeType.Sum(x => x.Pips) <= Param_double_StopLoss_Pips)
            {
                CloseAll_TradeType(pos_All_TradeType);
            }

            //OR THIS
            if (tradeType == TradeType.Sell)
            {
                if (Symbol.Ask > Param_double_StopLoss_Price_Sell)
                {
                    CloseAll_TradeType(pos_All_TradeType);
                }
            }
            else
            {
                if (Symbol.Bid < Param_double_StopLoss_Price_Buy)
                {
                    CloseAll_TradeType(pos_All_TradeType);
                }
            }
        }

        private void CloseAll_TradeType(IEnumerable<Position> pos_All_TradeType)
        {
            foreach (Position pos in pos_All_TradeType)
            {
                ClosePositionAsync(pos);
            }
        }
    }
}

 


@Xammo

Xammo
12 Sep 2022, 13:28

Hi Vadivelan

I'm no pro so don't take the following too seriously just thought it might help you with an idea to get to where you want to be although you probably already realise you need to think things through more about your strategy as you work things out usually two more problems/challenges turn up!

I just had a quick go at coding something up and initially thought a flag would do the job but what about a countdown timer?

It all depends what timeframe you are working on - for example if 10 trades close all at once (even if you use ClosePositionAsync they won't all close at exactly the same millisecond) how long do you want to wait after the one trade has executed to be 'in the clear' to open another trade?

If a bunch of 10 trades closed between 12:00:00 -> 12:00:16 and another closed at 12:01:00 do you want to open a trade at 12:00:00 and 12:01:00 or do you consider them to be closing at the same time - depends on your timeframe kind a thing...

Basically what is the 'wait time' between determining a 'bunch of trades closing at the same time' and a 'series of trades closing one after the other in fairly close succession that you want a new trade to be executed each time'?

Anyway here you go - not tested/could well be issues depending on how you enter trades etc./just quickfire code probably doesn't confirm to coding etiquette/hopefully gives you some ideas and of course best of luck!

 

using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter("Count", DefaultValue = 100)]
        public int Param_int_Count { get; set; }

        private int int_Count;

        protected override void OnStart()
        {
            Positions.Closed += PositionsOnClosed;
        }

        protected override void OnTick() //change to OnBar if you want to count down bars
        {
            if (int_Count > 0)
            {
                --int_Count;
            }
        }

        private void PositionsOnClosed(PositionClosedEventArgs args)
        {
            var pos = args.Position;
            var sym = pos.SymbolName;
            var close = lowBar[sym].ClosePrices.LastValue;
            double vmacur = vma[sym].Result.LastValue;
            double minvolume = Symbols.GetSymbol(sym).VolumeInUnitsMin;

            if (close > vmacur && int_Count == 0)
            {
                ExecuteMarketOrder(TradeType.Buy, sym, minvolume, "EA", 0, 0);
            }
            else
            {
                ExecuteMarketOrder(TradeType.Sell, sym, minvolume, "EA", 0, 0);
            }

            int_Count = Param_int_Count;
        }

        protected override void OnStop()
        {
            Positions.Closed -= PositionsOnClosed;
        }
    }
}

 


@Xammo

Xammo
08 Sep 2022, 18:06

Sure understood these things happen and am glad you know about it and are working on it and best of luck getting it sorted etc. all good - what I meant is I would assume/hope you wouldn't release 4.3/force those on 4.1 to update to 4.2 until you are 99.9999% certain all the bugs are ironed out in 4.2


@Xammo

Xammo
08 Sep 2022, 12:59

Right ok thanks for confirming but obviously you couldn't possibly release 4.3 when OnBar and Server.Time don't work in 4.2... right? (not to mention the automate display problem)

I mean am I missing something here this isn't a 'little' problem


@Xammo

Xammo
08 Sep 2022, 12:32

Hi Paolo

If you don't need the bells and whistles (or potentially disastrous known issues!) of 4.2 I'd suggest rolling back to 4.1 if you want the automate display to work properly - https://ctrader.com/forum/ctrader-support/38830?page=1#8 


@Xammo

Xammo
08 Sep 2022, 12:27

4.1 working rock solid all OnBar and OnTick printing as they should on the hour in the BarTest bot and no loss of automate display after kicking off half a dozen backtests and clicking between them/code editor everything working just like it always used to

It is beyond me how Spotware could allow their recent version to go into production knowing OnBar and Server.Time.Hour do not work correctly (what else isn't working?) but at least 4.1 works properly so obviously I won't be upgrading any time soon

Panagiotis before I start full swing into running bots live that will not be able to be stopped easily can you please confirm that there are no plans to force clients to update and that 4.1 is sticking around for the forseable future please?

Thanks

Max


@Xammo

Xammo
07 Sep 2022, 21:06

Hi Panagiotis

It does not seem this issue is solved in 4.3 at least not for me/in my particular setup

I just logged on to check how things were progressing and the BarTest bot was showing an OnTick at 13 minutes past an hour (and also the 2 EMA's I have on the chart as being loaded/unloaded at the same 13 minutes past the hour - I have only just started seeing this since upgrading to 4.2 - no idea why it is loading then unloading them or what is going on but do not think this has anything to do with my issues but would seem like the whole bot is being reloaded or something?)

Then before I copied all the info to paste in here I stupidly clicked onto the live bot as I could see no trade had been entered on the last new bar (2 had entered succesfully on the hour bars since start/I am using the OnBar to trigger the trade not the server.time in OnTick thinking if it is working in 4.3 this is the proper/better way to do things) and unfortunately I am still getting the total loss of the Automate Display in 4.3 so I lost access to everything viewable and had to resart cTrader to get things working again

I will roll back to 4.1 but these issues are really making me think twice about what is going on with cTrader I know there were many suggestions/wants from the community in the pipeline for a very very long time but core functionality issues like this I have never experienced...

Whilst I am typing this it has just turned the hour and the live bot entered the trade correctly and the BarTest bot showing both OnBar and OnTick as it should

Just thinking out loud here but could the loss of display be linked to this somehow? It seems to be happening after a certain amount of time (I hope you have seen the other trader having the same issue?) could this be when the bot tries to reload and everything gets messed up/restarted somehow even though it is already running?

Will report back with how things go in 4.1


@Xammo

Xammo
07 Sep 2022, 17:48

OK thanks I've gone for 4.3 guess I'm well out of touch/been off cTrader for the summer seems things have moved on quite a bit and cross broker seems good/presume it must be beta as 4.2 was long talked about etc. anyway I've kicked off the live bot and the BarTest bot so will keep an eye and hopefully no issues like this again thanks again for your help


@Xammo

Xammo
07 Sep 2022, 16:11

Hi Panagiotis

Thanks for your reply and honesty but this is a massive shock to hear

How long has it been known about and when is soon?

How could such a serious issue have made it through to production?

What if my bots were weeks/months into working and this happened (I presume it must be from an update?) It would completely destroy the strategy and risk serious real world $$$ losses!

I think I have seen others ask - is it possible to stop automatic cTrader updates?

I have also seen many mentions about rolling back to 4.1 but honestly I thought the platform was broker specific so how can I roll back to a generic 4.1 is that possible?

Is this issue only with 4.2/can I roll back to 4.1 and the timing will work properly please?

Thanks

Max


@Xammo

Xammo
07 Sep 2022, 14:08

07/09/2022 09:13:47.912 | CBot instance [BarTest, AUDUSD, h1] started.
07/09/2022 09:13:48.553 | STARTED
07/09/2022 09:36:38.659 | OnTick
07/09/2022 10:00:00.278 | OnTick
07/09/2022 10:00:00.278 | OnBar
07/09/2022 10:50:46.540 | OnTick
07/09/2022 11:00:00.774 | OnTick
07/09/2022 11:00:00.774 | OnBar
27/10/2022 02:39:25.610 | OnTick
27/10/2022 03:53:33.350 | OnTick
 

hmmm...

I've edited the code in the LIVE bot to use OnBar (it has opened live trades on these dodgy time stamps) but highly suspect the same issue is going to occur - at least it did in demo but I just want it to work in LIVE!


@Xammo

Xammo
07 Sep 2022, 01:57

Hi Paolo

I'm having the same issue - submitted a ticket a few days back and posted about here - https://ctrader.com/forum/ctrader-support/38822?page=1#5


@Xammo

Xammo
07 Sep 2022, 01:47

If it might make any difference set access rights to full in the bot too just realised I've got that set aswell

Also looking at the screenshot in the other ticket about this it seems they are with Raw Trading Ltd same as me - could that have something to do with it? I downloaded cTrader from their site once logged in to my account in the download area - 4.2.22.8460


@Xammo

Xammo
07 Sep 2022, 01:21

It keeps happening and is getting really annoying/also just seen another person has posted reporting the same issue

Panagiotis try running a backtest on tick data from the server - hourly chart - trade every hour and let it run for 6 months plus then try clicking on another bot/instance/code editor - this is when it seems to be happening for me


@Xammo

Xammo
06 Sep 2022, 15:43

Hi Panagiotis

Thanks - are you able to test on a Beeks VPS or equivalent? Their VPS's are running on VMWare with a VMWare SVGA 3D display adapter/Windows Server 2012 R2 in the Gold tier at least anyway

There seems to be no rhyme or reason to when/why it is happening no idea how am gonna pinpoint what is causing it other than 'oh ok ****** it's happened again'... then I can screenshot it (useless I think?) restart (annoying) and start again (losing all the backtest results)

Anything I can do/send that would help?


@Xammo

Xammo
01 Sep 2022, 19:23

Just got back to using email notifications (that had worked for ages with gmail) and realised they weren't working/came across this thread

Managed to get them working no problems using an outlook account - nothing special other than setting the sending/receiving email addresses in the bot code to same email address and entering all the outlook SMTP details as found on the web - probably don't have 2FA set on the account either as is purely for notifications but haven't checked - good luck anyone who is trying


@Xammo

Xammo
01 Sep 2022, 19:19

Cheers Panagiotis as always! You seem to have some magic touch it would seem as I had another crack at it today and no idea what was done differently (yeh I already followed those instructions as many times before/looks like they might need updating tho as I am not seeing a 2.0 folder with the latest install) and it is now working with .Net6.0 and VS2022! Result! Thank you will have to get the other VPS sorted too

(I also submitted a request via Ctrl/shift/T or whatever it is about the display dissapearing when I clicked between backtests - anyway that is sorted now too/no idea how to notify Spotware it's resolved)


@Xammo