Topics
Replies
breakermind
12 Apr 2014, 10:31
RE:
Hi,
if the period for the backtest is a period in which the robot is tested - very poorly.
In competitions for robots 100% in a month is the norm.
look for competition strategies: https://www.google.pl/search?q=jforex+strategy+contest
or if the previous link is blocked https://www.google.pl/search?q=strategy+contest
See how it works, there is an examples.
Regards
@breakermind
breakermind
11 Apr 2014, 23:08
( Updated at: 21 Dec 2023, 09:20 )
Socket Connections
TCP Multi-user Socket (Client/Server) scheme:

next will be: multi-client server example in java
Bye.
@breakermind
breakermind
11 Apr 2014, 14:32
( Updated at: 21 Dec 2023, 09:20 )

miej więcej o to chyba chodzi.
@breakermind
breakermind
11 Apr 2014, 14:09
RE:
Hi,
may in a certain period of time remaining open positions generated a loss, and after the close of the first item you are equity under balance.
Bye.
@breakermind
breakermind
10 Apr 2014, 12:49
RE: However
breakermind said:
This post has been removed by the moderator due to a violation of the EULA.
Hi hi hi the truth is sometimes painful ... hahhaha ... a lot of work in front of programmers from calgo.
Bye.
@breakermind
breakermind
10 Apr 2014, 12:39
However
This post has been removed by the moderator due to a violation of the EULA.
@breakermind
breakermind
09 Apr 2014, 20:39
PID ?
and why in history in html file
I don't see position PID like this in opened positions?
@breakermind
breakermind
09 Apr 2014, 20:02
Statement
Spotware said:
breakermind said:
Hi,
how to retrieve the history of closed positions from calgo robot?
bye
you can use History collection
Hi,
HOW ?
and what the label?
can I generate Statement from robot?
really could not read the history of the position from the robot (it is a joke unless)?
PS.
If I see again "We will add this in the future."
I walk out of here and never come back ...
@breakermind
breakermind
09 Apr 2014, 14:09
Limiting negative slippage
It is possible set slippage in cAlgo Robots ?
Slippage can be either positive or negative. Positive slippage means that the execution price is better than the reference price (never seen on *Moderated*), and negative slippage means that the execution price is worse than the reference price (Allways seen on *Moderated*).
Regards
@breakermind
breakermind
09 Apr 2014, 13:34
RE: Label
How change label manualy from calgo when I set position?
@breakermind
breakermind
09 Apr 2014, 13:13
Live cAlgo positions on the website
Hi,
Yes it works in the real world. Displaying opened positions from cAlgo on the web page :]
You can see :
Regards
@breakermind
breakermind
08 Apr 2014, 14:43
How to get Trader Contest positions and copy to file and next load to calgo
Hi,
How we can copy Traders opend positions to www page :
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=51042
and then we can GET file from web page and load to calgo robots
Bye..
@breakermind
breakermind
07 Apr 2014, 14:29
RE: Write and read opened positions from one robot to another
and why it does not work?
string[] stringArray = { "one", "two", "three", "four" };
var last=stringArray.Last();
var first=stringArray.First();
thx
@breakermind
breakermind
07 Apr 2014, 14:26
Write and read opened positions from one robot to another
Write robot:
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.IO;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class WriteToFileExample : Robot
{
//================================================================================
// Vars
//================================================================================
// stream for file
StreamWriter _fileWriter;
// desktop folder
static string desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
// path to file
string filePath = Path.Combine(desktopFolder, "z.txt");
private string responseFromServer = "";
private string openPositionsString = "";
[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("Hello Master ... ");
}
//================================================================================
// OnBar
//================================================================================
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);
}
}
//================================================================================
// 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 + "_##";
}
}
//=============================================================================== save to file
Print(File.Exists(filePath) ? "============== File exists." : "================= File does not exist.");
if (!File.Exists(filePath))
{
_fileWriter = File.AppendText(filePath);
//creating file
_fileWriter.AutoFlush = true;
//file will be saved on each change
//_fileWriter.WriteLine("All opened positions <---> Server Time: " + Server.Time);
_fileWriter.WriteLine(openPositionsString);
// close file and next read from file
_fileWriter.Close();
}
//=========================================================================== read from file
var dFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
var fPath = Path.Combine(dFolder, "z.txt");
string[] lines = System.IO.File.ReadAllLines(fPath);
foreach (string line in lines)
{
// Use a tab to indent each line of the file.
Print("Text from file: \t" + line);
}
}
//================================================================================
// OnStop
//================================================================================
protected override void OnStop()
{
Print("Bye Master ...");
}
}
}
second robot read from file opened positions:
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.IO;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class WriteToFileExample : Robot
{
//================================================================================
// Vars
//================================================================================
// stream for file
StreamWriter _fileWriter;
// desktop folder
static string desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
// path to file
string filePath = Path.Combine(desktopFolder, "z.txt");
private string responseFromServer = "";
private string openPositionsString = "";
[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("Hello Master ... ");
}
//================================================================================
// OnBar
//================================================================================
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);
}
}
//================================================================================
// OnTick
//================================================================================
protected override void OnTick()
{
//=============================================================================== if file exists
Print(File.Exists(filePath) ? "============== File exists." : "================= File does not exist.");
if (File.Exists(filePath))
{
//=========================================================================== read from file
var dFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
var fPath = Path.Combine(dFolder, "z.txt");
string[] lines = System.IO.File.ReadAllLines(fPath);
foreach (string line in lines)
{
// Use a tab to indent each line of the file.
Print("Opened positions line: \t" + line);
File.Delete(fPath);
}
}
}
//================================================================================
// OnStop
//================================================================================
protected override void OnStop()
{
Print("Bye Master ...");
}
}
}
@breakermind
breakermind
05 Apr 2014, 22:12
RE: How catch last event
Hi,
How to retrieve the history of closed positions?
@breakermind
breakermind
05 Apr 2014, 15:48
How catch last event
Hi and thanks
how to capture last-position-event (like modify stoploss or takeprofit, open position, close position) when position was opened not from robot but manualy from calgo?
thx
@breakermind
breakermind
03 Apr 2014, 11:57
RE: How to split string
Hi,
how to get current price for all available currency?
@breakermind
breakermind
31 Mar 2014, 15:13
( Updated at: 21 Dec 2023, 09:20 )
How to split string
Hi,
I have code:
// ----------------------------------------------------------------------------------
// 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("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("Slave Robot start ...");
responseFromServer = "";
}
protected override void OnBar()
{
if (Positions.Count < MaxPositions)
{
if (Volume > VolumeMax)
{
Volume = VolumeMax;
}
}
}
//================================================================================
// 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 = "START";
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, "_", "*") + "_##";
}
// 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, "_", "*") + "_##";
}
}
*/
openPositionsString = "Send Login credentials";
//================================================================================
// Send POST to HTTPS Server
//================================================================================
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 + "/get.php");
// post data
byte[] postBytes = Encoding.ASCII.GetBytes("&user=" + Username + "&pass=" + Password);
// 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);
}
string inp = "" + responseFromServer;
string[] posin = inp.Split("##");
foreach (string pos in posin)
{
Print(pos);
}
}
//================================================================================
// OnStop
//================================================================================
protected override void OnStop()
{
Print("Slave Robot stop");
}
}
}
and this code generate error:
string inp = "" + responseFromServer;
string[] posin = inp.Split("##");
foreach (string pos in posin)
{
Print(pos);
}

What is wrong?
Regards
@breakermind
breakermind
24 Apr 2014, 12:39
Very good
There is better but more risky :D:D:D
/forum/cbot-support/1397
Bye.
@breakermind