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 5684
Next
In Process
galina_bobro
galina_bobro

galina_bobro

  • 1 Question
  • 1 Answer
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
galina_bobro
Asked: December 29, 20202020-12-29T10:01:05+00:00 2020-12-29T10:01:05+00:00In: Forex Expert Advisors

Re-opening the position…

  • 0

Something I’m missing, however, just the code is already familiar probably. 
In general, there is an Expert Advisor on MT5 that should open only one position on a signal. This is checked by the function: 
void Fn_pos_find_market(ulong &tic1, ulong &tic2, int magic){
   tic1=0; tic2=0; 
   datetime time1 = 0, time2 = 0; 
   for(int i=0; i      ulong tic= PositionGetTicket(i);
      if(tic<=0) continue; 
      if(!PositionSelectByTicket(tic)) continue; 
      if(PositionGetString (POSITION_SYMBOL)!=_Symbol) continue; 
      if(PositionGetInteger(POSITION_MAGIC)!=magic)    continue; 
      if  (tic1==0) { tic1=tic; time1=(datetime)PositionGetInteger(POSITION_TIME);}
      else          { tic2=tic; time2=(datetime)PositionGetInteger(POSITION_TIME);}
      if(tic1>0 && tic2>0) break;}
   if(time2>0 && time1>time2){ulong t=tic1; tic1=tic2; tic2=tic1;}}
Looking for 2 positions because there is still topping (ie, and looking for, and check if the position immediately) but not so important. 
Here is the code at the beginning of the function that opened: 
ulong t1, t2; Fn_pos_find_market(t1, t2, inp_magic);
if(t1>0 || t2>0) return(false);
The log clearly shows that the opening of the signal was 2 times with a difference of about 20ms (the message in the log writes when opening). At the time of execution of the second request, it is clear that the first one has already been executed (I sin that the broker may not have accepted it yet) They say that this happens when the volatility is increased. 
According to the log (at 16: 00: 03 one transaction and 16: 00: 23 immediately another, the campaign for the next tick)
IP 0 16:00:03.884 Trades ‘15014283’: deal #1002308647 sell 0.02 USDJPY at 110.391 done (based on order #1003181634)
CN 0 16:00:03.885 Trades ‘15014283’: order #1003181634 sell 0.02 / 0.02 USDJPY at 110.391 done in 151.690 ms
—–
LO 0 16:00:23.083 Trades ‘15014283’: market sell 0.02 USDJPY sl: 110.445 tp: 108.510
CP 0 16:00:23.087 Trades ‘15014283’: accepted market sell 0.02 USDJPY sl: 110.445 tp: 108.510
EE 0 16:00:23.147 Trades ‘15014283’: deal #1002308940 sell 0.02 USDJPY at 110.352 done (based on order #1003181963)
JK 0 16:00:23.148 Trades ‘15014283’: order #1003181963 sell 0.02 / 0.02 USDJPY at 110.352 done in 64.595 ms
Or check not positions,but trades…

  • 2 2 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    2 Answers

    • Voted
    • Oldest
    • Recent
    1. galina_bobro

      galina_bobro

      • 1 Question
      • 1 Answer
      • 0 Best Answers
      • 20 Points
      View Profile
      galina_bobro
      2020-12-29T10:01:16+00:00Added an answer on December 29, 2020 at 10:01 am

      fxsaber:

      This is an extra line.

      The problem seems to be caused by this bug

      Thank you very much for the idea, it would take me a very long time to get to this

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

      fxsaber

      • 1 Question
      • 57 Answers
      • 0 Best Answers
      • 140 Points
      View Profile
      fxsaber
      2020-12-29T10:01:11+00:00Added an answer on December 29, 2020 at 10:01 am

      Galina Bobro:

            if(!PositionSelectByTicket(tic)) continue; 

      This is an extra line.

      The problem seems to be caused by this bug

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

      Libraries: mt4orders

      fxsaber, 2017.07.24 23:39

      When OrderSend was not synchronized with the trading environment of the terminal, automatic synchronization was built into mt4orders.

      After a while, the developers built in synchronization and the old synchronization code was left in the library with a small exception – it began not only to synchronize, but also to check whether the synchronization of OrderSend from the developers works correctly. In case of an error, an alert should pop up

          if (MT4ORDERS::OrderSendBug)
          {
            Alert("BUG!!!!!!");

      There were reports that this Alert is triggered in rare cases (it seems, when the CPU is loaded), signaling that the OrderSend of developers is bad in matters of synchronization with the trading environment. How to report this to the developer in the SD-I do not know, because I can not reproduce it. But the fact remains.

      • 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 521
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 706
    • 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

    • savinkins

      Getting data by the indicator from another indicator on a ...

      • 6 Answers
    • fresto

      Error opening the OptimOne file error: 5004

      • 2 Answers
    • asot650

      You need to write an Expert Advisor on the indicator

      • 4 Answers
    • miron_like

      Translation to mql5

      • 1 Answer
    • dynamiteman

      Script for commenting on an MT4 or MT5 trade

      • 2 Answers

    Users

    Brianacink

    Brianacink

    • 0 Questions
    • 0 Answers
    asot650

    asot650

    • 1 Question
    • 2 Answers
    investr777

    investr777

    • 1 Question
    • 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