Topics
30 Aug 2017, 11:07
 0
 3465
 3
28 Apr 2017, 14:00
 2348
 2
31 Mar 2017, 09:27
 2890
 3
30 Mar 2017, 11:50
 3666
 7
29 Mar 2017, 16:02
 2885
 7
29 Mar 2017, 10:48
 2262
 3
12 Mar 2017, 13:53
 2412
 2
01 Mar 2017, 22:40
 1947
 4
22 Feb 2017, 21:02
 2281
 1
22 Feb 2017, 19:48
 2696
 5
08 Feb 2017, 13:58
 6299
 14
03 Feb 2017, 10:03
 0
 2224
 1
Replies

mindbreaker
04 May 2015, 22:36

i dont test it :) I dont have skype.
@mindbreaker

mindbreaker
04 May 2015, 17:32

RE: RE: RE: RE: RE:

and when stop:

        protected override void OnStop()
        {
            // Put your deinitialization logic here
            Print("Bot was stoped!");
        }

 


@mindbreaker

mindbreaker
04 May 2015, 17:30

RE: RE: RE: RE:

Pips count and stop:

            // profit pips
            double pips = 0;
            foreach (var trade in Positions)
            {
                pips = pips + trade.Pips;
            }
            if (pips > 100)
            {
                Stop();
            }

 


@mindbreaker

mindbreaker
04 May 2015, 17:23

