help with invalid stops error i dont get it

 

So i try to place an order with mql5 it gives me an error 



2020.07.10 13:25:30.158 2020.01.03 17:32:36   CTrade::OrderSend: market buy 1.00 @EP sl: 3016.35 tp: 3022.55 [invalid stops]


double SL = (Ask - 2.4);
 double PT = (Ask + 3.8);
 


if (price > above) {
   
   
   if (runningmacdsignal > 0){
      
      if (price > runningfivesma) {
      
         Print ("goin to place a trade at" + Ask);
         trade.Buy(1,NULL,Ask,SL,PT,"buying");
         
      }
      else {
      
      Print ("The price is not above the running fivesma");
      }
   }
 
double SL = (Ask - 2.4);
 double PT = (Ask + 3.8);
    1. SL/TP (stops) need to be normalized to tick size (not Point) — code fails on metals. (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 programming forum

    2. Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum

    3. Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.

  1. 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 / OrderClosePrice 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 / OrderClosePrice 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.)
      Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.

Reason: