need error fixing in my EA

 

I have an EA according to my requirements but When I run it on my live account it shows a little difference in parameters set and actual trade. It set different SL and TP. I set SL 10 and TP 12 pip but it open trade with SL and TP both 12 pip. If I add another pair the SL and TP of other pair is more different i.e 15 pip SL and 15 pip TP.
Please fix it for me if you can. Source file is attached. Also, see attachment for details. TP and SL are set 10 and 12 while EA put tp and sl 30 pip away.
Please fix it for me and send me file at laksahib@gmail.com. I will be thankful to you.

Files:
 
laksahib:

I have an EA according to my requirements but When I run it on my live account it shows a little difference in parameters set and actual trade. It set different SL and TP. I set SL 10 and TP 12 pip but it open trade with SL and TP both 12 pip. If I add another pair the SL and TP of other pair is more different i.e 15 pip SL and 15 pip TP.
Please fix it for me if you can. Source file is attached. Also, see attachment for details. TP and SL are set 10 and 12 while EA put tp and sl 30 pip away.
Please fix it for me and send me file at laksahib@gmail.com. I will be thankful to you.

Remember, levels close in profit and loss include the spread.

I make some change in code to fix some errors.

Try this version.

Files:
 
Nikolaos Pantzos: Try this version.
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Do not assume history has only closed orders.
    Do not assume history is ordered by date, it's not.
              Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum

  3. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11

    Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11

  4.          if(sendorder(OP_BUY,mylot(),    // we send our buy order into
                          Ask,Bid-StopLoss*pt,         // broker's server then we out
                          Ask+TakeProfit*pt,           // from this cycle to avoid
                          Blue)>0)
    
    You buy at the Ask and sell at the Bid.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

 
William Roeder:
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Do not assume history has only closed orders.
    Do not assume history is ordered by date, it's not.
              Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum

  3. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11

    Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11

  4. You buy at the Ask and sell at the Bid.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

Hello,

you' are right, but this thread not opened by me.

Reason: