Topics
01 Dec 2015, 13:28
 3860
 5
10 Oct 2014, 21:23
 3118
 10
17 Jun 2014, 16:50
 2626
 5
30 May 2014, 16:44
 4972
 10
07 May 2014, 12:08
 4009
 11
Replies

breakermind
27 Mar 2014, 12:43

cbot
// ----------------------------------------------------------------------------------
//  Simple Robot with sent positions to www server via https connection method post
// ----------------------------------------------------------------------------------

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using System.IO;
using System.Net;
using System.Text;
using System.Runtime;

//using System.Net.Security.Cryptography.X509Certyficates;

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

        private int zzz;
        private string responseFromServer = "";
        private string openPositionsString = "";

        [Parameter("Hostname", DefaultValue = "breakermind.com")]
        public string sslServerHost { get; set; }

        [Parameter("Port", DefaultValue = 443)]
        public int sslServerPort { get; set; }

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

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

        [Parameter("Position label", DefaultValue = "Master Position Label")]
        public string MyLabel { get; set; }

        [Parameter("Position comment", DefaultValue = "Master Position Comment")]
        public string MyComment { get; set; }

        [Parameter("Volume", DefaultValue = 10000)]
        public int Volume { get; set; }

        [Parameter("Volume Max", DefaultValue = 100000)]
        public int VolumeMax { get; set; }

        [Parameter("Stop Loss (pips)", DefaultValue = 30)]
        public int StopLoss { get; set; }

        [Parameter("Take Profit (pips)", DefaultValue = 15)]
        public int TakeProfit { get; set; }

        [Parameter(DefaultValue = 5)]
        public int MaxPositions { get; set; }

//================================================================================
//                                                                         OnStart
//================================================================================
        protected override void OnStart()
        {
            Print("Master Robot start ... Trade Master");
        }

        protected override void OnBar()
        {
            if (Positions.Count < MaxPositions)
            {

                if (Volume > VolumeMax)
                {
                    Volume = VolumeMax;
                }
                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, MyLabel, StopLoss, TakeProfit);
                ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, MyLabel, StopLoss, TakeProfit);
            }
        }
//================================================================================
//                                                                Positions OnTick
//================================================================================
        // replace character
        public static String CharReplace(String source, String ch1, string ch2)
        {
            String result = source.Replace(ch1, ch2);
            return result;
        }

        /// datatime to timestamp
        public static double DateTimeToUnixTimestamp(DateTime dateTime)
        {
            return (dateTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds;
        }

        protected override void OnError(Error error)
        {
            Print("Error code: " + error.Code);
        }

        protected override void OnTick()
        {
            // get all opened positions with label and put to openPositionsString
            var AllPositions = Positions.FindAll(MyLabel);
            openPositionsString = "";
            foreach (var position in AllPositions)
            {
                // BUY positions
                if (position.TradeType == TradeType.Buy)
                {
                    // OPENED POSITION STRING
                    openPositionsString += DateTimeToUnixTimestamp(position.EntryTime) + "_" + CharReplace("" + position.Id, "_", "*") + "_" + position.SymbolCode + "_TRUE" + "_" + position.Volume + "_" + CharReplace("" + position.EntryPrice, ",", ".") + "_" + CharReplace("" + position.StopLoss, ",", ".") + "_" + CharReplace("" + position.TakeProfit, ",", ".") + "_" + CharReplace("" + position.Label, "_", "*") + "_" + CharReplace("" + position.Comment, "_", "*") + "_##";
                }
                // SELL positions
                if (position.TradeType == TradeType.Sell)
                {
                    // OPENED POSITION STRING
                    openPositionsString += DateTimeToUnixTimestamp(position.EntryTime) + "_" + CharReplace("" + position.Id, "_", "*") + "_" + position.SymbolCode + "_FALSE" + "_" + position.Volume + "_" + CharReplace("" + position.EntryPrice, ",", ".") + "_" + CharReplace("" + position.StopLoss, ",", ".") + "_" + CharReplace("" + position.TakeProfit, ",", ".") + "_" + CharReplace("" + position.Label, "_", "*") + "_" + CharReplace("" + position.Comment, "_", "*") + "_##";
                }

            }

//================================================================================
//                                                       Send POST to HTTPS Server
//================================================================================
            if (responseFromServer == openPositionsString)
            {
                Print("Same strings ... wait for new Positions !");
            }

            if (responseFromServer != openPositionsString)
            {
                Print("====================================================================================");
                Print("request server =>> " + openPositionsString);
                try
                {
                    // For test php file return back POST ?line=  (password and username disabled)
                    WebRequest request = WebRequest.Create("https://" + sslServerHost + ":" + sslServerPort + "/s.php");
                    // post data
                    byte[] postBytes = Encoding.ASCII.GetBytes("line=" + openPositionsString);
                    // settings
                    request.Proxy = null;
                    request.Method = "POST";
                    //request.Credentials = CredentialCache.DefaultCredentials;
                    request.ContentType = "application/x-www-form-urlencoded";

                    request.ContentLength = postBytes.Length;
                    Stream requestStream = request.GetRequestStream();
                    requestStream.Write(postBytes, 0, postBytes.Length);

                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    Stream dataStream = response.GetResponseStream();

                    StreamReader reader = new StreamReader(dataStream);
                    responseFromServer = reader.ReadToEnd();
                } catch (Exception e)
                {
                    Print("Error: " + e);
                }
                Print("response server <<= " + responseFromServer);
            }

        }


//================================================================================
//                                                                          OnStop
//================================================================================
        protected override void OnStop()
        {
            Print("Master Robot stop");
        }
    }
}

 


