Replies

zelenij.krokodil
10 Jul 2016, 18:18

First, I don't know if you can actually use .NET framework 4.5 with cAlgo - I think our good friends from Spotware are lagging a few years behind the rest of the world in that regard.

 

You can add a reference to cAlgo dll - you should be able to find it in your Documents/cAlgo somewhere.

 

Then you need to have a reference to a Robot object - pass it to your state machine as a construction time parameter or have it as a property which you will set first thing.


@zelenij.krokodil

zelenij.krokodil
08 Jul 2016, 09:07

A followup

I ended up creating my own squid HTTP proxy and configuring it in such a way that it allows CONNECT for port 80 as well as 443.  I really hope Spotware fix their code as well, because in the end of the day they are not compliant with the most common Internet practices of using port 80 for clear text traffic only.


@zelenij.krokodil

zelenij.krokodil
07 Jul 2016, 15:58

RE: RE: RE: Same problems

For the sake of other users with similar issue: the Spotware support has done some investigation and it boils down to the fact, that cTrader tries using an SSL-encrypted protocol while connecting to port 80.  My ISP doesn't seem to like this kind of traffic, which is somewhat understandable - after all, 80 is clear text HTTP, at least by widely accepted convention.  Obviously, many other ISPs don't seem to care, that's why only few users are affected by this kind of behaviour.  Spotware are working on a solution, but I haven't been given any timeframe.

In the meanwhile I'm thinking about temporary workarounds for myself.


@zelenij.krokodil

zelenij.krokodil
06 Jul 2016, 12:01

RE: RE: Same problems

EDOD said:

zelenij.krokodil said:

For 4 days now I'm unable to log into my account. I wrote to the support, but so far have received exactly 0 help from them.  They keep on trying to blame my internet connection or my OS.  This is pathetic!

ahh good to know that i'm not the only one with these issue!! well then i've already contact my broker and they would tell me if they find solution.

Try contact your broker bro! Hope it will work soon.

I am still using cTrader demo account, because my algo is in development.  So I have no other recourse than the spotware support.  Which so far hasn't helped at all.


@zelenij.krokodil

zelenij.krokodil
04 Jul 2016, 17:57

Same problems

For 4 days now I'm unable to log into my account. I wrote to the support, but so far have received exactly 0 help from them.  They keep on trying to blame my internet connection or my OS.  This is pathetic!


@zelenij.krokodil

zelenij.krokodil
29 Jun 2016, 17:14

RE:

I am getting the same issue today.  Any idea why????


@zelenij.krokodil

zelenij.krokodil
20 Jun 2016, 16:24

RE:

Mikro said:

Hi,

sounds like an idea. Havn't created a separate library project for a cBot yet.

How would you do that an how would you transfer the stateinfomation, buy and sell signals and so on?

Do you know an open source tool for graphical statemachine design? I took a look at the MATLAB Stateflow Demo but could not manage to compile c# code...

THX

Depends on what you need to do, you can:

1. In the library create a state machine object, that accepts Robot as one of the construction parameters

2. Use the state machine object to make all the trading decisions, calling to the relevant Robot methods

3. In the actual algo create an instance of the state machine object and pass it this

4. Don't forget to reference cAlgo dll in the library project

I personally haven't used any state machine generation code, so can't help you here.  But there must be at least some libraries that will make your life easier - maybe search for workflow or rules engines


@zelenij.krokodil

zelenij.krokodil
19 Jun 2016, 08:09

RE:

Mikro said:

Hi all,

to implement trading strategies a state machine would come in handy at times.

As of now I found no other option to code one than to use a switch statement and an enumeration to be able to switch to different logic blocks depending on the actice Triggers...

      private enum ds
        {
            Timer,
            Idle,
            OpenLong,
            OpenShort,
         }

  switch (DirectorState)
                {
                    case ds.Timer:      // DS: TIMER
                        if (DsTimer()==true) CycleComplete = true;
                        break;

                    case ds.Idle:       // DS: IDLE
                        if (DsIdle() == true) CycleComplete = true;
                        break;

                    case ds.OpenLong:   // SM: OPEN LONG
                        if (DsOpenlong() == true) CycleComplete = true;
                        break;
                  }

 

For Visual Studio there are Add-ins like 'Stateless' Designer but I could not get them to work for cBot design so far.

Has anybody found a tool, perhaps even a graphical, to create StateMachines in a cBot so far?

THX

Can't you create a separate library project, design the state machine there and then just link the library to your main cBot robot project?


@zelenij.krokodil

zelenij.krokodil
14 Jun 2016, 18:26

I have a text file in my algo project in Visual Studio.  I set the build action to Embedded Resource.  In a regular .NET assembly I could read it with code similar to this:

 

var assembly = Assembly.GetExecutingAssembly();
var resourceName = "MyCompany.MyProduct.MyFile.txt";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
    string result = reader.ReadToEnd();
}

But the algo building process must be stripping resources, I guess, because mine isn't there.


@zelenij.krokodil

zelenij.krokodil
14 Jun 2016, 18:18

RE:

Spotware said:

Dear Trader

The backtesting data is historical data. 

We recommend you to set the data of backtesting to Tick Data from Server, which is accurate.

Yes, I know that backtesting is done using historical data.  It still has timestamps, that tell when the event was recorded in the past, doesn't it?  It would be useful information for me.


@zelenij.krokodil

zelenij.krokodil
11 Jun 2016, 16:55

RE: RE: RE: RE: RE: RE:

moneybiz said:

zelenij.krokodil said:

