Buystop and Sellstop EA

 

Hi guys

So I have an EA that I am trying to code and half of it works. Only the buystop opens but not the sellstop, and it seems like a simple fix but i cant wrap my head around it. please help

Here is my code:

input double    Lotsizeforbuy = 0.10;

input int Distancebuy = 500;


input double    Lotsizeforsell = 0.10;

input int Distancesell = 500;


void OnTick()

  {

//+------------------------------------------------------------------+

if (OrdersTotal()==0) //if we have no open positions or orders

//+------------------------------------------------------------------+

int buyticket = OrderSend  //send a pending buy order

(

Symbol(), //Currency pair

OP_BUYSTOP, //set a buystop

Lotsizeforbuy, //lot size

(Ask+(Distancebuy*_Point)), //200 point above the ASK price

3, //3 pips slippage

0, //no SL

0, //no TP

NULL, //no comment

0, //No ID Number

0, //no expiration date

Green //set arrow colour

);

//+------------------------------------------------------------------+ 

//send a pending sell order

int sellticket = OrderSend 

(

Symbol(), //Currency pair

OP_SELLSTOP, //set a sellstop

Lotsizeforsell, //lot size

(Bid+(Distancesell*_Point)), //200 point above the BID price

3, //3 pips slippage

0, //no SL

0, //no TP

NULL, //no comment

0, //No ID Number

0, //no expiration date

Red //set arrow colour

); 

//+------------------------------------------------------------------+ 

  }

 
  1. Why did you post your MT4 question in the 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? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  3. Taariq Gamieldien: Only the buystop opens but not the sellstop, a
    A SellStop price must be below the market.
              Example of a buy limit and a buy stop? - General - MQL5 programming forum #1 (2020)