@breakermind

breakermind
27 Mar 2014, 12:06

RE: RE: RE: RE:

breakermind said:

Hi,

how to convert this price (position.EntryPrice)

1,777  ==> 1.777

ane how convert date (position.EntryTime)

2014-03-25 11:11:11     ===>   seconds (133658232763)

Thanks

 

DataTime to unix timestamp

        public static double DateTimeToUnixTimestamp(DateTime dateTime)
        {
            return (dateTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds;
        }

 


@breakermind

breakermind
27 Mar 2014, 12:00

How to change character in string

Hi,

How to change character in string ?

string

21312312_32323232

to this

21312312#32323232


@breakermind

breakermind
26 Mar 2014, 17:21

RE:

Ok, Thanks


@breakermind

breakermind
26 Mar 2014, 16:12

Robot with send position to www server

when new position opened robot send post request tto www server (Master for position copy):

// ----------------------------------------------------------------------------------
//  Simple Robot with sent positions to www server via https connection method post
// ----------------------------------------------------------------------------------

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using System.IO;
using System.Net;
using System.Text;
//using System.Net.Security.Cryptography.X509Certyficates;

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

        private int zzz;
        private string responseFromServer = "";
        private string openPositionsString = "";

        [Parameter("Hostname", DefaultValue = "breakermind.com")]
        public string sslServerHost { get; set; }

        [Parameter("Port", DefaultValue = 443)]
        public int sslServerPort { get; set; }

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

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

        [Parameter("Position label", DefaultValue = "Master Position Label")]
        public string MyLabel { get; set; }

        [Parameter("Position comment", DefaultValue = "Master Position Comment")]
        public string MyComment { get; set; }

        [Parameter("Volume", DefaultValue = 10000)]
        public int Volume { get; set; }

        [Parameter("Volume Max", DefaultValue = 100000)]
        public int VolumeMax { get; set; }

        [Parameter("Stop Loss (pips)", DefaultValue = 30)]
        public int StopLoss { get; set; }

        [Parameter("Take Profit (pips)", DefaultValue = 15)]
        public int TakeProfit { get; set; }

        [Parameter(DefaultValue = 5)]
        public int MaxPositions { get; set; }

//================================================================================
//                                                                         OnStart
//================================================================================
        protected override void OnStart()
        {
            Print("Master Robot start ... Trade Master");
            //  openPositionsString = "";
            //  responseFromServer = "";
        }

        protected override void OnBar()
        {
            if (Positions.Count < MaxPositions)
            {

                if (Volume > VolumeMax)
                {
                    Volume = VolumeMax;
                }
                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, MyLabel, StopLoss, TakeProfit);
                ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, MyLabel, StopLoss, TakeProfit);
            }
        }
