Find positions closed on this day before cBot starts

13 Mar 2018, 12:40Find positions closed on this day before cBot starts#1
alexander.n.fedorovposts: 80since: 02 Jan 2018

Dear Pangiotis,

Is it possible to find programmatically the list of position closed and their attributes berfore robot starts (or whatever is possible)?

The robot may have been stopped for whatever reason, and after it is restarted , information about positions before restart.

Regards

 

13 Mar 2018, 12:45#2
Panagiotis Charalampousposts: 1003since: 13 Jan 2017

Hi Alexander,

You can use History to access historical trades. Let me know if this helps.

Best Regards,

Panagiotis


Head of Community Management at cTrader
13 Mar 2018, 13:07#3
alexander.n.fedorovposts: 80since: 02 Jan 2018

That is what I did:

"

    [Robot(TimeZone = TimeZones.RussianStandardTime, AccessRights = AccessRights.None)]
    public class LondonRange : Robot
    {

...

       public HistoricalTrade FindLast;

...

OnStart()

...

Severity Code Description Project File Line Suppression State

Error CS0501 'LondonRange.FindLast(string)' must declare a body because it is not marked abstract, extern, or partial London Range C:\Users\User\Documents\cAlgo\Sources\Robots\London Range\London Range\London Range.cs 77 Active

"

After that I am lost

please advise

 

 

13 Mar 2018, 14:04#4
alexander.n.fedorovposts: 80since: 02 Jan 2018

I  was able to this:

 

"

...

 

        foreach(HistoricalTrade trade in History)
            {
                if (trade.Label == Instance)
                    Print("closed trade ID = {0}, trade closing time = {1}", trade.ClosingDealId,  trade.ClosingTime );
            }
...           

 

13/03/2018 15:00:00.941 | closed trade ID = 47704059, trade closing time = 12.03.2018 13:06:03 

 

...

"

The I could cycle through the trades and find the last one, but what would be the syntax for "Find.Last" . How do I invoke the label there?

13 Mar 2018, 14:08#5
Panagiotis Charalampousposts: 1003since: 13 Jan 2017

Hi Alexander,

You can use  History.FindLast()

Best Regards,

Panagiotis


Head of Community Management at cTrader
13 Mar 2018, 14:12#6
alexander.n.fedorovposts: 80since: 02 Jan 2018

Pangiotis,

You very kind. It worked. Thank you

Regards

Alexander