Buy stop

 

Hello friends please if anyone can help me i need to change this execution order to buy stop order.


trade.PositionOpen(_Symbol, RDER_TYPE_BUY,InpLots,last,Tick.ask,sl,tp,Tradecomment);

 
To change the execution order to a buy stop order you need to modify the  OrderSend  function parameters accordingly. 
// Define the price for the buy stop order
double buyStopPrice = NormalizeDouble(Tick.ask + Distance * _Point, _Digits);

// Place a buy stop order
trade.PositionOpen(_Symbol, ORDER_TYPE_BUY_STOP, InpLots, buyStopPrice, 0, sl, tp, TradeComment);
  • ORDER_TYPE_BUY_STOP  is used to specify a buy stop order.
  • buyStopPrice  is calculated based on the current ask price ( Tick.ask ) plus a specified distance ( Distance ) in points.
  • NormalizeDouble  is used to ensure the price is correctly formatted.
  • The  OrderSend  function is replaced with  trade.PositionOpen  to open a buy stop order at the calculated price.
For more detailed guidance you can explore https://www.mql5.com/en/articles/100

Good luck with your coding!
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
  • www.mql5.com
The Expert Advisors programming in MQL5 is simple, and you can learn it easy. In this step by step guide, you will see the basic steps required in writing a simple Expert Advisor based on a developed trading strategy. The structure of an Expert Advisor, the use of built-in technical indicators and trading functions, the details of the Debug mode and use of the Strategy Tester are presented.
 
Oleksandr Medviediev #:
To change the execution order to a buy stop order you need to modify the  OrderSend  function parameters accordingly. 
  • ORDER_TYPE_BUY_STOP  is used to specify a buy stop order.
  • buyStopPrice  is calculated based on the current ask price ( Tick.ask ) plus a specified distance ( Distance ) in points.
  • NormalizeDouble  is used to ensure the price is correctly formatted.
  • The  OrderSend  function is replaced with  trade.PositionOpen  to open a buy stop order at the calculated price.
For more detailed guidance you can explore https://www.mql5.com/en/articles/100

Good luck with your coding!

Hello sir it is not work, I got many errors

 

You find all you need on your pc!

Just open ..\MQL5\Include\Trade\Trade.mqh

and search (Ctrl+F) for: "CTrade::BuyStop" and study the code

 
Carl Schreiber #:

You find all you need on your pc!

Just open ..\MQL5\Include\Trade\Trade.mqh

and search (Ctrl+F) for: "CTrade::BuyStop" and study the code

I can't it is too hard for me.

 
Bash123456 #:

I can't it is too hard for me.

Then learn to search, because there is practically nothing that has not already been programmed for MT4/MT5!
    => Search in the articles: https://www.mql5.com/en/articles
    => Search in the codebase: https://www.mql5.com/en/code
    => Search in general: https://www.mql5.com/en/search or via Google with: "site:mql5.com .." (forgives typos and variants)
BTW If you place the cursor on an MQL function and press F1, you will see the reference directly, many with examples to copy and paste - the fastest form to code!

Or you order you program here: https://www.mql5.com/en/job

MQL5 Articles
MQL5 Articles
  • www.mql5.com
MQL5 Programming Articles
 
Bash123456 #: I can't it is too hard for me.

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Try asking at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.
              I need HEEEELP, please, it's URGENT...really ! - General - MQL5 programming forum (2017)

  4. Or pay (Freelance) someone to code it. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2019)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help (2017)

Reason: