Replies

ninosgr
08 Mar 2015, 13:55

RE: Is there still a need to Importing external signal files?

joeatbayes said:

see:  /algos/cbots/show/588  and /algos/cbots/show/591  I have also written the portion which does the import and executes trades based on external signals.   If others will find it of value then let me know and I can post it as a new CBot.  It takes quite a bit of extra effort to package things for external consumption but if there is sufficient demand I will do so.  Thanks Joe E. 

could you please share your code? thanks


@ninosgr

ninosgr
04 Mar 2014, 11:15

RE:

Hi hermoso,

would you be interested in creating a simple robot for me which would send current market data over TCP and receive the basic commands of cAlgo such open close position take profit etc?

I am not a programmer and although your description seems very clear but not for a non programmer.

my email address is ninosgr@gmail.com

Thanks

You can use ZEROMQ is the easy and reliable way to do 

 

here is an example: 

 

Server Side:

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using ZMQ;

         List fields = new List 
        {
            "Open",
            "High",
            "Low",
            "Close"
        };   

 

     protected override void OnStart()
        {
            int total = 0;
            using (var context = new Context(1))
            {
                using (Socket worker = context.Socket(SocketType.DEALER))
                {
                    worker.StringToIdentity(Symbol.Code, Encoding.Unicode);
                    worker.Connect("tcp://127.0.0.1:5999");



                    while (true)
                    {
                        string request = worker.Recv(Encoding.Unicode);
                        if (request.Equals("FIM"))
                            total++;
                        // Print(total);



                        for (int idx = 0; idx < fields.Count(); idx++)
                        {
                            if (request.Equals(fields[idx]))
                            {
                                var valor_ = valor(request, Convert.ToInt32(worker.Recv(Encoding.Unicode)));

                                worker.Send(valor_, Encoding.Unicode);
                                break;
                            }
                        }


                    }                    

                }

            }


        }

 

         private String valor(string request, int periodo)
        {

            if (String.Equals(request, "Open"))
                return Convert.ToString(MarketSeries.Open.Last(periodo));
            if (String.Equals(request, "High"))
                return Convert.ToString(MarketSeries.High.Last(periodo));
            if (String.Equals(request, "Low"))
                return Convert.ToString(MarketSeries.Low.Last(periodo));
            if (String.Equals(request, "Close"))
                return Convert.ToString(MarketSeries.Close.Last(periodo));
            Print("cagada");
            return Convert.ToString(0);
        }

 

 

//////////////////////////////////////

 

 

Client Side

 

 

 

         protected override void OnStart()
        {

            using (var context = new Context(1))
            {
                using (Socket requester = context.Socket(SocketType.ROUTER))
                {
                    requester.Bind("tcp://*:5999");
                    System.Threading.Thread.Sleep(1000);
                    double high = consulta(context,requester,"USDJPY","High",100)
                }
            }

}

 

 

         private double consulta(ZMQ.Socket requester, string Ativo, String Series, int periodo)
        {

            requester.SendMore(Ativo, Encoding.Unicode);
            requester.SendMore(Series, Encoding.Unicode);
            requester.Send(Convert.ToString(periodo), Encoding.Unicode);
            requester.Recv();
            string buffer = requester.Recv(Encoding.Unicode);
            return Convert.ToDouble(buffer);

        }

}

 

 

you can get zeromq via nuget.. create a new project in visual studio download via nuget and then reference it in your calgo project outside de visual studio,, you do this just to get the files

 

as clrzmq is a wrapper of the libzmq the libzmq must be in the calgo path... control alt del... the click with the right button on calgo process... then go to file or folder(sorry my windows is in pt-br) something like that.. then copy the libzmq to this folder

 

 

This is an example of as many robots as you want exchanging quotes... pay attetion in this topology the router must wait for the dealers to connect... i really sugest you to go to http://zguide2.zeromq.org/

 

 

here are my references

 


//#reference: ..\..\x64\Release\clrzmq.dll
//#reference: ..\..\x64\Release\clrzmq-ext.dll

 

i hope this helps you

 


@ninosgr

ninosgr
04 Mar 2014, 10:20

RE:

Hello,

Is there somewhere an example of how to log in and connect to (cAlgo) server using an external application written in (C #)?

I need to write a widget that displays the status of the currency and allow open and close position

is it possible?

Thanks

Please could you share your findings?

 

thanks my email is ninosgr@gmail.com

 

thanks


@ninosgr

ninosgr
04 Mar 2014, 10:17

RE: RE: RE:

Hi scalptastic,

I am interested in making a robot which will communicate with tcp/osc with external apps. Is it possible to get in touch with to point me to the right direction?

my email address is ninosgr@gmail.com thanks

admin said:
scalptastic said:

hi guys; just had a chance to demo the cTrader platform. it is great; and user friendly.


is there an API to connect to cAlgo or cTrader from external apps; such as Java or C++?

i have a legacy algo app that I need to keep running for the moment; while exploring the new platform.

 

thanks.

 

This is beyond our scope at the moment but you may implement such functionality with cAlgo using the System.NET namespace.

 

 

Great. is it possible to interface cAlgo with custom .NET DLLs? i.e. I am interested to write a TCP/IP comms so I can send orders through.

 

also; can I access existing .NET libraries installed in the PC?

 

 

 


@ninosgr

ninosgr
07 Feb 2014, 13:24

RE: RE: RE:

Hi could you share what you found? is there any way to implement OSC protocol or TCP?

 

Thanks

Hi again,
is no longer valid.
I found a solution elsewhere.
Thanks and bye.

 


@ninosgr