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()
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
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 consecutive_loss; //The variable that holds the number of consecutive losses counting from the latest
//order open time (closed trades)
int counter = 0;
if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() )
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);
ArrayResize( copyopentime, counter);
int latest = ArrayMaximum(copyopentime,WHOLE_ARRAY,0) ;
copyopentime[latest] = 0;
int pos = orderarray[x];
//Print(" Profit = ",profit[pos]) ;
Thanks a lot,
how do you use it?
as indicator or as function (void) in an EA?
I actually said that it is a function
It's an integer function as it returns an integer