Hi JJjjgengis wrote:I apologize for the mistake, but the "20" must be "0.0002", or "20" must be multplied for point (20*point).jjgengis wrote:Hi fx8000,
I would suggest a little modify at the code. I noticed that often the EA doesn't fail a trade with error 130 invalid stop. This because sometimes the stoplevel of some pairs , e.g. audndz, is high and the EA set a price not far enought .
With these two rows I solved the problem:Code: Select all
//Long if (direction == up) { if (!TradeLong) return; price = NormalizeDouble(BarHigh + spread + (PlusOne * Point), Digits); if (TakeProfit > 0) take = NormalizeDouble(Ask + (TakeProfit * Point), Digits); stop = NormalizeDouble(BarLow, Digits); // ************** modify to avoid stoplevel error *********************** double stoplevelprice = Bid - NormalizeDouble(MarketInfo(Symbol(),MODE_STOPLEVEL)-20, Digits); if ( stoplevelprice < stop) stop = stoplevelprice; // ************** end modify to avoid stoplevel error *********************** type = OP_BUYSTOP; SendTrade = true; }//if (direction == up) //Short if (direction == down) { if (!TradeShort) return; price = NormalizeDouble(BarLow - spread - (PlusOne * Point), Digits); if (TakeProfit > 0) take = NormalizeDouble(Bid - (TakeProfit * Point), Digits); stop = NormalizeDouble(BarHigh, Digits); // ************** modify to avoid stoplevel error *********************** stoplevelprice = Ask + NormalizeDouble(MarketInfo(Symbol(),MODE_STOPLEVEL)+20, Digits); if ( stoplevelprice > stop) stop = stoplevelprice; // ************** end modify to avoid stoplevel error ***********************
JJ
Code: Select all
stoplevelprice = Ask + NormalizeDouble(MarketInfo(Symbol(),MODE_STOPLEVEL)+( 20 * point) , Digits);
Sorry!
JJ
No problem. I will make the correction and update the ea in post 1. The update this morning has not been downloaded by anyone yet.
Thanks again for your help.
Peter