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 1193
In Process
st2050
st2050

st2050

  • 1 Question
  • 3 Answers
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
st2050
Asked: December 18, 20202020-12-18T10:13:35+00:00 2020-12-18T10:13:35+00:00

How to allow trading at certain times

  • 0

Hello, dear friends.
Please suggest a solution, how can the existing Expert Advisor expertmapsarsizeoptimized programmatically allow the opening of new orders only in a certain period of time of day?
Preferably without significant changes in the code.
I broke my head how to do it beautifully.

  • 16 16 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    16 Answers

    • Voted
    • Oldest
    • Recent
    1. alexeyvik

      alexeyvik

      • 1 Question
      • 74 Answers
      • 0 Best Answers
      • 172 Points
      View Profile
      alexeyvik
      2020-12-18T10:15:02+00:00Added an answer on December 18, 2020 at 10:15 am

      operlay:

      example of the adviser’s work from 11 to 12 days.

      if from 11 to 12 and from 15 to 16

      replace 

      Read about conditional operators

      Oh, my God!!! help me pass by in silence…

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

      operlay

      • 0 Questions
      • 1 Answer
      • 0 Best Answers
      • 22 Points
      View Profile
      operlay
      2020-12-22T07:02:00+00:00Added an answer on December 22, 2020 at 7:02 am

      example of the adviser’s work from 11 to 12 days.

      //+------------------------------------------------------------------+
      //|                                     restrictionTimeOperation.mq4 |
      //|                        Copyright 2019, MetaQuotes Software Corp. |
      //|                                             |
      //+------------------------------------------------------------------+
      #property copyright "Copyright 2019, MetaQuotes Software Corp."
      #property link      "
      #property version   "1.00"
      #property strict
      #property indicator_chart_window
      //+------------------------------------------------------------------+
      //| Custom indicator initialization function                         |
      //+------------------------------------------------------------------+
      int OnInit()
        {
      //--- indicator buffers mapping
        
      //---
         return(INIT_SUCCEEDED);
        }
      //+------------------------------------------------------------------+
      //| Custom indicator iteration function                              |
      //+------------------------------------------------------------------+
      int OnCalculate(const int rates_total,
                      const int prev_calculated,
                      const datetime &time[],
                      const double &open[],
                      const double &high[],
                      const double &low[],
                      const double &close[],
                      const long &tick_volume[],
                      const long &volume[],
                      const int &spread[])
        {
      //---
         MqlDateTime mqldt;
         if (mqldt.hour >= "11" && mqldt.hour <= "12") {
      //your code
            Alert("startTick; 11 Hour");
         }
      //--- return value of prev_calculated for next call
         return(rates_total);
        }

      if from 11 to 12 and from 15 to 16

      replace 

        if ((mqldt.hour >= "11" && mqldt.hour <= "12") ||
             (mqldt.hour >= "15" && mqldt.hour <= "16")
      ) {
      //your code
            Alert("startTick; 15 Hour/");
         }

      Read about conditional operators

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

      anatoli_51

      • 0 Questions
      • 1 Answer
      • 0 Best Answers
      • 22 Points
      View Profile
      anatoli_51
      2020-12-22T07:01:28+00:00Added an answer on December 22, 2020 at 7:01 am

      hello tell me how to enter the time of permission to trade in this adviser flat adviser and turn off the time of the london and american trading session was very good thank you to everyone who will help

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

      vladon

      • 0 Questions
      • 13 Answers
      • 0 Best Answers
      • 46 Points
      View Profile
      vladon
      2020-12-22T07:02:00+00:00Added an answer on December 22, 2020 at 7:02 am

      lazarev-d-m:

      a few modifications and everything works again

      I used this method in my program in general

       

      the main thing is that it works for you, I just noticed

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

      st2050

      • 1 Question
      • 3 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      st2050
      2020-12-18T10:14:41+00:00Added an answer on December 18, 2020 at 10:14 am

      to sergeev

      Thanks. further implementation is clear.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    6. lazarev-d-m

      lazarev-d-m

      • 0 Questions
      • 2 Answers
      • 0 Best Answers
      • 24 Points
      View Profile
      lazarev-d-m
      2020-12-22T07:02:00+00:00Added an answer on December 22, 2020 at 7:02 am

      Vladon:

      and if the end of the period= 2 and the beginning of the period=22

      ???

      then your code is not correct 

      if (mqldt.hour>=22||mqldt.hour>=0&&mqldt.hour<=2)
      {
      //your code
      }

      a few modifications and everything works again

      I used this method in my program in general

      if (
      (mqldt.day_of_weak==1&&mqldt.hour==1&&mqldt.min>=0&&mqldt.min<=10) | /
      ...
      //there are 20-50 such conditions for each pair
      ...
      (mqldt.day_of_weak==5& & mqldt. hour==16&&mqldt. min>=>0&&mqldt. min<=10)
      )
      {
      //code
      }

       

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

      sergeev

      • 0 Questions
      • 8 Answers
      • 0 Best Answers
      • 36 Points
      View Profile
      sergeev
      2020-12-22T07:02:00+00:00Added an answer on December 22, 2020 at 7:02 am

      st2050:

      The order is opened not in the Expert Advisor file itself, but in the includeexpertexpert.mqh module.

      if you even know where the opening occurs, what prevents you from inserting it here?

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

      st2050

      • 1 Question
      • 3 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      st2050
      2020-12-18T10:14:22+00:00Added an answer on December 18, 2020 at 10:14 am

      to sergeev:

      The Expert Advisor expertmapsarsizeoptimized. mq5 is available in the standard set of the MT5 terminal. It can be seen in the navigator (Expert Advisors>Advisors), it is located in the mql5expertsadvisors folder.

      If necessary, I will post the text. 

      The order is opened not in the Expert Advisor file itself, but in the includeexpertexpert.mqh module. However, the code of trailing stop is in the module IncludeExpertTrailingTrailingParabolicsar.mqh. Thus, the code is scattered in different files.

      Therefore, the question was: how to modify the adviser beautifully and effectively.

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

      vladon

      • 0 Questions
      • 13 Answers
      • 0 Best Answers
      • 46 Points
      View Profile
      vladon
      2020-12-22T07:02:00+00:00Added an answer on December 22, 2020 at 7:02 am

      lazarev-d-m:

      My Expert Advisor is based on trading at a certain time

      after #include #property (at the beginning of the code), insert

      in your main function OnTimer/onTick after curly brackets insert this

      next, insert all the working code inside this

      thus, the expert advisor will work only at a certain time, the only drawbacks are that you can skip some event, so it is more convenient to push not all the code inside the if statement, but only the part that is responsible for opening an order

      and if the end of the period= 2 and the beginning of the period=22

       

      ???

       

      then your code is not correct 

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    10. lazarev-d-m

      lazarev-d-m

      • 0 Questions
      • 2 Answers
      • 0 Best Answers
      • 24 Points
      View Profile
      lazarev-d-m
      2020-12-22T07:02:01+00:00Added an answer on December 22, 2020 at 7:02 am

      My Expert Advisor is based on trading at a certain time

      after #include #property (at the beginning of the code), insert

      mqldatetime mqldt;in your main function OnTimer/onTick, insert thisTimeCurrent(mqldt) after curly brackets);

      next, insert all the working code inside this

      OnTimer
      {
      if (mqldt.hour>=>"period start"& & mqldt. hour>=>"period end"
      {
      //your code
      }
      }
      thus, the EA will only work at a certain time, the only drawback is that you can skip some event, so it is more convenient to push not the entire code inside the if statement, but only the part that is responsible for opening an order

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

      sergeev

      • 0 Questions
      • 8 Answers
      • 0 Best Answers
      • 36 Points
      View Profile
      sergeev
      2020-12-22T07:02:01+00:00Added an answer on December 22, 2020 at 7:02 am

      st2050:

      The question was how to modify this particular Expert Advisor with its specific text.

      ??? neither the adviser nor the text has not been seen.  therefore, this is a purely theoretical bazaar.

      Comrades, I know how to open an order at a certain time.

      so what’s the matter? open it.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    12. st2050

      st2050

      • 1 Question
      • 3 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      st2050
      2020-12-18T10:14:02+00:00Added an answer on December 18, 2020 at 10:14 am

      Comrades, I know how to open an order at a certain time.

      The question was how to modify this particular Expert Advisor with its specific text. It’s not all that obvious.

      As for the offer of GODZILLA (by the way, thank you so much for your posts), will not the modification of the order be prohibited in this case? I only need to block the opening of new ones.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    13. godzilla

      godzilla

      • 0 Questions
      • 6 Answers
      • 0 Best Answers
      • 32 Points
      View Profile
      godzilla
      2020-12-22T07:02:01+00:00Added an answer on December 22, 2020 at 7:02 am

      st2050:

      Hello, dear friends.

      Please suggest a solution, how can the existing Expert Advisor expertmapsarsizeoptimized programmatically allow the opening of new orders only in a certain period of time of day?

      Preferably without significant changes in the code.

      I broke my head how to do it beautifully.

      Well, redo my function a little and that’s it!

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    14. abolk

      abolk

      • 0 Questions
      • 3 Answers
      • 0 Best Answers
      • 26 Points
      View Profile
      abolk
      2020-12-22T07:01:26+00:00Added an answer on December 22, 2020 at 7:01 am

      Yedelkin:
       “How to allow trading at a certain time” is very simple. Prohibit sending requests at certain times. Type if(date=date) return; 

      a small clarification “<=”.

      usually when they say ” prohibit trading from 8:00 to 12:00 – they mean “allow from 12:00”.

       

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    15. yedelkin

      yedelkin

      • 0 Questions
      • 1 Answer
      • 0 Best Answers
      • 22 Points
      View Profile
      yedelkin
      2020-12-22T07:02:01+00:00Added an answer on December 22, 2020 at 7:02 am

      st2050:  

       “How to allow trading at a certain time” is very simple. Prohibit sending requests at certain times. Type if(date

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    16. sergeev

      sergeev

      • 0 Questions
      • 8 Answers
      • 0 Best Answers
      • 36 Points
      View Profile
      sergeev
      2020-12-22T07:02:02+00:00Added an answer on December 22, 2020 at 7:02 am

      st2050:

      Hello, dear friends.

      Please suggest a solution, how can the existing Expert Advisor expertmapsarsizeoptimized programmatically allow the opening of new orders only in a certain period of time of day?

      Preferably without significant changes in the code.

      I broke my head how to do it beautifully.

      if (Current hour >= required start & & current hour < required completion )

      {

      // open an order

      }

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

    Users

    Leonardcig

    Leonardcig

    • 0 Questions
    • 0 Answers
    DennisByday

    DennisByday

    • 0 Questions
    • 0 Answers
    Haroldmeary

    Haroldmeary

    • 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