Order History
and how i see, how many order in a row are with loss
means, i want only to count, how many orders away is the last profit order
amando:
My opionion was to order it at ticket number, this means open time if i'm right
I've adapted one of my functions to do what you want.
//-------Function to count closed cosecutive losing trades counting from last int ConsecutiveLosses() { int consecutive_loss; //The variable that holds the number of consecutive losses counting from the latest //order open time (closed trades) int counter = 0; datetime opentime[]; double profit[]; for(int index=0;index<OrdersHistoryTotal();index++) { if(!OrderSelect(index,SELECT_BY_POS,MODE_HISTORY) ) continue; else if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() ) { counter++ ; ArrayResize( opentime, counter); ArrayResize( profit, counter); opentime[counter -1]=OrderOpenTime(); //If you change OrderOpenTime() to OrderCloseTime() it will calculate using profit[counter -1]=OrderProfit(); // close time instead of open time } } int orderarray []; ArrayResize( orderarray, counter); datetime copyopentime[]; ArrayResize( copyopentime, counter); ArrayCopy(copyopentime,opentime); for(int x=counter-1;x>=0;x--) { int latest = ArrayMaximum(copyopentime,WHOLE_ARRAY,0) ; orderarray[x]=latest; copyopentime[latest] = 0; } for(int x=counter-1;x>=0;x--) { int pos = orderarray[x]; if(profit[pos]<0) consecutive_loss++; else break; //Print(" Profit = ",profit[pos]) ; } return(consecutive_loss); }
Hello,
i'm looking for a method in my EA to check if the last orders was in profit or loss
if the last order was in loss, i will check if the order before was in loss
so in general to say, how many loss trades in a row
does anyone have an idea about his?
i use OrderMagicNumber() and OrderComment()