RE: RE: RE:
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

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


        int tradeStart = 0;
        int tradeCurrent = 0;

        protected override void OnStart()
        {
            // Put your initialization logic here
            foreach (var trade in History)
            {
                tradeStart++;
            }
        }

        protected override void OnTick()
        {
            // colose id

            foreach (var trade in History)
            {
                tradeCurrent++;
            }

            if (tradeCurrent - tradeStart >= 10)
            {
                Print("Close bot after 10 closed positions");
            }
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 


@mindbreaker

mindbreaker
04 May 2015, 17:22

RE: RE:

hiba7rain said:

?hiba7rain said:

Hi

Can any one help to show How to stop cBot after X number of trades or X number of profit pips?

 

thanks

 

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

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


        int tradeStart = 0;
        int tradeCurrent = 0;

        protected override void OnStart()
        {
            // Put your initialization logic here
            foreach (var trade in History)
            {
                tradeStart++;
            }
        }

        protected override void OnTick()
        {
            // colose id

            foreach (var trade in History)
            {
                foreach (var trade in History)
                {
                    tradeCurrent++;
                }

            }
            
            if(tradeCurrent - tradeStart >= 10){
            Print("Close bot after 10 closed positions")
            }
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

after 10 trade closed


@mindbreaker

mindbreaker
04 May 2015, 09:57

RE: RE:
        protected override void OnTick()
        {

            double earn = 0;

            foreach (var pos in Positions)
            {
                if (pos.TradeType == TradeType.Buy)
                {
                    // if You write pos and hit dot you have got tips for positions in calgo                    
                    //pos.NetProfit;
                    //pos.Pips;
                    //...
                    earn += pos.GrossProfit;
                }
            }
            if (earn > 100)
            {
                foreach (var pos in Positions)
                {
                    if (pos.TradeType == TradeType.Buy)
                    {
                        ClosePosition(pos);
                    }
                }
            }

        }

 


@mindbreaker

mindbreaker
03 May 2015, 19:56

double earn = 0; foreach (var pos in Positions){ if (pos.TradeType == TradeType. Buy){ earn+= pos.GrosProfit; } } if (earn> 100){ foreach (var posin Positions){ ClosePosition (pos); } }
@mindbreaker

mindbreaker
01 May 2015, 17:59

zzzz
foreach (var pos in Positions){ If (pos.Symbol="EURUSD"){ // //closepositionhere }
@mindbreaker

mindbreaker
28 Apr 2015, 15:06

RE:

millionaireboy said:

Hello Friends,

 Is it Possible that i can show my Indicator at my site ? Actually i have got created one best custom indicator i want that i share that indicator with others but just at my site.. I don't want to share indicator ?

If possible let me know i'm ready to pay for it. (if it's possible )

 

Hi,

You could display indicator value on your site like text .

or

create desktop screen shot in c# and display on web page

or

in mt4 create chart screenshot(from robot EA) every minute and set on web page.

It is possible.

Bye.


@mindbreaker

mindbreaker
21 Apr 2015, 18:37

Look at this :

/forum/calgo-reference-samples/825

Bye.


@mindbreaker

mindbreaker
21 Apr 2015, 14:20

RE:

tradermatrix said:

hello
for a robot I use this method to cut my positions (a total gains):

 

   [Parameter(DefaultValue = 30)]
    public double totalgains { get; set; }

  var netProfit = 0.0;


            foreach (var openedPosition in Positions)
            {

                netProfit += openedPosition.NetProfit + openedPosition.Commissions;

            }

          if (Math.Abs(netProfit) >= totalgains)


                if (netProfit >= totalgains && totalgains != 0)
                {

                    foreach (var openedPosition in Positions)
                    {
                        ClosePosition(openedPosition);
                    }

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

in this method it cut all the buy and sell positions.
I would like a method that separately cut a total buy and sell total.

  [Parameter(DefaultValue = 30)]
    public double totalBuy { get; set; }

  [Parameter(DefaultValue = 30)]
    public double totalSell { get; set; }

 

thank you for your help
cordially

 

Hi,

 

if(openedPosition.TradeType.Buy){

// todo with buy positions

}else{

// todo with sell positions

}

 

Bye.


@mindbreaker

mindbreaker
20 Apr 2015, 10:14

RE:

WhiteSage said:

Check the overloads, you can pass in a marketSeries.

Thank you.

found here:  /forum/whats-new/1463  and  /forum/calgo-reference-samples/2227


@mindbreaker

mindbreaker
15 Apr 2015, 18:24

RE: Working

This post was removed by moderator.


@mindbreaker

mindbreaker
15 Apr 2015, 18:22

Working

Works (SSL cAlgo Client send Symbol Bid Ask to the Server C#):

 

Server SSL C# MultiConnection

Server.cs

using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Security.Authentication;

namespace server
{
    public class server
    {

        private string positions = "";
        // Declare a two dimensional array 
        // users allowed 10
        private static int maxSlots = 11;
        private string[,] posArray = new string[maxSlots + 1, 1];
        X509Certificate serverCertificate = new X509Certificate2("ssl.p12", "KeyPass");

        ManualResetEvent tcpClientConnected = new ManualResetEvent(false);

        static void DisplayCertificateInformation(SslStream stream)
        {
            Console.WriteLine("Certificate revocation list checked: {0}", stream.CheckCertRevocationStatus);

            X509Certificate localCertificate = stream.LocalCertificate;
            if (stream.LocalCertificate != null)
            {
                Console.WriteLine("Local cert was issued to {0} and is valid from {1} until {2}.",
                    localCertificate.Subject,
                    localCertificate.GetEffectiveDateString(),
                    localCertificate.GetExpirationDateString());
            }
            else
            {
                Console.WriteLine("Local certificate is null.");
            }
            // Display the properties of the client's certificate.
            X509Certificate remoteCertificate = stream.RemoteCertificate;
            if (stream.RemoteCertificate != null)
            {
                Console.WriteLine("Remote cert was issued to {0} and is valid from {1} until {2}.",
                    remoteCertificate.Subject,
                    remoteCertificate.GetEffectiveDateString(),
                    remoteCertificate.GetExpirationDateString());
            }
            else
            {
                Console.WriteLine("Remote certificate is null.");
            }
        }

                static string ReadMessage(SslStream sslStream)
        {
            // Read the  message sent by the client. 
            // The client signals the end of the message using the 
            // "<EOF>" marker.
            byte [] buffer = new byte[2048];
            StringBuilder messageData = new StringBuilder();
            int bytes = -1;
            do
            {
                // Read the client's test message.
                bytes = sslStream.Read(buffer, 0, buffer.Length);

                // Use Decoder class to convert from bytes to UTF8 
                // in case a character spans two buffers.
                Decoder decoder = Encoding.UTF8.GetDecoder();
                char[] chars = new char[decoder.GetCharCount(buffer,0,bytes)];
                decoder.GetChars(buffer, 0, bytes, chars,0);
                messageData.Append (chars);
                // Check for EOF or an empty message. 
                if (messageData.ToString().IndexOf("<EOF>") != -1)
                {
                    break;
                }
            } while (bytes !=0); 

            return messageData.ToString();
        }


        void ProcessIncomingData(object obj)
        {
            SslStream sslStream = (SslStream)obj;
            try{
                // Set timeouts for the read and write to 5 seconds.
                sslStream.ReadTimeout = 5000;
                sslStream.WriteTimeout = 5000;
                // Read a message from the client.   
                Console.WriteLine("Waiting for client message...");
                string messageData = ReadMessage(sslStream);
                Console.WriteLine("Received: {0}", messageData);

                // Write a message to the client. 
                byte[] message = Encoding.UTF8.GetBytes("Hello from the server.<EOF>");
                Console.WriteLine("Sending hello message.");
                sslStream.Write(message);
                sslStream.Flush();

            }
            catch (Exception e) { }

        }

        void ProcessIncomingConnection(IAsyncResult ar)
        {
            TcpListener listener = (TcpListener)ar.AsyncState;
            TcpClient client = listener.EndAcceptTcpClient(ar);
            SslStream sslStream = new SslStream(client.GetStream(), false);
            try
            {

                sslStream.AuthenticateAsServer(serverCertificate, false, SslProtocols.Tls, true);
                //DisplayCertificateInformation(sslStream);
            }
            catch (Exception e)
            {
                Console.WriteLine("Client no ssl" + client);
                client.Close();
            }



            ThreadPool.QueueUserWorkItem(ProcessIncomingData, sslStream);
            tcpClientConnected.Set();
        }

        public void start()
        {
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8080);
            TcpListener listener = new TcpListener(endpoint);
            listener.Start();

            while (true)
            {
                tcpClientConnected.Reset();
                listener.BeginAcceptTcpClient(new AsyncCallback(ProcessIncomingConnection), listener);
                tcpClientConnected.WaitOne();
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("Multi user server. Recive save and send data to clients max 10 accounts.");
            //DateTime.Now.ToLongTimeString()
            Console.WriteLine(DateTime.Now + " Waiting for connections....");
            try
            {
                server s = new server();
                s.start();
            }
            catch (Exception e) { }
        }
    }
}

 

Client.algo

// System
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
// cAlgo
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using System.Collections;
using System.Collections.Generic;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class OnePositionClient : Robot
    {

        // "Server SSL Certyficate (CN=www.domain.com)"
        public string hostname = "www.example.com";

        // "Server host www.example.com"
        public string host = "www.example.com";

        // "Server port"
        public int port = 8080;

        List<string> PosOpenID = new List<string>();

        public static string txt = "";

        private static Hashtable certificateErrors = new Hashtable();

        protected override void OnBar()
        {
            ConnectSSL("Hello Server " + Symbol);
        }


//================================================================================================================
//                                                                                  SSL Socket client Data send
//================================================================================================================

        // The following method is invoked by the RemoteCertificateValidationDelegate.
        public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None)
                return true;

            Console.WriteLine("Certificate error: {0}", sslPolicyErrors);

            // Do not allow this client to communicate with unauthenticated servers when false.
            //return false;
            //Force ssl certyfikates as correct
            return true;
        }

        static string ReadMessage(SslStream sslStream)
        {
            // Read the  message sent by the server. 
            // The end of the message is signaled using the 
            // "<EOF>" marker.
            byte[] buffer = new byte[2048];
            StringBuilder messageData = new StringBuilder();
            int bytes = -1;
            do
            {
                bytes = sslStream.Read(buffer, 0, buffer.Length);

                // Use Decoder class to convert from bytes to UTF8 
                // in case a character spans two buffers.
                Decoder decoder = Encoding.UTF8.GetDecoder();
                char[] chars = new char[decoder.GetCharCount(buffer, 0, bytes)];
                decoder.GetChars(buffer, 0, bytes, chars, 0);
                messageData.Append(chars);
                // Check for EOF. 
                if (messageData.ToString().IndexOf("<EOF>") != -1)
                {
                    break;
                }
            } while (bytes != 0);

            return messageData.ToString();
        }


        public void ConnectSSL(string msg = "")
        {

            txt = "";
            try
            {
                TcpClient client = new TcpClient(host, port);

                // Create an SSL stream that will close the client's stream.
                SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
                try
                {
                    sslStream.AuthenticateAsClient(hostname);
                } catch (AuthenticationException e)
                {
                    Console.WriteLine("Exception: {0}", e.Message);
                    if (e.InnerException != null)
                    {
                        Print("Inner exception: {0}", e.InnerException.Message);
                    }
                    Print("Authentication failed - closing the connection.");
                    client.Close();
                    return;
                }


                // Signal the end of the message using the "<EOF>".
                // Semd message
                byte[] messsage = Encoding.UTF8.GetBytes(msg + " <EOF>");
                // Send hello message to the server. 
                sslStream.Write(messsage);
                sslStream.Flush();
                // Read message from the server. 
                string serverMessage = ReadMessage(sslStream);
                Print("Server says: {0}", serverMessage);
                // Close the client connection.
                client.Close();
                Print("Client closed.");


            } catch (ArgumentNullException e)
            {
                Print("ArgumentNullException: {0}", e);
            } catch (SocketException e)
            {
                Print("SocketException: {0}", e);
            }

        }


    }
}

 


@mindbreaker

mindbreaker
15 Apr 2015, 17:11

sslstream end

Hi all,

Multi ssl server and client from calgo

It does not work correctly client dont Print server message why?

Client:

// System
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
// cAlgo
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using System.Collections;
using System.Collections.Generic;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;


namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class OnePositionClient : Robot
    {

        [Parameter("Username", DefaultValue = "")]
        public string Username { get; set; }

        [Parameter("Password", DefaultValue = "")]
        public string Password { get; set; }

        [Parameter("MoneyForSignalUSD", DefaultValue = 100, MinValue = 100)]
        public int MoneyForSignalUSD { get; set; }

        List<string> PosOpenID = new List<string>();
        List<string> PosCloseID = new List<string>();
        List<string> PosServerID = new List<string>();
        List<string> PosServerAll = new List<string>();

        public static string txt = "";

        private static Hashtable certificateErrors = new Hashtable();

        protected override void OnTick()
        {
            ConnectSSL("HelloServer" + Symbol);
        }


//================================================================================================================
//                                                                                   End Send POST to HTTPS Server
//================================================================================================================

        // The following method is invoked by the RemoteCertificateValidationDelegate.
        public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None)
                return true;

            Console.WriteLine("Certificate error: {0}", sslPolicyErrors);

            // Do not allow this client to communicate with unauthenticated servers.
            //return false;
            //Force ssl certyfikates as correct
            return true;
        }


        public void ConnectSSL(string msg = "")
        {

            txt = "";
            try
            {
                TcpClient client = new TcpClient("localhost", 8080);

                // Create an SSL stream that will close the client's stream.
                SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
                try
                {
                    sslStream.AuthenticateAsClient("ssl.breakermind.com");
                } catch (AuthenticationException e)
                {
                    Console.WriteLine("Exception: {0}", e.Message);
                    if (e.InnerException != null)
                    {
                        Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
                    }
                    Console.WriteLine("Authentication failed - closing the connection.");
                    client.Close();
                    return;
                }
                int j = 10;
                byte[] messsage = Encoding.UTF8.GetBytes(msg + (char)j);
                // Send hello message to the server.
                Print("Send msg " + msg);
                sslStream.Write(messsage);
                sslStream.Flush();

                // Read message from the server.
                int i = -1;
                while ((i = sslStream.ReadByte()) != 10)
                {
                    txt = txt + (char)i;
                    if (i == -1)
                    {
                        Console.WriteLine("Server says: {0}", txt);
                        break;
                    }
                }
                Console.WriteLine("Server says: {0}", txt);
                // Close the client connection.

                client.Close();
                Console.WriteLine("Client closed.");

            } catch (ArgumentNullException e)
            {
                Print("ArgumentNullException: {0}", e);
            } catch (SocketException e)
            {
                Print("SocketException: {0}", e);
            }

        }


        public void Connect(string PosAll = "")
        {
            ///===========================================================

            string pos = "SET#" + "1#";
            //pos = pos + "SPREAD:" + Symbol.Spread + "|";
            pos = pos + PosAll;
            // end of stream
            pos = pos + '\0';

            // Process the data sent by the client.
            Print("String " + pos);
            ////===========================================================



            try
            {
                TcpClient client = new TcpClient("localhost", 8080);
                Byte[] data = System.Text.Encoding.ASCII.GetBytes(pos);
                NetworkStream stream = client.GetStream();
                stream.Write(data, 0, data.Length);
                Print("Sent: " + pos);
                data = new Byte[1024];
                Int32 bytes = stream.Read(data, 0, data.Length);
                string responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
                Print("Received: {0}", responseData);
                // Close everything.
                stream.Close();
                client.Close();

            } catch (ArgumentNullException e)
            {
                Print("ArgumentNullException: {0}", e);
            } catch (SocketException e)
            {
                Print("SocketException: {0}", e);
            }

        }


    }
}


