buy and sell stop

 

hi, can anybody tell me what's wrong with this code? only sell stop is opened

void OnTick()

  {

     // if we have no open orders or positions

     if (OrdersTotal()==0)

     // create a sell ticket

     int sellticket = OrderSend

     (

       Symbol(),       // currency pair

       OP_SELLSTOP,    // set sell stop

       0.10,           // lot size

       (Bid-50*_Point), // entry price

       3,              // slippage

       0,              // stop loss

       (Bid-80*_Point), // take profit

       NULL,

       1234,           // magic number

       0,              // expiration date

       Red);           // arrow color

      

     

    // if we have no open orders or positions

     if (OrdersTotal()==0)

     // create a buy ticket

     int buyticket = OrderSend

     (

       Symbol(),       // currency pair

       OP_BUYSTOP,     // set buy stop

       0.10,           // lot size

       (Ask+50*_Point),// entry price

       3,              // slippage

       0,              // stop loss

       (Ask+80*_Point),// take profit

       NULL,

       1234,           // magic number

       0,              // expiration date

       Green);         // arrow color

       

   }   
forex news - Trading blogs and financial markets analysis
forex news - Trading blogs and financial markets analysis
  • www.mql5.com
Forex – foreign exchange market, or currency market – is the market where one currency is traded for another. Open 24-hours a day from Sunday evening through to Friday night, it is the world's most
 
Please edit your post and
use the code button (Alt+S) when pasting code

I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
 
What happens if you remove the sellstop block ?
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2.    if (OrdersTotal()==0) int sellticket = OrderSend(…
    This if only applies to the SellStop (no brackets/braces). Once you open it, the if applying to the BuyStop will always be false.

  3. Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (strict), it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014

 
Keith Watford:
Please edit your post and
use the code button (Alt+S) when pasting code

I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.

sorry I'm just new here, thanks for the advice