Sell orders on expert advisor not working

 

Explanation from the developer: Program works by tracking a chart in external program and sending a signal through txt document. Expert in meta trader reads said file from common terminal folder and saves its content in a string variable. That part of the program worksexpert opensreadsand closes the file normallyBased on that signalexpert must enter buy or sell order with conditions set by the client which are not relevant for the working of the expertBuy orders are always executed as intendedSell orders don't work but only on client's computer regardless of account or broker usedOn computer on which the expert was developed and tested everything worksSettings on client's computer are set correctlyboth long and short positions are allowed and DLL inputs are not requiredSection of code that governs sending orders is attached below and is located in OnTick void function.

All variables are global and are defined correctly. lotSize, stopLoss, and takeProfit values are calculated based on inputs from client. Logs reports no errors

Worth noting is that client can manually enter any order and doesn't have leverage problems.

I can provide entire code if necessary.
if (BUY_SEL == "BUY")
      {
      lotSize = (AccountBalance()*riskPercentage/100)/(SL_distance*10);
      stopLoss = Ask-SL_distance*0.0001;
      takeProfit = Ask+SL_distance*Ratio*0.0001;
      ticket = OrderSend(_Symbol, OP_BUY, lotSize, Ask, 100, stopLoss, takeProfit, NULL, 12345);
      magic=12345;
      }
      else if (BUY_SEL == "SEL")
      {
      lotSize = (AccountBalance()*riskPercentage/100)/(SL_distance*10);
      stopLoss = Bid+SL_distance*0.0001;
      takeProfit = Bid-SL_distance*Ratio*0.0001;
      ticket = OrderSend(_Symbol, OP_SELL, lotSize, Bid, 100, stopLoss, takeProfit, NULL, 12345);
      magic=12345;
      }
 
mario_400:

Explanation from the developer: Program works by tracking a chart in external program and sending a signal through txt document. Expert in meta trader reads said file from common terminal folder and saves its content in a string variable. That part of the program worksexpert opensreadsand closes the file normallyBased on that signalexpert must enter buy or sell order with conditions set by the client which are not relevant for the working of the expertBuy orders are always executed as intendedSell orders don't work but only on client's computer regardless of account or broker usedOn computer on which the expert was developed and tested everything worksSettings on client's computer are set correctlyboth long and short positions are allowed and DLL inputs are not requiredSection of code that governs sending orders is attached below and is located in OnTick void function.

All variables are global and are defined correctly. lotSize, stopLoss, and takeProfit values are calculated based on inputs from client. Logs reports no errors

Worth noting is that client can manually enter any order and doesn't have leverage problems.

I can provide entire code if necessary.

this is a duplicate thread, no need for that....

your best option is to speak to the developer, you have not provided enough detail for anyone to respond, and I doubt anyone is going to be interested in debugging another developers work..

 
mario_400: All variables are global and are defined correctly. lotSize, stopLoss, and takeProfit values are calculated based on inputs from client.
      stopLoss = Ask-SL_distance*0.0001;
      takeProfit = Ask+SL_distance*Ratio*0.0001;

You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using 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 close 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 spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
    My GBPJPY shows average spread = 26 points, average maximum spread = 134.
    My EURCHF shows average spread = 18 points, average maximum spread = 106.
    (your broker will be similar).
              Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)