Store
Challenges
Brokers
Discord
More
cBots
Plugins
Copy
Indicators
Prop firms
Get cTrader
Our jobs
Help center
SaifBD
Joined 05.01.2014
Please convert those MT4 codes to cAlgo 05 Jan 2015, 17:13
GetTickCount();
TimeCurrent();
deklin 05 Jan 2015, 23:53
Instead of TimeCurrent() use Server.Time
Print ( Server.Time );
See: /api/reference/internals/iserver/time
The time can be formatted using C# http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
---
Instead of GetTickCount() I would just start a variable at 0 and add to it every tick.
Here is an example that incorporates both of these solutions:
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 simpleTest : Robot { long tickCounter = 0; [Parameter("TotalTicsToStopAt", DefaultValue = 10)] protected override void OnStart() { Print("Current Time: " + Server.Time); Print("Current Time with Custom Formatting: " + Server.Time.ToString("ddd, MMM d yyyy H':'mm':'ss tt")); } protected override void OnTick() { Print("Tick Count: " + tickCounter++); } protected override void OnStop() { } } }
deklin
05 Jan 2015, 23:53
Re: Please convert those MT4 codes to cAlgo
Instead of TimeCurrent() use Server.Time
See:
/api/reference/internals/iserver/time
The time can be formatted using C#
http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
---
Instead of GetTickCount() I would just start a variable at 0 and add to it every tick.
Here is an example that incorporates both of these solutions:
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 simpleTest : Robot { long tickCounter = 0; [Parameter("TotalTicsToStopAt", DefaultValue = 10)] protected override void OnStart() { Print("Current Time: " + Server.Time); Print("Current Time with Custom Formatting: " + Server.Time.ToString("ddd, MMM d yyyy H':'mm':'ss tt")); } protected override void OnTick() { Print("Tick Count: " + tickCounter++); } protected override void OnStop() { } } }@deklin