(My tester EA)
#property
- Don't add text inside
quoted or SRC blocks, put it outside. MQL4
Forum editor problem - MQL4 forum
I want my EA to write Open order information only once
Remember the last ticket number written and ignore that and earlier.
- Don't add text inside
quoted or SRC blocks, put it outside. MQL4
Forum editor problem - MQL4 forum
- Remember the last ticket number written and ignore that and earlier.
Dear whroeder1,
Thanks for your prompt comment and your advice on not adding text inside SRC blocks.
I need a little more elaboration on what you mean by "Remember the last ticket number written and ignore that and earlier."
The below coding is what I came up after reading your comment but it produces the same result as before. Which part am I getting wrong?
for(int i=0;i<OrdersTotal();i++) {int e=0; if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==TRUE) {if(OrderTicket()!=e) {int handle=FileOpen(FileName,FILE_CSV|FILE_READ|FILE_WRITE,","); FileSeek(handle,0,SEEK_END); FileWrite(handle,OrderType(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots()); FileClose(handle); e= OrderTicket(); } } }
kb985504: . Which part am I getting wrong?
|
|
|
I got it now!
Thank you very much for your advice!
Hello! I am trying to make the same thing as you where it outputs all live data to a CSV file with my open trades without seeking file end. I have edited your code to just this but it only exports the last position and not all of the open positions. How would I loop for each open position? Thanks for the help :)
I know you said the way around it is to reject earlier tickets with e and then ignore the previous tickets but I cant figure it out, I just want to export data into the csv live of all my open positions...
string FileName="Optimization.csv"; int start() { for(int i=0;i<OrdersTotal();i++) {int e=0; if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==TRUE) {if(OrderTicket()!=e) {int handle=FileOpen(FileName,FILE_CSV|FILE_READ|FILE_WRITE,","); FileWrite(handle,OrderType(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots(),OrderProfit()); FileClose(handle); e= OrderTicket(); } } } return(0); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use