//================================================================================
//                                                                Positions OnTick
//================================================================================


        protected override void OnTick()
        {
            // get all opened positions with label and put to openPositionsString
            var AllPositions = Positions.FindAll(MyLabel);
            openPositionsString = "";
            foreach (var position in AllPositions)
            {
                // BUY positions
                if (position.TradeType == TradeType.Buy)
                {
                    // OPENED POSITION STRING
                    openPositionsString += position.EntryTime + "_" + position.Id + "_" + position.SymbolCode + "_TRUE" + "_" + position.Volume + "_" + position.EntryPrice + "_" + position.StopLoss + "_" + position.TakeProfit + "_" + position.Label + "_" + position.Comment + "_##";
                }
                // SELL positions
                if (position.TradeType == TradeType.Sell)
                {
                    // OPENED POSITION STRING
                    openPositionsString += position.EntryTime + "_" + position.Id + "_" + position.SymbolCode + "_FALSE" + "_" + position.Volume + "_" + position.EntryPrice + "_" + position.StopLoss + "_" + position.TakeProfit + "_" + position.Label + "_" + position.Comment + "_##";
                }

            }





//================================================================================
//                                                       Send POST to HTTPS Server
//================================================================================
            if (responseFromServer == openPositionsString)
            {
                Print("Same strings ... wait for new Positions !");
            }

            if (responseFromServer != openPositionsString)
            {
                Print("====================================================================================");
                Print("request server =>> " + openPositionsString);

                // For test php file return back POST ?line=  (password and username disabled)
                WebRequest request = WebRequest.Create("https://" + sslServerHost + ":" + sslServerPort + "/s.php");
                // post data
                byte[] postBytes = Encoding.ASCII.GetBytes("line=" + openPositionsString);
                // settings
                request.Proxy = null;
                request.Method = "POST";
                request.Credentials = CredentialCache.DefaultCredentials;
                request.ContentType = "application/x-www-form-urlencoded";

                request.ContentLength = postBytes.Length;
                Stream requestStream = request.GetRequestStream();
                requestStream.Write(postBytes, 0, postBytes.Length);

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream dataStream = response.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);
                responseFromServer = reader.ReadToEnd();
                Print("response server <<= " + responseFromServer);
            }

        }


//================================================================================
//                                                                          OnStop
//================================================================================
        protected override void OnStop()
        {
            Print("Master Robot stop");
        }
    }
}

 


@breakermind

breakermind
26 Mar 2014, 13:35

RE: RE: RE: RE: RE:

Hi all,