//====================================================================================================================
//                                                                                                Initialize Positions
//====================================================================================================================

Server multi ssl

using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Security.Authentication;

namespace server
{
    public class server
    {

        private string positions = "";
        // Declare a two dimensional array 
        // users allowed 10
        private static int maxSlots = 11;
        private string[,] posArray = new string[maxSlots + 1, 1];
        X509Certificate serverCertificate = new X509Certificate2("ssl.p12", "KeyPass");

        ManualResetEvent tcpClientConnected = new ManualResetEvent(false);

        static void DisplayCertificateInformation(SslStream stream)
        {
            Console.WriteLine("Certificate revocation list checked: {0}", stream.CheckCertRevocationStatus);

            X509Certificate localCertificate = stream.LocalCertificate;
            if (stream.LocalCertificate != null)
            {
                Console.WriteLine("Local cert was issued to {0} and is valid from {1} until {2}.",
                    localCertificate.Subject,
                    localCertificate.GetEffectiveDateString(),
                    localCertificate.GetExpirationDateString());
            }
            else
            {
                Console.WriteLine("Local certificate is null.");
            }
            // Display the properties of the client's certificate.
            X509Certificate remoteCertificate = stream.RemoteCertificate;
            if (stream.RemoteCertificate != null)
            {
                Console.WriteLine("Remote cert was issued to {0} and is valid from {1} until {2}.",
                    remoteCertificate.Subject,
                    remoteCertificate.GetEffectiveDateString(),
                    remoteCertificate.GetExpirationDateString());
            }
            else
            {
                Console.WriteLine("Remote certificate is null.");
            }
        }

