Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

First independent community of traders

First independent community of traders Logo First independent community of traders Logo

First independent community of traders Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • Buy Theme
  • Home
  • About Us
  • Blog
  • Contact Us
Home/ Questions/Q 6336
Next
In Process
miron_like
miron_like

miron_like

  • 4 Questions
  • 6 Answers
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
miron_like
Asked: January 27, 20212021-01-27T07:18:40+00:00 2021-01-27T07:18:40+00:00In: Forex Expert Advisors

Opening an order in the opposite direction

  • 0

Please tell me, when closing an order for StopLoss, I need to open an order in the opposite direction with the same parameters, but once. I.e. if the first order was closed for SL, then for subsequent closed orders for SL, do not open an order in the opposite direction.

  • 11 11 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    11 Answers

    • Voted
    • Oldest
    • Recent
    1. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2021-01-27T07:20:01+00:00Added an answer on January 27, 2021 at 7:20 am

      miron_like:

      Please tell me, what can I do based on my code, so as not to rewrite it?

      No, you can’t.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. miron_like

      miron_like

      • 4 Questions
      • 6 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      miron_like
      2021-01-27T07:19:55+00:00Added an answer on January 27, 2021 at 7:19 am

      Vladimir Karputov:

      To get started, just take an example and remove all the extra stuff – what you don’t need.

      Please tell me, what can I do based on my code, so as not to rewrite it?

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. nektomk

      nektomk

      • 2 Questions
      • 38 Answers
      • 0 Best Answers
      • 92 Points
      View Profile
      nektomk
      2021-01-27T07:19:49+00:00Added an answer on January 27, 2021 at 7:19 am

      miron_like:
      Please tell me, when closing an order for StopLoss, I need to open an order in the opposite direction with the same parameters, but once. I.e. if the first order was closed for SL, then for subsequent closed orders for SL, do not open an order in the opposite direction.

      instead of (together) SL, enter a pending order with the same (or different) parameters, at the desired level. By the way, SL is not allowed everywhere, and in general, you should forget about such order parameters as TakeProfit and StopLoss – treat them as independent transactions and happiness will remain.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    4. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2021-01-27T07:19:43+00:00Added an answer on January 27, 2021 at 7:19 am

      miron_like:

      I looked at your example. Frankly speaking, while there is not enough knowledge to fully understand it and then write it as it should. 

      Can you tell me how to implement this task based on this code?

      To get started, just take an example and remove all the extra stuff – what you don’t need.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    5. miron_like

      miron_like

      • 4 Questions
      • 6 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      miron_like
      2021-01-27T07:19:32+00:00Added an answer on January 27, 2021 at 7:19 am

      Vladimir Karputov:

      No, it’s not right. You caught a transaction with the TRADE_TRANSACTION_DEAL_ADD type – this is adding a transaction to the history, please note that there is no mention of an order here. Forget about the orders. There are only positions.

      Next, see that the transaction must have the DEAL_REASON_SL property – again, the transaction, orders do not even smell.

      Now it remains to open a position:

      To begin with, just write the code in which it opens a position after you find the trade that appeared as a result of the Stop loss trigger – then, when I see your code, I will tell you further.

        if (Total==0 && Opn_B==true){
         TP=Bid + SizeTP*Point;
         SL=Bid - SizeSL*Point;
         Ticket=OrderSend(Symbol(),OP_BUY,Lts,Ask,5,SL,TP,NULL,0,0,clrBlue);
         if (Ticket > 0){
          if(!OrderSelect(Ticket)){
           //Opening a position in the opposite direction with the same parameters
          }
         }
        }

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    6. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2021-01-27T07:19:25+00:00Added an answer on January 27, 2021 at 7:19 am

      miron_like:

      And so the code in its full form looks right?

      …

      No, it’s not right. You caught a transaction with the TRADE_TRANSACTION_DEAL_ADD type – this is adding a transaction to the history, please note that there is no mention of an order here. Forget about the orders. There are only positions.

      Next, see that the transaction must have the DEAL_REASON_SL property – again, the transaction, orders do not even smell.

      Now it remains to open a position:

      Forum on trading, automated trading systems and testing of trading strategies

      Opening an order in the opposite direction

      Vladimir Karputov, 2017.07.27 14:05

      And for an example of opening a position (namely, a position, and not placing a pending order), see the same code that I gave (the OpenBuy and OpenSell functions).

      To begin with, just write the code in which it opens a position after you find the trade that appeared as a result of the Stop loss trigger – then, when I see your code, I will tell you further.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    7. miron_like

      miron_like

      • 4 Questions
      • 6 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      miron_like
      2021-01-27T07:19:10+00:00Added an answer on January 27, 2021 at 7:19 am

      prostotrader:

      Make a check for the existence of an order

      a little misunderstood, i.e. it should look like this?

      long     deal_reason       =-1;
      deal_reason=HistoryDealGetInteger(trans.deal,DEAL_REASON);
      if(deal_reason==DEAL_REASON_SL){
        if(!OrderSelect(ticket)){
          //Opening an order
        }
      }

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    8. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2021-01-27T07:19:04+00:00Added an answer on January 27, 2021 at 7:19 am

      miron_like:

      long     deal_reason       =-1;
      deal_reason=HistoryDealGetInteger(trans.deal,DEAL_REASON);
      if(deal_reason==DEAL_REASON_SL)
      and here is what I need...

      Am I right?”

      Yes. That’s right.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    9. prostotrader

      prostotrader

      • 0 Questions
      • 18 Answers
      • 0 Best Answers
      • 60 Points
      View Profile
      prostotrader
      2021-01-27T07:18:58+00:00Added an answer on January 27, 2021 at 7:18 am

      miron_like:

      Can you tell me how to open an order in the opposite direction? And only once, and not every time when closing an order for SL

      Make a check for the existence of an order

      if(!OrderSelect(ticket))
      {
      //Setting an order
      }

      Added

      In fact, everything is a little more complicated, to answer unambiguously, you need to see the code…

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    10. miron_like

      miron_like

      • 4 Questions
      • 6 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      miron_like
      2021-01-27T07:18:51+00:00Added an answer on January 27, 2021 at 7:18 am

      Vladimir Karputov:

      Example of how to catch a 100% guaranteed trade as a result of triggering the Stop Loss code Stop Loss Take Profit – in OnTradeTransaction, catch a trade that is closed as a result of the Stop loss trigger (the DEAL_REASON_SL property of the trade). 

      After you have caught a closed trade as a result of the Stop Loss trigger, you can already do what you need.

      Can you tell me how to open an order in the opposite direction? And only once, and not every time when closing an order for SL

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    11. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2021-01-27T07:18:44+00:00Added an answer on January 27, 2021 at 7:18 am

      miron_like:
      Please tell me, when closing an order for StopLoss, I need to open an order in the opposite direction with the same parameters, but once. I.e. if the first order was closed for SL, then for subsequent closed orders for SL, do not open an order in the opposite direction.

      Example of how to catch a 100% guaranteed trade as a result of triggering the Stop Loss code Stop Loss Take Profit – in OnTradeTransaction, catch a trade that is closed as a result of the Stop loss trigger (the DEAL_REASON_SL property of the trade). 

      After you have caught a closed trade as a result of the Stop Loss trigger, you can already do what you need.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    Stats

    • Questions 530
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 749
    • Popular
    • Comments
    • Tags
    • forexcommunity

      Highlighting what’s important about questions & Answers on Discy Community!

      • 0 Comments
    • forexcommunity

      Introducing Keyboard Shortcuts, our first Labs feature

      • 0 Comments
    • forexcommunity

      Defining quality on Discy Engine — what a helpful answer ...

      • 0 Comments
    • forexcommunity

      Organizational and company accounts on Discy Engine the next step

      • 0 Comments
    • forexcommunity

      Hello world!

      • 0 Comments

    Related Questions

    • BrantHaps

      write my essay ndl

      • 0 Answers
    • Galengask

      write my paper qxg

      • 0 Answers
    • Johnbup

      Слоты в онлайн казино. Игровые автоматы бесплатно

      • 0 Answers
    • StephenWaibe

      Торгуйте акциями основных технологических компаний США

      • 0 Answers
    • Doublebtc-Ceact

      DoubleBTC.WIN - Double your bitcoin in 24 hours

      • 0 Answers

    Users

    Roberdraf

    Roberdraf

    • 0 Questions
    • 0 Answers
    LouisJah

    LouisJah

    • 0 Questions
    • 0 Answers
    JoshuaCrymn

    JoshuaCrymn

    • 0 Questions
    • 0 Answers

    Footer

    First independent community of traders

    About

    An independent community of forex traders. This is where traders communicate. You can ask your questions and you will receive an answer to your question.
    • Terms of Use
    • Privacy Policy
    • Cookie Policy
    • Knowledge Base
    • Support

    © 2021 Forexcommunity.net. All Rights Reserved