Send  positions to www server method $_POST

 

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using System.IO;
using System.Net;
using System.Text;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC)]
    public class NewRobot : Robot
    {

        private int zzz;

        private string openPositionsString = "";
        protected override void OnStart()
        {
            //Positions.Opened += PositionsOnOpened;
        }
        /*
        private void PositionsOnOpened(PositionOpenedEventArgs args)
        {
            var position = args.Position;

            Print(position.Label != "---" ? "Position opened by LabelsSample cBot at {0}" : "Position opened manually at {0}", position.EntryPrice);
        }
        */
//================================================================================
//                                                             OnPositionOpened
//================================================================================


        protected override void OnTick()
        {

            var AllPositions = Positions.FindAll("");
            openPositionsString = "";
            int BuyPos = 0;
            int SellPos = 0;
            foreach (var position in AllPositions)
            {


                // Count opened positions
                if (position.TradeType == TradeType.Buy)
                {
                    BuyPos = BuyPos + 1;
                    Print("POS VOLUME: " + position.Volume);
                    //position.EntryPrice = position.EntryPrice;

                    int time = position.EntryTime.Year * 10000 + position.EntryTime.Month * 100 + position.EntryTime.Minute;
                    // OPENED POSITION STRING
                    openPositionsString += "START" + position.EntryTime + "," + position.Id + "," + position.SymbolCode + ",TRUE" + "," + position.Volume + "," + position.EntryPrice + "," + position.StopLoss + "," + position.TakeProfit + "," + position.Label + "," + position.Comment + ",ZZZEND";
                    Print("HOW TO SHOW IN LOGS ======================================================");
                    Print("String : {0}", openPositionsString);


                }
                if (position.TradeType == TradeType.Sell)
                {

                    // OPENED POSITION STRING
                    openPositionsString += "START" + position.EntryTime + "," + position.Id + "," + position.SymbolCode + ",FALSE" + "," + position.Volume + "," + position.EntryPrice + "," + position.StopLoss + "," + position.TakeProfit + "," + position.Label + "," + position.Comment + ",ZZZEND";
                    Print("HOW TO SHOW IN LOGS ======================================================");
                    Print("String : " + openPositionsString);
                    SellPos = SellPos + 1;
                }

            }

            Print("All Buy positions: " + BuyPos);
            Print("All Sell positions: " + SellPos);


            string sslServerHost = "breakermind.com";
            int sslServerPort = 443;
            WebRequest request = WebRequest.Create("https://" + sslServerHost + ":" + sslServerPort + "/s.php");
            request.Proxy = null;
            request.Method = "POST";
            request.Credentials = CredentialCache.DefaultCredentials;
            request.ContentType = "application/x-www-form-urlencoded";
            byte[] postBytes = Encoding.ASCII.GetBytes("line=" + openPositionsString + "---" + zzz++);
            request.ContentLength = postBytes.Length;
            Stream requestStream = request.GetRequestStream();
            requestStream.Write(postBytes, 0, postBytes.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream dataStream = response.GetResponseStream();

            StreamReader reader = new StreamReader(dataStream);
            string responseFromServer = reader.ReadToEnd();
            Print("All Buy positions:" + responseFromServer);
            //Console.WriteLine(responseFromServer);
            //Print("All Buy positions: " + BuyPos);
        }



        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
    /*
        public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            return true;
        }
        */

}

:]


@breakermind

breakermind
25 Mar 2014, 17:36

RE: RE: RE: RE:

breakermind said:

Hi,

how to convert this price (position.EntryPrice)

1,777  ==> 1.777

ane how convert date (position.EntryTime)

2014-03-25 11:11:11     ===>   seconds (133658232763)

Thanks

 

Does calgo has the ability to specify the time in milliseconds for position.EntryTime ?

if Yes how to do that ?


@breakermind

breakermind
25 Mar 2014, 13:28

RE: RE: RE:

Hi,

how to convert this price (position.EntryPrice)

1,777  ==> 1.777

ane how convert date (position.EntryTime)

2014-03-25 11:11:11     ===>   seconds (133658232763)

Thanks


@breakermind

breakermind
24 Mar 2014, 15:11

RE:

server side php file send.php save/update and delete opened positions into mysql database and then return recived positions line back 

send.php

<?php
include('functions.php');
// line example
// START1395336294584,59923886,GBP/JPY,true,1.0,169.199,167.195,171.195,jf1nikmw1,null,ZZZ1395336294584,59923886,GBP/JPY,true,1.0,169.199,167.195,171.195,jf1nikmw1,null,ZZZEND

//======================================================================================= connect mysql
$mysqlcon = isConnect('localhost','root', 'toor');


//======================================================================================= get input strings
$user_ip = $_SERVER['REMOTE_ADDR'];
$user_time = time();
$user = md5($_GET['user']);
$pass = md5($_GET['pass']);
$line = htmlspecialchars($_GET['line'], ENT_QUOTES, 'UTF-8');
echo "<pre>";
echo $line;
echo "</pre>";
$userID = 0;
$out = "";
$positions[] = 0;