        static string ReadMessage(SslStream sslStream)
        {
            // Read the  message sent by the client.
            // The client signals the end of the message using the
            // "" marker.
            StringBuilder messageData = new StringBuilder();
            int bytes = -1;
            do
            {
                // Read the client's test message.
                bytes = sslStream.ReadByte();

                // Use Decoder class to convert from bytes to UTF8
                // in case a character spans two buffers.
                Decoder decoder = Encoding.UTF8.GetDecoder();
                char znak = (char)bytes;
                messageData.Append(znak);
                // Check for EOF or an empty message.
                if (messageData.ToString().IndexOf("") != -1)
                {
                    break;
                }
            } while (bytes != 0);

            return messageData.ToString();
        }

        void ProcessIncomingData(object obj)
        {
            SslStream sslStream = (SslStream)obj;
            //string ip = ((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString();

            //Console.WriteLine("Client IP : " + ip);


            string sb = "";
            int i = -1;
            try
            {
                while (true)
                {
                    int j = 10;
                    //Console.WriteLine((char)j);
                    while ((i = sslStream.ReadByte()) != 10)
                    {
                        sb = sb + (char)i;
                       // Console.WriteLine("Stream in char " +  i);
                        if (i == -1) break;
                    }
                    Console.WriteLine("Client " + sb);
                    byte[] messsage = Encoding.UTF8.GetBytes("Helloclient" + (char)j);
                    // Send hello message to the server.
                    sslStream.Write(messsage);
                    sslStream.Flush();

                }

            }
            catch (Exception e) { }

        }

