Coming from SC (SC), lots of things in MC.NET look different.
In SC you develop in their own language (called ACSIL) which is pretty close in style to Easylanguage so things are very clear.
But since it's actually C++ underneath it, if you need/want something that is not encapsulated in ACSIL, you can simply use C++ code in the same study and it will compile just fine.
With that said, I see that MC.NET supports only C#.NET programming.
I'm not a professional programmer and I just learn as I go (after 3 years I've developed a plethora of complex tools in SC).
I tried going over C# codes in MC.NET, but since you don't give any remarks in the code of what you do there... it's even harder to "learn as I go"
Please help me convert this small code snippet from SC to MC.NET which will give me some insight of how things are done in MC.NET.
This code snippet simply gets the system times of when bars were created and stores them in an array:
Code: Select all
int& IndexFollow = sc.PersistVars->i1;
if (IndexFollow < sc.Index)
{
OpenTime[sc.Index] = sc.CurrentSystemDateTime.GetTime();
IndexFollow = sc.Index;
}
sc.Index = an ACSIL member that holds the last (or current) bar's index number.
In SC the first bar that is load into a chart gets Index number 0. the second bar gets Index number 1 etc etc.
Every time a new bar is added, sc.Index grows by 1.
When that happens I simply store the system time (sc.CurrentSystemDateTime.GetTime()) in an array which is indexed by the bars Indexes (OpenTime[sc.Index]).
In order to get just the bar's creation time, I need to "lock" the if statement and I do that with an int variable called IndexFollow.
But since a regular variable will get over written with each new tick in the current bar, SC gives an option to create a persistent var like this:
int& IndexFollow = sc.PersistVars->i1;
(you can declare persistent int, float, double and DateTime)
Looking on code examples in MC.NET and reading your wiki, I couldn't see how can I translate this little code snippet.
How do you index bars?
Where it is stored?
How do you create persistent (static?) vars?
Please help