//======================================================================================= if user and password correct
$q = mysql_query("SELECT * FROM users WHERE user_email_hash='$user' AND user_pass='$pass'");
$userExist = mysql_num_rows($q);

// user istnieje pobierz rekord z bazy (id usera)
if($userExist != 0){
	while ($row = mysql_fetch_assoc($q)){
		//echo "user id: " . $userID = $row['user_id'];
		$userID = $row['user_id'];
	}
}

if($line == "STARTEND"){
	$q5 = mysql_query("UPDATE positionsTest1 SET pos_close='$user_time' WHERE pos_close = 0 AND user_id =".$userID) or die( "#ERROR-1#" . mysql_error());
	die($line);
}

//========================================================================================== preg_match for correct positions settings

$isLineOK = preg_match("/^START([0-9]{1,99},[0-9]{1,99},[A-Z0-9\/]{1,10},[A-Z]{1,6},[0-9]{5,30},[0-9\.]{5,30},[0-9\.]{5,30},[0-9\.]{5,30},[a-zA-Z0-9]{1,100},[a-zA-Z0-9]{1,100},ZZZ)+END$/", $line);



//======================================================================================== sprawdzenie danych wejściowych
if(isPositionString($line) && isAllowedChar($line) && $userExist == 1 && $userID != 0 && $isLineOK == 1){
	
	$cutline =  isPositionStringCut($line);

	$posLines = explode('ZZZ', $cutline);

	$i = 0;
	foreach ($posLines as $line1){
		$positions[$i] = explode(',', substr($line1, 0, -3));
		$i++;
	}

	$positionsExists = "";
	$z =0;
	foreach ($positions as $value) {
		
		$positionsExists = $positionsExists.$userID.$positions[$z][1].",";
		$positionsExists = $positionsExists."0";
		//echo "==".$positionsExists."++";
		$z++;
	}		

	$j =0;
	foreach ($positions as $value) {
		
		$pos_id = $userID.$positions[$j][1];
		$pos_currency = $positions[$j][2];
		$pos_volume = $positions[$j][4];
		$pos_stoploss = (float)$positions[$j][6];
		$pos_takeprofit = (float)$positions[$j][7];
		$pos_isLong = $positions[$j][3];
		$pos_open = $positions[$j][0];
		$pos_open_price = (float)$positions[$j][5];
		$pos_label = $positions[$j][8];
		$pos_comment = $positions[$j][9];
		
		if($pos_volume = $positions[$j][4] <= 10000){
			$pos_volume = 10000;
		}

		// INSERT INTO table (primarykeycol,col1,col2) VALUES (1,2,3) ON DUPLICATE KEY UPDATE col1=0, col2=col2+1

		//$q2 = mysql_query("DELETE FROM positionsTest WHERE pos_id NOT IN ( $positionsExists)");
		$q4 = mysql_query("UPDATE positionsTest1 SET pos_close='$user_time' WHERE pos_close = 0 AND user_id =".$userID." AND pos_id NOT IN (".$positionsExists.")") or die( "#ERROR-1#" . mysql_error());

		//$q3 = mysql_query("UPDATE positionsTest SET pos_currency='$pos_currency',pos_volume='$pos_volume',pos_stoploss='$pos_stoploss',pos_takeprofit='$pos_takeprofit',pos_isLong='$pos_isLong',pos_open='$pos_open',pos_open_price='$pos_open_price',pos_label='$pos_label',pos_comment='$pos_comment', user_ip='$user_ip', user_time='$user_time' WHERE pos_id = '$pos_id'");
		$q1 = mysql_query("INSERT INTO positionsTest1(pos_id,pos_currency,pos_volume,pos_stoploss,pos_takeprofit,pos_isLong,pos_open,pos_open_price,pos_label,pos_comment, user_id, user_ip, user_time) VALUES('$pos_id','$pos_currency','$pos_volume','$pos_stoploss','$pos_takeprofit','$pos_isLong','$pos_open','$pos_open_price','$pos_label','$pos_comment', '$userID', '$user_ip', '$user_time') ON DUPLICATE KEY UPDATE pos_currency='$pos_currency',pos_volume='$pos_volume',pos_stoploss='$pos_stoploss',pos_takeprofit='$pos_takeprofit',pos_isLong='$pos_isLong',pos_label='$pos_label',pos_comment='$pos_comment', user_ip='$user_ip', user_time='$user_time'") or die( "#ERROR-1#" . mysql_error());
		$j++;
	}

	//echo microtime();
	//$nanotime = system('date +%s%N');
	
	//function microtime_float()
	//{
	//	list($usec, $sec) = explode(" ", microtime());
	//	return ((float)$usec + (float)$sec);
	//}
	
	//echo microtime_float();
	
	
	if (!empty($_GET)) {
		//echo "<br>";
		//echo $user."<br>";
		//echo $pass."<br>";
		//echo $line."<br>";
	}	
	
	$out = $line;
}else{$out = '##SEND##CORRECT##DATA##';}
mysql_close($mysqlcon);