        void ProcessIncomingConnection(IAsyncResult ar)
        {
            TcpListener listener = (TcpListener)ar.AsyncState;
            TcpClient client = listener.EndAcceptTcpClient(ar);
            SslStream sslStream = new SslStream(client.GetStream(), false);
            try
            {
                
                sslStream.AuthenticateAsServer(serverCertificate, false, SslProtocols.Tls, true);
                //DisplayCertificateInformation(sslStream);
            }catch(Exception e){
                Console.WriteLine("Client no ssl" + client);
            client.Close();
            }

            
            
            ThreadPool.QueueUserWorkItem(ProcessIncomingData, sslStream);
            tcpClientConnected.Set();
        }

        public void start()
        {
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8080);
            TcpListener listener = new TcpListener(endpoint);
            listener.Start();

            while (true)
            {
                tcpClientConnected.Reset();
                listener.BeginAcceptTcpClient(new AsyncCallback(ProcessIncomingConnection), listener);
                tcpClientConnected.WaitOne();
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("Multi user server. Recive save and send data to clients max 10 accounts.");
            //DateTime.Now.ToLongTimeString()
            Console.WriteLine(DateTime.Now + " Waiting for connections....");
            try
            {
                server s = new server();
                s.start();
            }
            catch (Exception e) { }
        }
    }
}

