Hi, I am new to MC. what is the cleanest way to write trade information to file, as it compiles in the chart?
I am looking for basic information, which can be found in existing functions. I am looking for something that will emulate the List of trades, found in performance summary. Just basic trade information:
Order#, Type, SignalName ,Date/Time, Price, Contracts
what does the code need to look like to produce a running file in the proper chronological order of entry/exit?
Thank you. Gordon
How to write basic trade information to file [SOLVED]
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
You can use the PRINT statement to output any data to an ascii file.Hi, I am new to MC. what is the cleanest way to write trade information to file, as it compiles in the chart?
I am looking for basic information, which can be found in existing functions. I am looking for something that will emulate the List of trades, found in performance summary. Just basic trade information:
Order#, Type, SignalName ,Date/Time, Price, Contracts
what does the code need to look like to produce a running file in the proper chronological order of entry/exit?
Thank you. Gordon
Check out the wiki for the relevant keywords for Order#, Type, SignalName ,Date/Time, Price, Contracts, etc.
Hi, I didn't explaining myself very well. I do know the functions and how to write to file, my issue is exactly how to I fire the code off, as it might be an exit that fired or it might have been an entry that fired. And I might have an exit and entry fire at the same time, how do I ensure that the trades are written in chronological order?
Thanks
Thanks
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
You can put the PRINT statement at all the critical points.Hi, I didn't explaining myself very well. I do know the functions and how to write to file, my issue is exactly how to I fire the code off, as it might be an exit that fired or it might have been an entry that fired. And I might have an exit and entry fire at the same time, how do I ensure that the trades are written in chronological order?
Thanks
eg.
Code: Select all
If buy.condition = true then
BEGIN
Buy ("B") next bar at market;
PRINT...
END;
Thanks TJ, I am using stops, so I really can't code like you suggested. More or less, I will have to look for a change in TotalTrades, once that changes, then I know there is something to report. I can imagine something where I loop through the difference between TotalTrade and the prior Totaltrades, looking at EntryDateTime(x) and ExitDateTime(x), so then I know if I am dumping entryPrice or ExitPrice. But this seems very complicated and convoluted.
There really has to be a "simple" way to write to file so these trades are in chronological order.
Thanks again.
Gordon
There really has to be a "simple" way to write to file so these trades are in chronological order.
Thanks again.
Gordon
- JoshM
- Posts: 2196
- Joined: May 20 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Just monitor whether there is an open position (while there wasn't previously), and vice versa. For example:Thanks TJ, I am using stops, so I really can't code like you suggested. More or less, I will have to look for a change in TotalTrades, once that changes, then I know there is something to report. I can imagine something where I loop through the difference between TotalTrade and the prior Totaltrades, looking at EntryDateTime(x) and ExitDateTime(x), so then I know if I am dumping entryPrice or ExitPrice. But this seems very complicated and convoluted.
There really has to be a "simple" way to write to file so these trades are in chronological order.
Code: Select all
Variables:
IntraBarPersist PrevMP(0),
MP(0);
MP = MarketPosition(0);
if (MP <> 0 and PrevMP = 0) then begin
Print("A new position has been opened");
if (MP > 0) then
Print(".. it's a long position")
else
Print(".. it's a short position");
end;
if (PrevMP <> 0 and MP = 0) then begin
Print("A position has been closed");
end;
PrevMP = MP;