Running an intraday system I would like to monitor account size and trading results in this manner:
- write results into a file and make this file available to other devices (e.g. by copying it into a Dropbox folder)
- output current account size and trade results after closing trades
- using a paper trading account
- if nothing happens then write the file once per hour
- data feed is IQFeed and my broker is IB
My intention is to see whether real trading results meet backtest results.
I use this code:
Code: Select all
If (ATS_Monitoring and Date=CurrentDate and RegularMarketHours and BarStatus(1) = 2) and
( MP <> MP[1] or NetProfit <> NP or Mod(TimeToMinutes(time),60) = 0) then begin
value1=GetRTAccountNetWorth("DU16****");
value2=GetRTUnrealizedPL("DU16***");
TraceOutStr = DateToString(DateToJulian(Date)) + " " + TimeToString(ELTimeToDateTime(Time))+
" Account=" + NumToStr(value1,2) +
" open Trade=" + NumToStr(value2,2) +
" NetProfit=" + NumToStr(NetProfit,2);
FileAppend(Trace_path+"Account_Size.txt",TraceOutStr+NewLine);
end;
The account size could not change so much according to the netprofits.29.12.2014 10:00:00 Account=816645.00 open Trade=0.00 NetProfit=0.00
29.12.2014 11:00:00 Account=816627.00 open Trade=-38.00 NetProfit=0.00
29.12.2014 12:00:00 Account=816970.00 open Trade=-58.00 NetProfit=-164.00
29.12.2014 13:00:00 Account=818190.00 open Trade=-48.00 NetProfit=-164.00
29.12.2014 14:00:00 Account=818144.00 open Trade=3.00 NetProfit=-164.00
02.01.2015 09:00:00 Account=827690.00 open Trade=0.00 NetProfit=0.00
02.01.2015 10:00:00 Account=826805.00 open Trade=0.00 NetProfit=0.00
02.01.2015 11:00:00 Account=827901.00 open Trade=-21.00 NetProfit=-264.00
02.01.2015 12:00:00 Account=827802.00 open Trade=0.00 NetProfit=-407.00
02.01.2015 13:00:00 Account=827584.00 open Trade=-42.00 NetProfit=-407.00
02.01.2015 14:00:00 Account=828033.00 open Trade=0.00 NetProfit=-286.00
And I am not sure to which time frame the netprofit belongs. How to make sure that it belongs only to one day?
Is the code ok?
Backtesting shows anyway totaly different results.
Backtesting shows two trades, which made $121 each.
This is the major problem.