datetime time = iTime(NULL,0,0); double yclose = iClose(_Symbol,PERIOD_D1,1); double yhigh = iHigh(_Symbol,PERIOD_D1,1); double ylow = iLow(_Symbol,PERIOD_D1,1); double pivot = MathAbs((yhigh + ylow + yclose)/3); double S1 = MathAbs(2 * pivot - yhigh); double S2 = MathAbs(pivot - (yhigh - ylow));
None of those variables are changing. assign the variables in OnStart.for(order = 0; order <= OrdersTotal() - 1; order++) { ... bool closed = OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,clrRed);
In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading) you must count down when closing/deleting/modifying in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forumbool pivotstop = OrderModify(OrderTicket(), OrderOpenPrice(), pivot, OrderTakeProfit(),0);
Check your return codes (OrderModify and OrderSelect) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
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
What Im trying to get my EA to do is move the stop to each previous pivot as price moves into profit but without being slowly trailed.
I can get EA to move stop to pivot when Ask <= S1 with one basic if statement but problem is I cant get it to move on to the next if statement when Ask <= S2. It doesn't read the next OrderModify () function.
I guess its because they are both clashing as both Ask <= S1 and Ask <= S2 are true.