Thanks.


@mindbreaker

mindbreaker
13 Apr 2015, 14:33

RE:

Paul_Hayes said:

Hi,

If you are using the .NET framework version 4.5 look into the Task Parallel Library

The Task Parallel Library (TPL) is based on the concept of a task, which represents an asynchronous operation. In some ways, a task resembles a thread or ThreadPool work item, but at a higher level of abstraction. The term task parallelism refers to one or more independent tasks running concurrently

https://msdn.microsoft.com/en-us/library/dd537609%28v=vs.110%29.aspx

Just refactor your code to implement this architecture.

 

Thank you very much.


@mindbreaker

mindbreaker
23 Mar 2015, 22:44

RE: RE:

/algos/indicators/show/750


@mindbreaker

mindbreaker
22 Mar 2015, 10:25

RE:

mindbreaker said:

Hi,

How to get Week Open Price (or Open,Close,High,Low of week bar Timeframe W1)?

Thanks

or how change this indicator to show week lines not day lines?

// -----------------------------------------------------------------------------------------------
//
//    This is an example of how to plot the Daily Open and Close on a TimeFrame lower than Daily 
//
// -----------------------------------------------------------------------------------------------

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class DailyOpenClose : Indicator
    {
        [Output("Open", Color = Colors.Wheat, PlotType = PlotType.Points)]
        public IndicatorDataSeries Open { get; set; }

        [Output("Close", Color = Colors.Blue, PlotType = PlotType.Points)]
        public IndicatorDataSeries Close { get; set; }

        public override void Calculate(int index)
        {
            if (index < 1)
            {
                // If first bar is first bar of the day set open
                if (MarketSeries.OpenTime[index].TimeOfDay == TimeSpan.Zero)
                    Open[index] = MarketSeries.Open[index];
                return;
            }

            DateTime openTime = MarketSeries.OpenTime[index];
            DateTime lastOpenTime = MarketSeries.OpenTime[index - 1];
            const string objectName = "messageNA";

            if (!ApplicableTimeFrame(openTime, lastOpenTime))
            {
                // Display message that timeframe is N/A
                const string text = "TimeFrame Not Applicable. Choose a lower Timeframe";
                ChartObjects.DrawText(objectName, text, StaticPosition.TopLeft, Colors.Red);
                return;
            }

            // If TimeFrame chosen is applicable remove N/A message
            ChartObjects.RemoveObject(objectName);

            // Plot Daily Open and Close
            PlotDailyOpenClose(openTime, lastOpenTime, index);
        }

        private bool ApplicableTimeFrame(DateTime openTime, DateTime lastOpenTime)
        {
            // minutes difference between bars
            var timeFrameMinutes = (int)(openTime - lastOpenTime).TotalMinutes;

            bool daily = timeFrameMinutes == 1440;
            bool weeklyOrGreater = timeFrameMinutes >= 7200;

            bool timeFrameNotApplicable = daily || weeklyOrGreater;

            if (timeFrameNotApplicable)
                return false;

            return true;
        }

        private void PlotDailyOpenClose(DateTime openTime, DateTime lastOpenTime, int index)
        {
            double close;
            int i;

            // Day change
            if (openTime.Day != lastOpenTime.Day)
            {
                // Plot Open
                Open[index] = MarketSeries.Open[index];

                // Plot previous day close                
                close = MarketSeries.Close[index - 1];
                i = index - 1;
                while (MarketSeries.OpenTime[i].Day == lastOpenTime.Day)
                {
                    Close[i] = close;
                    i--;
                }
            }
            // Same Day
            else
            {
                // Plot Open 
                Open[index] = Open[index - 1];
            }

            // Plot todays close 
            DateTime today = DateTime.Now.Date;
            if (openTime.Date != today)
                return;

            close = MarketSeries.Close[index];
            i = index;
            while (MarketSeries.OpenTime[i].Date == today)
            {
                Close[i] = close;
                i--;
            }
        }
    }
}

Thanks


@mindbreaker

mindbreaker
19 Mar 2015, 17:03

Do not waste your time. It dont work.


@mindbreaker

mindbreaker
19 Mar 2015, 13:20

All files Copier from trader contest to calgo and mt4

Hi,

https://github.com/breakermind/JForexSDKCopier

Bye


@mindbreaker