Yes, yes, I understand why it's happening!  And no, there is nothing in any log, because I can't get to that stage - in cTrader the algo isn't even listed.  And in cAlgo it's disabled, so I can't run it.  That's why I call it a bug in cTrader/cAlgo - a bug in the GUI.  I think cTrader should not hide those algos that produced an exception on initialization, but should list them in red colour with an error message.

Not listing it or disabling it is a sign of something not right on the initialization part of the bot namely parameters. Which seems enough indication to make you check the code.
But you want it to tell you exactly which part caused the error. Simply you want them to do your job for you.
Probably those attributes are processed on non UI thread and only after proper initialization of the bot each bot is assigned a log window until then it is not possible to display a visual error message.
Actually it is not a bug it is by design that way. Only it could be more informative.

I think the GUI should be as helpful as possible when dealing with errors, even if I am the culprit.  Especially when it can, as is in this case.  Clearly, some exception is thrown when they try to cast object which happens to be System.String to double.  It wouldn't be very difficult to a) show the algo in red and b) add the fact that an InvalidCastException was thrown - and here is the stack trace.  Silently swallowing the error is not very helpful, since I don't have a clue regarding what exactly is going on.


@zelenij.krokodil

zelenij.krokodil
11 Jun 2016, 07:55

RE: RE: RE: RE:

moneybiz said:

zelenij.krokodil said:

moneybiz said:

zelenij.krokodil said:

I had this error in my algo code:

 

        [Parameter(DefaultValue = "SomeValue")]
        public double MySetting{ get; set; }


 

So the property type (double) doesn't really match the default value (string).  This thing compiles successfully, but then cTrader doesn't list it under cBots.  cAlgo does list it, but doesn't allow to run it.  I get that my parameter declaration is not valid, and there is probably an exception being thrown in the bowls of cTrader/cAlgo - but some sort of feedback from the GUI would be nice for this and other errors like that.  I do compile my algo from Visual Studio, not cAlgo, if that matters.  The best option would be to list the algo, but show it red with tooltip giving more information...

 

It's not bug of cAlgo it's your mistake to assign string to a numerical value.

I hope you don't also blame cAlgo when your bot doesn't perform well. :)
 

I think you misunderstood me.  My code is wrong, no argument.  The bug in cAlgo is not that it won't allow me to run the robot, but that it won't give me the proper feedback that there is something wrong, and what exactly is wrong!  And it is important in this and similar case, because the code compiles.  It took me awhile to figure out what was wrong.

It compiles because DefaultValue is of object data type. You can put any data type you want. So it won't complain.
But on runtime it has to fire some exception, did you check the log tab, maybe there is some error info?
 

Yes, yes, I understand why it's happening!  And no, there is nothing in any log, because I can't get to that stage - in cTrader the algo isn't even listed.  And in cAlgo it's disabled, so I can't run it.  That's why I call it a bug in cTrader/cAlgo - a bug in the GUI.  I think cTrader should not hide those algos that produced an exception on initialization, but should list them in red colour with an error message.


@zelenij.krokodil

zelenij.krokodil
10 Jun 2016, 20:39

RE: RE:

moneybiz said:

zelenij.krokodil said:

I had this error in my algo code:

 

        [Parameter(DefaultValue = "SomeValue")]
        public double MySetting{ get; set; }


 

So the property type (double) doesn't really match the default value (string).  This thing compiles successfully, but then cTrader doesn't list it under cBots.  cAlgo does list it, but doesn't allow to run it.  I get that my parameter declaration is not valid, and there is probably an exception being thrown in the bowls of cTrader/cAlgo - but some sort of feedback from the GUI would be nice for this and other errors like that.  I do compile my algo from Visual Studio, not cAlgo, if that matters.  The best option would be to list the algo, but show it red with tooltip giving more information...

 

It's not bug of cAlgo it's your mistake to assign string to a numerical value.

I hope you don't also blame cAlgo when your bot doesn't perform well. :)
 

I think you misunderstood me.  My code is wrong, no argument.  The bug in cAlgo is not that it won't allow me to run the robot, but that it won't give me the proper feedback that there is something wrong, and what exactly is wrong!  And it is important in this and similar case, because the code compiles.  It took me awhile to figure out what was wrong.


@zelenij.krokodil

zelenij.krokodil
08 Jun 2016, 22:13

RE: Latest filled and closed position

kricka said:

Do not worry about misspelling or writing the wrong words. An edit function though would be most welcome and also spam removal by the moderator to make the forum more readable.

When it comes to listing, the latest filled and closed position may be of interest for you to check into. 

Information and download link: Bought and Sold cBot

I am afraid this won't do for me, because I might have multiple orders being filled/closed at the same time.  So I really need to know order/position's status at any given moment (I realize that a message could be in transit from the broker, but that's another story).


@zelenij.krokodil

zelenij.krokodil
07 Jun 2016, 20:42

Sorry, I meant to say your solution was O(n).  My, there is no edit option, not to mention lots of spam at the top of each forum section...


@zelenij.krokodil

zelenij.krokodil
07 Jun 2016, 20:41

Thanks for pointing out History.  However, you solution is O(1) and if an algo produces a lot of closed positions over time, this might be a performance issue.  History.Find might be a better option, assuming it is not implemented as linear search as well.  If it is, we are doomed and I might need to reevaluate cAlgo suitability for my purposes...


@zelenij.krokodil

zelenij.krokodil
07 Jun 2016, 20:25

I figured that much - matching comments/labels will get the info, but this is more of a hack than a proper way of doing it, in my opinion.


@zelenij.krokodil

zelenij.krokodil
07 Jun 2016, 19:56

And while we are at it, how do I know if a given position is closed or not?  At what price?


@zelenij.krokodil