fxDreema

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

    Simpler Way Than Using 8 Blocks?

    Questions & Answers
    2
    23
    4606
    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.
    • T
      Trader3487 last edited by

      I am using 8 "if less than n trades are running" blocks (project id: mt4-8457). Is there a simpler way to do this?

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

        If symbol parameter of every of these blocks should be the symbol specified in the Condition that is connected to it (now most of the blocks are that way, some of them are mixed), then you need only one "Less than..." block with specified market and set to empty (empty=current chart symbol).

        Also, blocks under "on Init" are executed once, right when EA is added to the chart. So there you can define constants (variables that will not change) and use them in "on Tick" without recalculate them on every tick.

        1 Reply Last reply Reply Quote 0
        • T
          Trader3487 last edited by

          only one "Less than..." block for all symbols (1 block total) or one for each symbol (8 blocks total)?

          Thanks for the tip about "on init" - that will make things a lot cleaner 🙂

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

            About "Market (empty=Current)" parameter, when it looks empty, it is:

            When chart symbol is EURUSD, this parameter is EURUSD
            When chart symbol is GBPUSD, this parameter is GBPUSD
            and the same way with any symbol

            And no "Contition" is needed above "Less than..." block.

            1 Reply Last reply Reply Quote 0
            • T
              Trader3487 last edited by

              ok great! Now last step: associating the correct trailing stop with the correct market. There are 3 different trailing stops in this ea - one for 5-decimal charts, one for 3-decimal charts, and one for 2-decimals. I tried this strategy of "Market (empty=Current)" parameter with the trailing stop also but it doesn't seem to work. If if use group #s then I need to duplicate the buy/sell blocks 3 times. I'm testing this out here before applying it to a more complicated scenario. Eventually, I want to set the ea on 8 different charts (8 different markets) and, depending on which market it is on, the correct trailing stop should apply.

              Thanks for your help 🙂

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

                You are trying to make universal EA that recognizes X-digits brokers, but actually fxDreema also does that using "Point format" in project options and this function:

                http://fxdreema.com/documentation/colle ... 4/pipvalue

                Now, function like this helps when EA works with basic currencies where digits are 5 or 4. But non-currencies are more complicated. You can find the same instrument with 1 digits in one broker and 2 digits in another. You can actually find USDJPY with 3 digits in one broker and 2 digits in another! And for non-currencies... it's hard to say that they have "pips".

                So I have to make it possible to define custom settings for every market. Well, I'm not gonna do this right now, but while this is not fact, you can make it somehow, and this is what I will suggest to you.

                If you use "input in digits" (I will rename the word "digits" to "price fraction" later), this will skip fxDreema's point format settings, because you can write exact value that does not depend on broker's digits. 0.00010 means 0.00010 everywhere. So if you have input constant like "OnePipIn_EURUSD" that is set to "0.00010" and another input constant like "SL" that is set to "20", within the EA you can do this calculation:

                SLasPriceFraction=SL*OnePipIn_EURUSD
                

                The result will be 0.00200 and will not depend on broker's digits. It will depend on "OnePipIn_EURUSD" that will be input parameter for the EA and the one who uses that EA will be able to control it.
                In other words, with "OnePipIn_EURUSD" parameter you control what "SL" means.

                1 Reply Last reply Reply Quote 0
                • T
                  Trader3487 last edited by

                  Where do I find "input in digits" or is that the concept that you go on to describe? That sounds doable but could you do one example on test project id: mt4-8457, just want to make sure I'm on the right track...

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

                    Oh damn, this option is not present in Trailing stop blocks... it's only level and pips over there...

                    Do you really try to create some kind of universal trailing stop EA?

                    1 Reply Last reply Reply Quote 0
                    • T
                      Trader3487 last edited by

                      I think I will separate this ea into 3 different eas: one ea for 5-decimal charts, one for 3-decimal charts & one for 2-decimal charts and rename variables for each one.

                      1 Reply Last reply Reply Quote 0
                      • T
                        Trader3487 last edited by

                        if I have the same ea running on multiple 5-decimal charts (meaning, same ea is running on EURUSD, GBPUSD, AUDUSD, etc), are formula results kept separate for each chart or do they overwrite each other? For example, the formula block that calculates trailing stop distance (spreadsize + s/l size) stores result in variable named "SL_5point". Does it hold each symbol's result separately or does each one overwrite the other one? It looks like it can hold separate values for SL_5point variable simultaneously (one for each chart) because I opened up 8 different charts on a demo account and attached the same ea to each one. The comment on each chart is displaying different value for SL_5point variable. I hope this is true 🙂

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

                          Every EA is working for it's own on it's chart, it's independent, no matter if it comes from the same .ex4.

                          1 Reply Last reply Reply Quote 0
                          • T
                            Trader3487 last edited by

                            We are back to the drawing board here because my broker kicked me off their server for trying to dynamically generate trailing by setting s/l value to 1 (i.e. too many calls to their server). I resolved the server load issue by rebuilding the trailing stop with variables but having a block that determines point format of current chart (2, 3, 4, or 5 decimal places) is essential so if you would be willing to make it an option, that would be really appreciated. It doesn't look like a difficult task since the information is already provided here, I just don't know how to put it into custom condition blocks that I can use - namely:

                            condition block 1: if current chart is 2-digits, then follow orange output.
                            condition block 2: if current chart is 3-digits, then follow orange output.
                            condition block 3: if current chart is 4-digits, then follow orange output.
                            condition block 4: if current chart is 4-digits, then follow orange output.

                            Thank you 🙂

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

                              You can always use the native MQL4 function to get chart digits, and it is like this:

                              MarketInfo("GBPUSD", MODE_DIGITS)
                              

                              or if you want to use the current symbol:

                              MarketInfo(Symbol(), MODE_DIGITS)
                              

                              This code returns values like 3, 4, 5... the number of digits after the point.

                              I don't know how this is related to the server overload problem. Yes, trailing stop can be set up in a way to modify stops whenever there is a small movement, or "Step" can be used to limit those movements... but for 1 pips I don't know what size can be this Stop parameter 🙂 So I can suggest to use virtual stops, check in "Options -> Project options" to enable "Use virtual stops". And virtual stops are objects - horizontal lines that the EA will check constantly, so there will be no interaction with the server. But in this case be really sure that the EA will not stop working (and leaving some trade uncovered) 🙂

                              1 Reply Last reply Reply Quote 0
                              • T
                                Trader3487 last edited by

                                thanks for that information. I added a condition block and went to "Market properties" > "Symbol (market name)" on the left operand. Could I put "MarketInfo(Symbol(), MODE_DIGITS)" into the adjust field?

                                the method I was using to the s/l in trailing stop block was making too many server calls because 1 pip was always less than the broker's minimum s/l requirement so the server would return a message like "s/l too short. using minimum s/l of 86 instead". And since the block was running every tick and trailing stop step size was 1 pip and there were 8+ charts open, those server messages were filling up the log. Thankfully, the broker covered the trades they closed 🙂

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

                                  Symbol (market name) is text, for example EURUSD. Digits value is numeric, like 3, 4, 5... I don't see how you can adjust EURUSD with 5 for example.

                                  And I still don't understand why you are trying to get out of one problem by digging into things that are not connected to it. If you have too small trailing stop, then use bigger one.

                                  1 Reply Last reply Reply Quote 0
                                  • T
                                    Trader3487 last edited by

                                    I could adjust the trailing stop size but I have more than 30 chart symbols now and each one is a condition block. Additionally, I have to add a regular version of the symbol name (ex. EURUSD) for standard trading account and a micro version (ex. EURUSDmicro) for micro account. Not all brokers use same naming system so I have to add another 30 blocks for different naming system (ex. EURUSDm instead of EURUSDmicro and XAGUSD/XAGUSDm instead of SILVER/SILVERmicro). That's 90 blocks that need a title and connections to and from those blocks and I have those blocks in 2 places in my ea (in the OnInit and in the main section), so it's just a lot of clicking and connecting not to mention if I want to add another symbol I have to add another 4 blocks. screenshot attached.

                                    The reason I need put all these condition blocks for chart symbols is in order to direct the ea to the proper trailing stop block. I am using 3 primary different trailing stops (blocks #104, 105 & 106) based on the number of decimals of the symbol. It would be so much easier if there was just 4 blocks that said "if chart is x decimal places" go to x trailing stop block or even 1 custom block that determined how many decimals the chart was and then directed output to the correct trailing stop block 🙂

                                    ......
                                    ScreenClip.png

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

                                      Ok, this needs special attention. I will go to update point format functionality, so many blocks for something so simple are not a good idea 🙂

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

                                        Go to "Options -> Project Options" and see at the top. Hope this helps. If there are some problems with this new functionality, make me know 🙂

                                        1 Reply Last reply Reply Quote 0
                                        • T
                                          Trader3487 last edited by

                                          great, thank you very much! So how do I make a condition block that says "if 0.0001 (4 decimals)" then follow orange output?

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

                                          Online Users

                                          G
                                          K
                                          P
                                          M
                                          M

                                          15
                                          Online

                                          146.7k
                                          Users

                                          22.4k
                                          Topics

                                          122.6k
                                          Posts

                                          Powered by NodeBB Forums | Contributors