Account trade log

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Account trade log

Postby robertm1907 » Sat Jul 15, 2017 9:41 pm

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?
robertm1907
 
Posts: 10
Joined: Thu Jul 06, 2017 6:58 am

Re: Account trade log

Postby Apprentice » Mon Jul 17, 2017 5:14 am

If the position is opened/closed?
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 22173
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Account trade log

Postby robertm1907 » Mon Jul 17, 2017 6:45 am

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?
robertm1907
 
Posts: 10
Joined: Thu Jul 06, 2017 6:58 am

Re: Account trade log

Postby Apprentice » Mon Jul 17, 2017 4:09 pm

Your request is added to the development list, Under Id Number 3825
If someone is interested to do this task, please contact me.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 22173
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Re: Account trade log

Postby robertm1907 » Mon Jul 24, 2017 10:55 pm

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.
Attachments
Account - logger.lua
Account - logger first draft
(12.7 KiB) Downloaded 223 times
robertm1907
 
Posts: 10
Joined: Thu Jul 06, 2017 6:58 am

Re: Account trade log

Postby Apprentice » Wed Jul 26, 2017 9:26 am

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.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 22173
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Account trade log

Postby robertm1907 » Wed Jul 26, 2017 7:39 pm

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?
robertm1907
 
Posts: 10
Joined: Thu Jul 06, 2017 6:58 am

Re: Account trade log

Postby robertm1907 » Fri Jul 28, 2017 7:57 am

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.
Attachments
Account - logger V1.lua
Cleaned up version.
(11.5 KiB) Downloaded 221 times
robertm1907
 
Posts: 10
Joined: Thu Jul 06, 2017 6:58 am

Re: Account trade log

Postby Konstantin.Toporov » Thu Aug 03, 2017 4:17 pm

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.
Konstantin.Toporov
FXCodeBase: Initiate
 
Posts: 110
Joined: Mon Aug 31, 2015 10:16 am


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 6 guests