Download MetaTrader 5

Expert Advisor...Warning at OrderModifiy()

To add comments, please log in or register
Interested in social trading? Read the article!
akuh
52
akuh 2016.11.28 20:33 

Hello Everyone

 

Wehen i compile my ea there is a warning that there is a problem with OrderModify() but i cannot  solve what the problem is ?!

 

I would appreciate if someone could take a look at it.

 

sincerely

 

akuh 

Files:
whroeder1
14470
whroeder1 2016.11.28 21:39  
OrderModify(OrderTicket(), 0, b-TrailingStop, 0, 0, 0);

         OrderBuy();
bool OrderBuy(){
      res=OrderSend(Symbol(), 0, NormalizeDouble(Lot,1), Ask, Slippage,
      NormalizeDouble(Ask-StopLoss,4), NormalizeDouble(Ask+TakeProfit,4), 0, 0, 0, 0);

      return(res);


  res=OrderClose(Ticket, Lots, priceClose, Slippage, 0);

      SelectOnlyOrder(0);
bool SelectOnlyOrder(int pos){
   return OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
 }

  1. Check your return codes 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
  2. All of them including OrderSend or your OrderBuy, OrderClose, OrderSelect or your SelectOnlyOrder.
  3. What do you think Ask-StopLoss is? 1.01234 - 50  is a bogus price. Zero is not a valid string (comment.) Don't hard code constants, use the proper symbols
    extern double TakeProfit = 50;
    extern double TrailingStop = 25 ;
    extern double StopLoss = 50;
    extern double MinProfit = 25;
    extern double ProfitPoints;
    extern int    Slippage=2;

          res=OrderSend(Symbol(), 0, NormalizeDouble(Lot,1), Ask, Slippage,
          NormalizeDouble(Ask-StopLoss,4), NormalizeDouble(Ask+TakeProfit,4), 0, 0, 0, 0);
    Adjust for 4/5 digit brokers and JPY pairs, SL/TP and slippage.
    extern double TakeProfit = 50;
    extern double TrailingStop = 25 ;
    extern double StopLoss = 50;
    extern double MinProfit = 25;
    extern double ProfitPoints;
    extern int    Slippage=2;

    double   pip        = StringFind(_Symbol,"JPY") < 0 ? 0.01 : 0.0001;
    int      slippage   = Slippage * int(pip / _Point);

          res=OrderSend(Symbol(), OP_BUY, NormalizeLots(Lot), Ask, slippage, Ask - StopLoss * pip, Ask + TakeProfit * pips, "", 0, 0, 0);
  4. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong

akuh
52
akuh 2016.11.28 23:11  

Thank you very much for your help. I will try to Implement your advices asap.

 

Could i ask another question to an EA ? In the attached EA i want to combine the iStochastic with the supersignal indicator. Basically i want  to combine the two indicator so that a buy signal is send when an ArrowUp from the supersignals and the signal line from the stochastics occur. I tried it in the attached EA but i dont really see why it doesnt work. Sorry for the questions...im a total beginner !

 I have to ad that the EA works with either one of the indicators. But somehow the EA opens hundreds of trades at the same time although the code says (as far as i can see) to just open one trade at a time. Maybe someone sees the mistake in the code immediately.

 

best regards

 

akuh 

Files:
Mladen Rakic
15573
Mladen Rakic 2016.11.29 13:27  
akuh:

Thank you very much for your help. I will try to Implement your advices asap.

 

Could i ask another question to an EA ? In the attached EA i want to combine the iStochastic with the supersignal indicator. Basically i want  to combine the two indicator so that a buy signal is send when an ArrowUp from the supersignals and the signal line from the stochastics occur. I tried it in the attached EA but i dont really see why it doesnt work. Sorry for the questions...im a total beginner !

 I have to ad that the EA works with either one of the indicators. But somehow the EA opens hundreds of trades at the same time although the code says (as far as i can see) to just open one trade at a time. Maybe someone sees the mistake in the code immediately.

 

best regards

 

akuh 

Super signals is repainting. You will find it hard to use from an EA
To add comments, please log in or register