fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Is it possible to change the used time-frame using input parameters (in blocks)?

    Questions & Answers
    4
    8
    4534
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Abade69
      Abade69 last edited by

      I think this may be asked a lot.

      Sometimes i need to create EA's that use multiple-timeframes but need the parameters to be editable to prevent duplication (and excessive work). This would add a lot of flexibility for creation AND for testing/optimization.

      0_1522874777511_10.png

      A view from one of my projects to demonstrate how big it can get without this option:

      https://fxdreema.com/builder/shared/YUoEVLcvb

      Thanks in advance 🙂

      1 Reply Last reply Reply Quote 1
      • M
        miro1360 last edited by

        this into inputs (string Timeframes is only for info) :

        0_1522875030412_edf1c788-ada0-4774-b363-13823bcc3329-image.png

        this into variables:
        0_1522875080609_9e961250-e5f9-4e15-b0ca-aff29a3ac94b-image.png

        in on Init:
        0_1522875104801_44a454a1-d7c1-4118-afc1-45a68bc158a2-image.png
        if(TF_input == 0) { TF_used = 0; } //current
        if(TF_input == 1) { TF_used = 1; } //M1
        if(TF_input == 2) { TF_used = 5; } //M5
        if(TF_input == 3) { TF_used = 15; } //M15
        if(TF_input == 4) { TF_used = 30; } //M30
        if(TF_input == 5) { TF_used = 60; } //H1
        if(TF_input == 6) { TF_used = 240; } //H4
        if(TF_input == 7) { TF_used = 1440; } //D1
        if(TF_input == 😎 { TF_used = 10080; } //W1

        in on Tick:
        0_1522875146822_39fc95d8-2448-44c4-863d-90e9191efbbc-image.png
        (just use variable for timeframe)

        this technique can be used also for other specific parameters where optimization and its static increment is not enough (different periods - like 13, 34, 82)

        Between trading and gambling is a very small gap, be careful.

        Abade69 1 Reply Last reply Reply Quote 2
        • Abade69
          Abade69 @miro1360 last edited by

          @miro1360 I right clicked the time-frame menu and WHOA! The variable menu appeared (feel so dumb now xD).

          So if i understand correctly the variable used needs to be int and ranges from 0 to 8 for each time-frame, is this the same for MQ5?

          1 Reply Last reply Reply Quote 0
          • M
            miro1360 last edited by

            for MQ5 you should change few things:

            variable type TF_used is ENUM_TIMEFRAMES
            and definitions are from this enum list: https://www.mql5.com/en/docs/constants/chartconstants/enum_timeframes

            0_1522893126963_6ffa6296-fe53-4de3-b6fb-cdde383547bd-image.png

            Between trading and gambling is a very small gap, be careful.

            Abade69 1 Reply Last reply Reply Quote 0
            • Abade69
              Abade69 @miro1360 last edited by

              @miro1360 Nice, this is exactly what i was looking for, you have my many thanks 🙂

              1 Reply Last reply Reply Quote 0
              • fxDreema
                fxDreema last edited by

                But wait, what about this block 0_1523048009729_478dd558-7ac2-4c48-bf63-be205d1b87c8-image.png

                Abade69 1 Reply Last reply Reply Quote 0
                • Abade69
                  Abade69 @fxDreema last edited by

                  @fxdreema Nice, this could be used to gather information from various time-frames without cloning blocks 😄

                  1 Reply Last reply Reply Quote 0
                  • V
                    vitgtw last edited by

                    Trying to find a solution to my prob and i see this.... Very nice job miro, tyvm.

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post

                    Online Users

                    N
                    L
                    A
                    M
                    B
                    E
                    S
                    M

                    23
                    Online

                    146.6k
                    Users

                    22.4k
                    Topics

                    122.6k
                    Posts

                    Powered by NodeBB Forums | Contributors