I am sorry, but I dont exactly understand your questions ...
I've added the code to get the last matching ticket out of the history pool and do the martingale stuff. I recommend do not use it! It will wipe out your account, rather sooner than later!
int magic=5020060; double BaseLotSize=0.01; int ticket=GetTicketFromHistory(Symbol(),magic); if(ticket>0){ if(OrderSelect(ticket,SELECT_BY_TICKET)){ double LotSize=OrderLots(); double Profit =OrderProfit(); Print("LotSize: ",LotSize); Print("Profit : ",Profit); if(Profit<0)LotSize*=2; else LotSize=BaseLotSize; }else{Print("An error occured in OrderSelect");} }else{Print("No matching ticket found in history!");LotSize=BaseLotSize;} Print("Next LotSize: ",LotSize); //------------------------------------------------------------------- //| Comment :https://forum.mql4.com/46182 states that the order //| in the history pool is not reliable. Therefore create //| a sorted list and search for the matching OrderCloseTime. //+------------------------------------------------------------------+ int GetTicketFromHistory(string sym,int mn,int orderposinhistory=0,bool debug=false){ if(debug)Print("Orders in history: ", OrdersHistoryTotal()); int ticket,count=1,i; datetime orderclosedates[]; for(i=OrdersHistoryTotal()-1;i>=0;i--){ if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))continue; if(debug)Print("OrderSymbol: ",OrderSymbol(),"; OrderMagicNumber: ",OrderMagicNumber(), " ;OrderType: ",OrderType(),"; OrderTicket: ",OrderTicket(), "; OrderCloseTime: ",TimeToStr(OrderCloseTime()),";"); if((OrderMagicNumber() ==mn) &&(OrderSymbol() ==sym) &&(OrderType()==OP_BUY||OrderType()==OP_SELL)){ ArrayResize(orderclosedates,count); orderclosedates[count-1]=OrderCloseTime(); count++; } } if(ArraySize(orderclosedates)>0){ if(debug)Print("ArraySize (Orders found): ",ArraySize(orderclosedates)); if(ArraySize(orderclosedates)>orderposinhistory){ ArraySort(orderclosedates,WHOLE_ARRAY,0,MODE_DESCEND); for(i=OrdersHistoryTotal()-1;i>=0;i--){ if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))continue; if(OrderCloseTime()==orderclosedates[orderposinhistory]){ ticket=OrderTicket(); if(debug)Print("Orderticket for order ",orderposinhistory," in history: ",ticket); break; } } }else{ if(debug)Print("Not enough matching orders in history!"); } } return(ticket); }
What do you mean with:
Paulie_sk:
I want to use as the martingale system but all the other experts are now trades in a row! I want to wait for the signal ....
I want to use as the martingale system but all the other experts are now trades in a row! I want to wait for the signal ....
thank you very much for your advice,
I test
kronin:
See also, my implementation Could EA Really Live By Order_History Alone? - MQL4 forum
int GetTicketFromHistory(string sym,int mn,int orderposinhistory=0,bool debug=false){
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I went through so much that I'm writing here.
Do you know a function or script ... they hit last trade - or + account, and swallowed a lot like the last trade ...
My idea is:Variant result = last trade account or reviewed or not, the result (0 /1)
or is negative which was a lot in store used
I want to use as the martingale system but all the other experts are now trades in a row! I want to wait for the signal ....
but simply do not prevent the different solution
thanks for the answers in advance when that is done I add an expert ....
sorry for my English