Page 1 of 1

Account trade log

PostPosted: Sat Jul 15, 2017 9:41 pm
by robertm1907
Is it possible, or is there already a strategy that logs live trades? I run more then one strategy and also manually trade on my live account. On some currencies I run more then one strategy. These can open and close positions while I sleep, so often I am not sure which strategy made the trade. This means I don't always have a good record of what is working and what isn't. The report created by Trading Station does not include a record of strategies custom identifier.

I would like to create a strategy that dumps selected data from say the "Accounts", "Trades", and "Closed Trades" tables. It would dump this data at a defined time period into say an XML file, or CSV file.

Does such strategy already exist? If not is it possible?

Re: Account trade log

PostPosted: Mon Jul 17, 2017 5:14 am
by Apprentice
If the position is opened/closed?

Re: Account trade log

PostPosted: Mon Jul 17, 2017 6:45 am
by robertm1907
For now just a routine dump of the closed trades. Though if it's possible you could used data from any of the tables. Is there something already like this?

Re: Account trade log

PostPosted: Mon Jul 17, 2017 4:09 pm
by Apprentice
Your request is added to the development list, Under Id Number 3825
If someone is interested to do this task, please contact me.

Re: Account trade log

PostPosted: Thu Jul 20, 2017 4:51 am
by Apprentice

Re: Account trade log

PostPosted: Mon Jul 24, 2017 10:55 pm
by robertm1907
Thanks. Was more a question about it being possible. This is what I have come up with so far. Still working on the XML option. The issue I have is, I need a way of inserting new entries between the previous data and the XML files closing root tag. This way I can make the XML file valid.
Have not been able to find a way to read a file and return a pointer, then inset data after the pointer.
Have attached my first draft. The code is rather clunky at the moment, once I sort out the XML issue will make efficient. Also currently just dumps everything in the open and closed trades tables, have not yet added options to choose.

Re: Account trade log

PostPosted: Wed Jul 26, 2017 9:26 am
by Apprentice
For solve your problem you need use file:seek. and for example function:
Code: Select all
function SeekToFirstCloseAttribute(file, attribute)
    local name = "</"..attribute..">"
 for line in file:lines() do
        if (line == name) then
            file:seek("cur", -string.len(name));
            return true;
        end
    end 
    return false;
end

-------using----------------
local f;
while (f == nil) do
    f = io.open(instance.parameters.stid, "a");
end
 
SeekToFirstCloseAttribute(f, "Records")   
f:write("test");
f:close();

-------file----------------
<Records>
   <Record>
      ...
    </Record>
    <Record Date>
       ...
    </Record>
</Records>


But In the current version of the Indicore SDK we have a problem with the function file:seek. Implementation of the function is absent. and we get a error message [attempt to call method 'seek' (a nil value)].
I think in the next version of Indicore SDK will be fixed this problem.

Re: Account trade log

PostPosted: Wed Jul 26, 2017 7:39 pm
by robertm1907
Thanks, you answered my next question. I have been trying to get file:seek() working for the past 2 days. Have been thinking I was doing something silly. Was kicking myself thinking this is so simple, but it won't work. Always got the 'method a nil value' error.

Is there somewhere that bugs/issues like this are listed?

Re: Account trade log

PostPosted: Fri Jul 28, 2017 7:57 am
by robertm1907
This is as far as I got, am unable to do exactly what I want with out file:Seek. Will come back and finish when this bug is fixed. On to the next project.

Re: Account trade log

PostPosted: Thu Aug 03, 2017 4:17 pm
by Konstantin.Toporov
Unfortunately, access to the function file:seek was disabled since 2014.
Now it is possible to write only into the end of the file.
We will consider this feature (to support seek) in the scope of the next release.