You will need to use the functions iHighest() / iLowest() and maybe even iBarShift() depending on how your code is structured.
yes indeed but how, here is what I do
first 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 work
Thank 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&&Close[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]<SL)return(Time[i]); } } return 0 ; }
int shifttp=iBarShift(Symbol(),0,ShiftTP()); int shiftsl=iBarShift(Symbol(),0,ShiftSL()); double Highest = High[iHighest(Symbol(),0,shifttp,shiftsl)] ;
jeef_1985:
yes indeed but how, here is what I do
first 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 work
Thank you for your help
Your 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).
functions one and two returs the times of the crossup and down of levels
iBarshift 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&&Close[1]>TP)return(Time[1]); } return 0 ; }
- 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.

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
Hi ,
I work on EA and I block and I hope your help
how to find the maximun price between the point where it hit take profit level and the stop loss level
as shown in the picture
thank you very much