//========================================================================================= send output string
//echo $out;
echo $out;
?>

 

 

file functions.php

<?php


function isConnect($host, $user, $password, $db = 'db'){
	$link = mysql_connect($host, $user, $password) or die('Not connected : ' . mysql_error());

	// make foo the current db
	$db_selected = mysql_select_db($db, $link) or die ('Can\'t use foo : ' . mysql_error());
	
	mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
	mysql_query("SET NAMES utf8");
	mysql_query("SET CHARACTER SET utf8");
	mysql_query("SET collation_connection = utf8_generali_ci");

	return $link;
}


function isAllowedChar($line){
if (preg_match("#^[a-zA-Z0-9\.\,\/]+$#", $line)) {	return 1;} else { return 0;}
}


function isPositionString($string){
	// start end check
	if(substr($string, 0, 5) == "START" && substr($string, -3) == "END"){return 1;}else{return 0;}
}

function isPositionStringCut($string){
	// start end check
	$string = substr($string, 5);
	$string = substr($string, 0, -6);
	return $string;
}


// clean input from $_GET $_POST USE:     $_CLEAN['GET'] = cleanInput($_GET);
function cleanInput($elem)
{
	if(!is_array($elem))
		$elem = htmlentities($elem, ENT_QUOTES,"UTF-8");
	else{
		foreach ($elem as $key => $value){
			$elem[$key] = cleanInput($value);
		}
	}
	return $elem;
}

//$isLineOK = preg_match("/^START([0-9]{1,99}AAA[0-9]{1,99}AAA[A-Z0-9\/]{1,10}AAA[A-Z]{1,6}AAA[0-9]{5,30}AAA[0-9\.]{5,30}AAA[0-9\.]{5,30}AAA[0-9\.]{5,30}AAA[a-zA-Z0-9]{1,100}AAA[a-zA-Z0-9]{1,100}AAAZZZ)+END$/", $line);
 

?>

and mysql database file

## mysql database

CREATE DATABASE db CHARACTER SET utf8 COLLATE utf8_general_ci;

# CREATE DATABASE `db` CHARACTER SET utf8 COLLATE utf8_general_ci;
# GRANT ALL ON `mydb`.* TO `username`@localhost IDENTIFIED BY 'password';
# FLUSH PRIVILEGES;
# `user_time` TIMESTAMP DEFAULT NOW(),

USE db;

