English

## Help please Highest between 2 levels ....

 17 jeef_1985 2016.08.19 14:31   Hi , I work on EA and I block and I hope your helphow to find the maximun price between the point where it hit take profit level  and the stop loss level as shown in the picturethank you very much
 1229 FMIC 2016.08.19 14:41 #   You will need to use the functions iHighest() / iLowest() and maybe even iBarShift() depending on how your code is structured.
 17 jeef_1985 2016.08.19 17:15 #   yes indeed but how, here is what I dofirst  function to find the time cross up TP, the secondis to find the time of cross Down SL and 2 functions iBarShift and iHighest , but it didnt workThank you for your help     ``` datetime ShiftTP(){           double TP ;      int Total = OrdersTotal()-1 ;       for(int i = Total ; i >= 0 ; i--){        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))          if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic && OrderType()==OP_BUY)          TP = OrderTakeProfit() ;            for(i=1;i<=ibars;i++)             {                if(Open[i]TP)return(Time[i]);              }         }        return 0 ;    }`````` datetime ShiftSL(){           double SL ;      int Total = OrdersTotal()-1 ;       for(int i = Total ; i >= 0 ; i--){        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))          if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic && OrderType()==OP_BUY)          SL = OrderStopLoss() ;            for( i=1;i<=ibars;i++)             {                if(Open[i]>SL&&Close[i]
 1229 FMIC 2016.08.19 17:44 #   jeef_1985: yes indeed but how, here is what I dofirst  function to find the time cross up TP, the secondis to find the time of cross Down SL and 2 functions iBarShift and iHighest , but it didnt workThank you for your helpYour code makes has many bugs:You are reusing the variable "i" for both loops, thus the second loop will mess-up the first one.If you already are able to get the "shift" in your functions, why get the "time", only to convert it back into a "shift" again.Why are are looping through the orders, without any idea of which order you will pick up first? Remember that there is no clear "ordering sequence" in the order history.Why search the order history twice in the separate TP and SL functions. First search for the order you want, and then look for when the prices were hit.Don't just search all the bars. The Order already has an open time and/or close time, that you can use to know how far back to go (and no more).
 17 jeef_1985 2016.08.19 21:45 #   functions  one and two returs the  times of the crossup and down of levelsiBarshift function parameter needs the time to find the index of chandeles that will reuse for iHighest function. I can not do better ... help if possible thank you ```datetime ShiftTP(){           double TP ;      int Total = OrdersTotal()-1 ;       for(int i = Total ; i >= 0 ; i--){        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))          if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic && OrderType()==OP_BUY)          TP = OrderTakeProfit() ;                 if(Open[1]TP)return(Time[1]);                      }        return 0 ;    }```
 13009 WHRoeder 2016.08.20 15:08 #   jeef_1985: iBarshift function parameter needs the time to find the index of chandeles that will reuse for iHighest function. I can not do better ...To get the time you already must have the shift. No need for the time and iBarShift, you already have it. Yes you can do better.``` int      shifttp=iBarShift(Symbol(),0,ShiftTP()); int      shiftsl=iBarShift(Symbol(),0,ShiftSL()); double   Highest = High[iHighest(Symbol(),0,shifttp,shiftsl)] ;```iHighest is not symbol, period, from, to, (or "to, from,") it is length, from. You must compute the length and the lowest shift.
 17 jeef_1985 2016.08.21 17:45 #   thank you sir : WHRoederthank you sir : FMIC    i'lle try to solve the problem