Topics
Replies
breakermind
08 Jun 2014, 20:57
RE:
Hi, look at this:
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 z : Robot { [Parameter("Max time position open(hours)", DefaultValue = 2, MinValue = 1)] public int MaxTimeOpen { get; set; } protected override void OnStart() { // Put your initialization logic here Print("Start robot: ", Server.Time.Hour); if (Server.Time.Hour == 0) { ExecuteMarketOrder(TradeType.Sell, Symbol, 10000, "", 100, 100); } } protected override void OnTick() { // Put your core logic here Print("OnTick: ", Server.Time.Hour); foreach (var position in Positions) { Print(position.EntryTime.TimeOfDay); int posOpenTimeHours = position.EntryTime.Hour + MaxTimeOpen; int posOpenTimeMinutes = position.EntryTime.Minute; if (posOpenTimeHours > 24) { posOpenTimeHours = posOpenTimeHours - 24; } Print("Pos open time: ", posOpenTimeHours); if (Server.Time.Hour > posOpenTimeHours && Server.Time.Minute > posOpenTimeMinutes) { ClosePosition(position); } } } protected override void OnStop() { // Put your deinitialization logic here } } }
Regards
@breakermind
breakermind
05 Jun 2014, 13:08
Trade and Copy ...
Hello,
if you want to test it to copy items between platforms cAlgo / cTrader I invite you to page:
It's only a test version and may need some improvements but even if it does not work please do not worry and write where is bug..
During the nick is registered email address, you can specify how you want like: asdsa@sdds.ddd
database and so will be removed and the system does not send e-mails with activation.
cTrader demo account you set up yourself:
Start deposit $ 1,000 with 1:200 leverage microlots (spotware demo account is ok)
For Trader account need an upgrade in setting after login.
For trader account leverage 1:100 min - max 1:200
For user (copy positions) min leverage 1:200 and microlots (1000 volume) if you want
copy signals from $ 100 deposit
Regards
Ps
Dear support when I can get Account ID and Broker name from cBot ???
@breakermind
breakermind
30 May 2014, 20:13
RE: RE: RE: RE: RE: RE:
This code generate exception onTick:
account = Math.Round(Account.Equity, 2) + "|" + Math.Round(Account.Balance, 2) + "|" + Math.Round(Account.FreeMargin, 2) + "|" + Math.Round(Account.Margin, 2) + "|" + Math.Round((decimal)Account.MarginLevel, 2) + "|" + Account.Currency + "|" + Account.IsLive + "|" + Account.Leverage;
this:
30/05/2014 17:12:25.502 | System.InvalidOperationException: Obiekt dopuszczający wartość pustą musi mieć wartość. w System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) w cAlgo.BreakermindCopyTrader.sendPositions(String Username, String Password) w cAlgo.BreakermindCopyTrader.OnTick()
why support ???
@breakermind
breakermind
30 May 2014, 17:58
RE: RE: RE: RE: RE:
New VS does not install on my 32 bit awesome machine :] , and do not want to pull back and look for the older version I see tomorrow on another machine.
although I suspect that it will not do anything.
Thanks for help.
Invalid said:
Try to debug in VS - it will be much faster
breakermind said:
I see this in logs when start cbot when i have no open positions.
I look for it later...or write again from the beginning.
Invalid said:
Which line gives you this exception?
breakermind said:
if i have open position error gone!
if not a see this above
@breakermind
breakermind
30 May 2014, 17:33
RE: RE: RE:
I see this in logs when start cbot when i have no open positions.
I look for it later...or write again from the beginning.
Invalid said:
Which line gives you this exception?
breakermind said:
if i have open position error gone!
if not a see this above
@breakermind
breakermind
30 May 2014, 16:49
RE:
if i have open position error gone!
if not a see this above
@breakermind
breakermind
30 May 2014, 12:53
RE: RE: RE: RE: RE: RE: RE: RE: RE:
Hi,
How to get Open.time for lastr 3 bars with current timeframe?
And how check what timeframe is set from cbot?
And how to get current time (or maybe something like timestamp [current time in seconds, milisec ])?
Thanks
@breakermind
breakermind
29 May 2014, 14:22
RE: RE: RE: RE: RE: RE: RE: RE:
Hi,
exactly ... but I meant more to write a pattern so that it is correct and acceptable by the compiler.
this part:
"/^\[GO\]([0-9]{1,99};[A-Z]{1,6};[A-Z]{1,6};[0-9]{1,99};[0-9\,]{3,30};[0-9\,]{3,30};[0-9\,]{3,30};[0-9\,]{3,30}\|)+\[OG\]$/"
now it does not matter, already found and wrote.
Thanks all and regards.
Invalid said:
You've asked for C# representation of your code. I gave it. Explain what's the problem?
breakermind said:
Hi,
I know that (i have google to ;] :D ) but :
I dont want fight with this "shit" again ("shit" - preg match patterns).
Thanks.
@breakermind
breakermind
28 May 2014, 16:50
RE: RE: RE: RE: RE: RE:
Hi,
I know that (i have google to ;] :D ) but :
I dont want fight with this "shit" again ("shit" - preg match patterns).
Thanks.
@breakermind
breakermind
28 May 2014, 14:41
RE: RE: RE: RE:
Hi,
how to rewrite this in c#:
php:
$valid = preg_match("/^\[GO\]([0-9]{1,99};[A-Z]{1,6};[A-Z]{1,6};[0-9]{1,99};[0-9\,]{3,30};[0-9\,]{3,30};[0-9\,]{3,30};[0-9\,]{3,30}\|)+\[OG\]$/", $pos);
Thanks
@breakermind
breakermind
28 May 2014, 12:03
and signal providers
http://www.dukascopy.com/fxcomm/signal_provider/
@breakermind
breakermind
28 May 2014, 11:56
RE: RE:
my account at the competition:
first year:
http://www.dukascopy.com/tradercontest/?action=blog&trader=breakermind&period=month&language=en&tab=feed
this year:
http://www.dukascopy.com/tradercontest/?action=blog&trader=zix&period=month&language=en&tab=feed
Maybe this year will be better than the previous :)
@breakermind
breakermind
28 May 2014, 11:15
RE:
kricka said:
Hi breakermind,
who does not want to be a millionaire :)
The thing is, a period can be any lenght from a month to a year I suppose. Compounding the account and not withdrawing anything under the lenght of the strategy. OK I must admit that a strategy like you are giving us here totally free of charge is achiveable but as we know things happen in trading and a strategy might not work out exactly as planed but never the less thanks for bringing up the importance of compounding.
Hmm ... even in 12 years is not bad. Some people lifelong not earn as much as 2M.
100% in the year on forex is not much, on the competition for dukaskopy are those madmen who have an average of 100% a month.
Regards
madman in future i hope :D :P
@breakermind
breakermind
28 May 2014, 02:41
RE: Vote
MasterCopyPosition update with force ssl validation for self signed ssl:
// System using System; using System.IO; using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; using System.Net.Security; // cAlgo using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.API.Requests; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class BreakermindMasterCopy : Robot { private string responseFromServer = ""; private string openPositionsString = ""; private string openPips = ""; private string account = ""; private int MaxPositions = 20; private int MinVolume = 10000; [Parameter("Username", DefaultValue = "zix")] public string Username { get; set; } [Parameter("Password", DefaultValue = "1231231231")] public string Password { get; set; } [Parameter("Auto Take Profit (pips)", DefaultValue = 200, MinValue = 10)] public int TakeProfitInPips { get; set; } [Parameter("Auto Stop Loss (pips)", DefaultValue = 50, MinValue = 10)] public int StopLossInPips { get; set; } protected override void OnStart() { Print("!!!! Master robot start!!! Account leverage 1:200, min volume" + MinVolume + "(!!! cBot CLOSE ALL position with lower volume !!!)"); Print("!!!! Start capital 1000$, Position required StopLoss and Take profit, Max " + MaxPositions + " positions !!!!"); if (Account.Leverage > 200) { Print("Account leverage incorrect !!! You need leverage <= 1:200, stoping... copier"); Stop(); } foreach (HistoricalTrade trade in History) { // this month closed positions if (DateTime.Now.Month == trade.EntryTime.Month) { Print("Curr month history positions: " + trade.PositionId + " open time " + trade.EntryTime.Month); } } } // onbar we will see... protected override void OnBar() { } protected override void OnTick() { // Put your core logic here try { sendPositions(Username, Password); } catch (Exception e) { var he = e; Print("Wait for positions......."); } } protected override void OnStop() { Print("Master robot stop!!!"); } //==================================================================================================================== // Send POST to HTTPS Server //==================================================================================================================== protected void sendPositions(string Username, string Password) { // log file path string desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); string logPath = Path.Combine(desktopFolder, "MasterLog.db"); // open position var AllPositions = Positions.FindAll(""); openPositionsString = "[GO]"; openPips = ""; foreach (var position in AllPositions) { if (Positions.Count >= MaxPositions || Positions.Count == 0) { break; } // close with wrong volume if (position.Volume < MinVolume) { Print("cBot Position: " + position.Id + " Wrong Min Volume (" + MinVolume + ") "); if (position.Volume < MinVolume) ClosePosition(position); Print("cBot Closed Position " + position.Id); } if (position.StopLoss == null) { Print("Position {1} SL price is {0}", position.StopLoss, position.Id); } if (position.TakeProfit == null) { Print("Position {1} TP price is {0}", position.StopLoss, position.Id); } if (position.StopLoss == null && position.TakeProfit == null) { Print("Modifying {0}", position.Id); ModifyPosition(position, GetAbsoluteStopLoss(position, StopLossInPips), GetAbsoluteTakeProfit(position, TakeProfitInPips)); } if (position.StopLoss == null) { Print("Modifying {0}", position.Id); //ModifyPosition(position, GetAbsoluteStopLoss(position, StopLossInPips), GetAbsoluteTakeProfit(position, TakeProfitInPips)); ModifyPosition(position, GetAbsoluteStopLoss(position, StopLossInPips), position.TakeProfit); } if (position.TakeProfit == null) { Print("Modifying {0}", position.Id); //ModifyPosition(position, GetAbsoluteStopLoss(position, StopLossInPips), GetAbsoluteTakeProfit(position, TakeProfitInPips)); ModifyPosition(position, position.StopLoss, GetAbsoluteTakeProfit(position, TakeProfitInPips)); } // BUY positions if (position.TradeType == TradeType.Buy && position.Volume >= MinVolume) { openPositionsString += position.Id + ";" + position.SymbolCode + ";" + "BUY" + ";" + position.Volume + ";" + position.EntryPrice + ";" + position.StopLoss + ";" + position.TakeProfit + ";" + DateTimeToUnixTimestamp(position.EntryTime) + "|"; openPips += position.Pips + "|"; } // SELL positions if (position.TradeType == TradeType.Sell && position.Volume >= MinVolume) { openPositionsString += position.Id + ";" + position.SymbolCode + ";" + "SELL" + ";" + position.Volume + ";" + position.EntryPrice + ";" + position.StopLoss + ";" + position.TakeProfit + ";" + DateTimeToUnixTimestamp(position.EntryTime) + "|"; openPips += position.Pips + "|"; } } openPositionsString += "[OG]"; //================================================================================ // Send request //================================================================================ if (responseFromServer == openPositionsString) { Print("Same strings ... wait for new Positions !"); Print("RESPONSE: " + responseFromServer); Print("OPEN POS: " + openPositionsString); } if (responseFromServer != openPositionsString) { // Account parametrs ============================================ account = Math.Round(Account.Equity, 2) + "|" + Math.Round(Account.Balance, 2) + "|" + Math.Round(Account.FreeMargin, 2) + "|" + Math.Round(Account.Margin, 2) + "|" + Math.Round((decimal)Account.MarginLevel, 2) + "|" + Account.Currency + "|" + Account.IsLive + "|" + Account.Leverage; try { using (StreamWriter w = File.AppendText(logPath)) { // log request w.WriteLine("REQUEST: " + DateTimeToUnixTimestamp(DateTime.UtcNow) + " : " + openPositionsString); w.Flush(); w.Close(); } //================================================================================ // FORCE CERTYFICATE SSL VALIDATION for self signed(openssl) ssl //================================================================================ ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); //================================================================================ // HTTPS POST //================================================================================ WebRequest request = WebRequest.Create("https://192.168.0.100/set.php"); Print("===================================================================================="); Print("==>> " + openPositionsString); Print("===================================================================================="); byte[] postBytes = Encoding.ASCII.GetBytes("line=" + openPositionsString + "&linepips=" + openPips + "&account=" + account + "&login=" + Username + "&pass=" + Password); //request.Credentials = CredentialCache.DefaultCredentials; request.Proxy = null; request.Method = "POST"; 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 = ""; responseFromServer = reader.ReadToEnd(); openPositionsString = ""; } catch (Exception e) { Print("===================================================================================="); Print("Post Error: " + e); Print("===================================================================================="); using (StreamWriter w = File.AppendText(logPath)) { // log response w.WriteLine("ERROR: " + DateTimeToUnixTimestamp(DateTime.UtcNow) + " : " + e); w.Flush(); w.Close(); } } Print("===================================================================================="); Print("<<== " + responseFromServer); Print("===================================================================================="); using (StreamWriter w = File.AppendText(logPath)) { // log response w.WriteLine("RESPONSE: " + DateTimeToUnixTimestamp(DateTime.UtcNow) + " : " + responseFromServer); w.Flush(); w.Close(); } } } //================================================================================ // modify SL and TP //================================================================================ private double GetAbsoluteStopLoss(Position position, int stopLossInPips) { Symbol Symbol = MarketData.GetSymbol(position.SymbolCode); return position.TradeType == TradeType.Buy ? position.EntryPrice - (Symbol.PipSize * stopLossInPips) : position.EntryPrice + (Symbol.PipSize * stopLossInPips); } private double GetAbsoluteTakeProfit(Position position, int takeProfitInPips) { Symbol Symbol = MarketData.GetSymbol(position.SymbolCode); return position.TradeType == TradeType.Buy ? position.EntryPrice + (Symbol.PipSize * takeProfitInPips) : position.EntryPrice - (Symbol.PipSize * takeProfitInPips); } /// datatime to timestamp public static double DateTimeToUnixTimestamp(DateTime dateTime) { return (dateTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds; } // end //================================================================================ // FORCE CERTYFICATE SSL VALIDATION for self signed ssl //================================================================================ public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return true; } //================================================================================================================ // End Send POST to HTTPS Server //================================================================================================================ } }
@breakermind
breakermind
28 May 2014, 01:09
RE: Account
breakermind said:
Hi
How to retrieve the account id and check if the account is real or demo?
How to retrieve the history of open position only with current month?Regards
foreach (HistoricalTrade trade in History) { if (DateTime.Now.Month == trade.EntryTime.Month) { Print("Curr month history positions: " + trade.PositionId + " open time " + trade.EntryTime); } }
if(Account.IsLive){ Print( "Demo account" ); }
@breakermind
breakermind
28 May 2014, 00:21
RE: RE:
Hi again,
Is it possible to force onBar works on custom period like m15 if the robot start on H1
Thanks
@breakermind
breakermind
27 May 2014, 12:32
( Updated at: 23 Jan 2024, 13:11 )
RE:
modarkat said:
OnTimer event will be added in next version of cAlgo:
[/forum/cbot-support/2871?page=1]
Thank you!
@breakermind
breakermind
27 May 2014, 12:20
RE: RE: RE:
Hi,
how to send notification or print to log every 5 minutes whitout use onBar(5M)?
Thanks
@breakermind
breakermind
26 May 2014, 00:51
RE:
Hi,
it is possible to start robot automatically when the cTrader / cAlgo starts?
Thanks
@breakermind
breakermind
11 Jun 2014, 09:57
UTC Time
Hi,
unix timestamp utc:
How to get bar open time?
@breakermind