## create table users
CREATE TABLE `users`
(
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_alias` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_email` varchar(200) CHARACTER SET utf8 collate utf8_general_ci ,
`user_email_hash` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_pass` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_ip` text CHARACTER SET utf8 collate utf8_general_ci,
`user_time` int(21),
`user_code` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_active` char(1) CHARACTER SET utf8 collate utf8_general_ci DEFAULT '0',
PRIMARY KEY (`user_id`),
UNIQUE (`user_email` , `user_alias`)
)ENGINE=innoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;


insert into users VALUES('','zix','xx#email.com', md5('xx@email.com'), md5('pass'),null,null,null,0);



## create table users_all
CREATE TABLE `users_all`
(
`user_id` bigint(21) NOT NULL AUTO_INCREMENT,
`user_alias` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_email` varchar(200) CHARACTER SET utf8 collate utf8_general_ci ,
`user_email_hash` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_pass` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_ip` text CHARACTER SET utf8 collate utf8_general_ci,
`user_time` int(21),
`user_code` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_active` char(1) CHARACTER SET utf8 collate utf8_general_ci DEFAULT '0',
`user_firstname` char(2) CHARACTER SET utf8 collate utf8_general_ci ,
`user_lastname` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_country` char(2) CHARACTER SET utf8 collate utf8_general_ci ,
`user_town` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_gender` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_dofb` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_mobile` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_startbalance` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_descripion` text CHARACTER SET utf8 collate utf8_general_ci,
`user_ip_mask` varchar(200) CHARACTER SET utf8 collate utf8_general_ci ,
PRIMARY KEY (`user_id`),
UNIQUE (`user_email` , `user_alias`)
)ENGINE=innoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;


CREATE TABLE `positionsTest1`
(
`pos_id` varchar(200) CHARACTER SET utf8 collate utf8_general_ci ,
`pos_currency` varchar(25) CHARACTER SET utf8 collate utf8_general_ci ,
`pos_volume` bigint(21) DEFAULT 10000,
`pos_stoploss` float,
`pos_takeprofit` float,
`pos_isLong` char(5) NOT NULL DEFAULT 0,
`pos_open` bigint(21) NOT NULL DEFAULT 0,
`pos_open_price` float,
`pos_close` int(11) NOT NULL DEFAULT 0,
`pos_close_price` float DEFAULT 0,
`pos_label` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`pos_comment` varchar(100) CHARACTER SET utf8 collate utf8_general_ci ,
`user_id` bigint(21) DEFAULT 0,
`user_ip` text CHARACTER SET utf8 collate utf8_general_ci,
`user_time` text CHARACTER SET utf8 collate utf8_general_ci,
`user_microtime` text CHARACTER SET utf8 collate utf8_general_ci,
`user_nanotime` text CHARACTER SET utf8 collate utf8_general_ci,
PRIMARY KEY (`pos_id`),
UNIQUE (`pos_id`)
)ENGINE=innoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;

may be useful for someone ... bye.


@breakermind

breakermind
24 Mar 2014, 13:19

RE:

breakermind said:

Hi

I need send open positions to www server like apache2 via ssl connection but ...

why this robot does not show opened positions string in log window?

// -------------------------------------------------------------------------------
//
//    This is a Template used as a guideline to build your own Robot. 
//
// -------------------------------------------------------------------------------

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using System.IO;
using System.Net;
using System.Text;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC)]
    public class NewRobot : Robot
    {

        private string openPositionsString = "";
        protected override void OnStart()
        {
            // Put your initialization logic here

        }

//================================================================================
//                                                             OnPositionOpened
//================================================================================
        protected override void OnPositionOpened(Position openedPosition)
        {
            int BuyPos = 0;
            int SellPos = 0;

            foreach (var position in Account.Positions)
            {
                // Count opened positions
                if (position.TradeType == TradeType.Buy)
                {
                    BuyPos = BuyPos + 1;
                    Print("POS VOLUME: " + position.Volume);

                    // OPENED POSITION STRING
                    openPositionsString = "START" + position.EntryTime + "," + position.Id + "," + position.SymbolCode + ",TRUE" + "," + position.Volume + "," + position.EntryPrice + "," + position.StopLoss + "," + position.TakeProfit + "," + position.Label + "," + position.Comment + ",ZZZEND";
                    Print("HOW TO SHOW IN LOGS ======================================================");
                    Print("String : " + openPositionsString);


                }
                if (position.TradeType == TradeType.Sell)
                {

                    // OPENED POSITION STRING
                    openPositionsString = "START" + position.EntryTime + "," + position.Id + "," + position.SymbolCode + ",FALSE" + "," + position.Volume + "," + position.EntryPrice + "," + position.StopLoss + "," + position.TakeProfit + "," + position.Label + "," + position.Comment + ",ZZZEND";
                    Print("HOW TO SHOW IN LOGS ======================================================");
                    Print("String : " + openPositionsString);
                    SellPos = SellPos + 1;
                }
            }




            Print("All Buy positions: " + BuyPos);
            Print("All Sell positions: " + SellPos);


        }
        // end OnPositionOpened

        protected override void OnTick()
        {
            // Put your core logic here
            int BuyPos = 0;
            string sslServerHost = "breakermind.com";
            int sslServerPort = 443;

            WebRequest request = WebRequest.Create("https://" + sslServerHost + ":" + sslServerPort + "/send.php?line=" + openPositionsString + "&user=ml@breakermind.com&pass=pass987");
            request.Proxy = null;
            request.Credentials = CredentialCache.DefaultCredentials;

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            string responseFromServer = reader.ReadToEnd();
            Print("All Buy positions:" + responseFromServer);
            //Console.WriteLine(responseFromServer);
            //Print("All Buy positions: " + BuyPos);
        }



        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
    /*
        public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            return true;
        }
        */

}

 

Thanks bye

 

and on server side  validate function for

openPositionsString

is

$isLineOK = preg_match("/^START([0-9]{1,99},[0-9]{1,99},[A-Z0-9\/]{1,10},[A-Z]{1,6},[0-9]{5,30},[0-9\.]{5,30},[0-9\.]{5,30},[0-9\.]{5,30},[a-zA-Z0-9]{1,100},[a-zA-Z0-9]{1,100},ZZZ)+END$/", $line);

 


@breakermind

breakermind
13 Mar 2014, 08:59

RE: RE: RE:

modarkat said:

breakermind said:

Hi,


and maybe someone knows how connect to mysql database using HTTPS
or how to send get request to web server (like apache2) using HTTPS 

Regards

http://stackoverflow.com/questions/708210/how-to-use-http-get-request-in-c-sharp-with-ssl-protocol-violation

Thank you


@breakermind

breakermind
13 Mar 2014, 08:27

RE:

Hi,


and maybe someone knows how connect to mysql database using HTTPS
or how to send get request to web server (like apache2) using HTTPS 

Regards


@breakermind

breakermind
06 Mar 2014, 13:00

RE: RE:

This post has been removed by the moderator due to a violation of the EULA.


@breakermind

breakermind
05 Mar 2014, 13:38

RE:

This post has been removed by the moderator due to a violation of the EULA.


@breakermind

breakermind
04 Mar 2014, 16:41

RE: RE:

ninosgr said:

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

Hello,

JForex (dukascopy.com) java platform with sdk for deweloping

Bye

 

 


@breakermind

breakermind
25 Nov 2013, 16:20

RE:

Hi,

simple methods are the best !!!

Look how much you earned without using robots just by looking at the Chart D1 beginning of each of the first month on the low or high up on the first day to buy or sell down holding the position until the end of the month?

It more than 200 pips and it is 100% per month (often it is only the first week without guessing and poring just waiting)

Regards

 


@breakermind

breakermind
13 Nov 2013, 11:58

RE: RE: nevertheless

breakermind said:

Hi,

It's like the Lord Admin already learned, let it delete this post too

: D: D: D

 

hmm maybe admin can also block user?

Let see ...

dukascopy.com rules cool strategy with 100% per month ....


@breakermind

breakermind
13 Nov 2013, 11:32

RE: nevertheless

Hi,

It's like the Lord Admin already learned, let it delete this post too

: D: D: D

 


@breakermind

breakermind
29 Oct 2013, 22:14

RE: RE: RE:

Hello,

It's not important to me.

Posts and account may remain ... can someone to do something useful.

Regards, Thanks, bye.


@breakermind