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

fxDreema

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

Control of trades, new trades and add to volume - help!

Questions & Answers
2
26
7.4k
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.
  • J
    james last edited by 18 Oct 2013, 21:54

    Hi again. I'm back! Sorry.

    I've been struggling with this for many hours, and I wondered if you could advise.

    I've made a small example of an EA here: http://fxdreema.com/shared/Wm5YJ3uGd.

    My actual EA picks up on a few signals over quite extended periods, so I don't want to miss a signal if another one is still being processed in the trades loop.

    I'm trying to do the following:
    *
    Allow the EA to pick up all new trade signals, without making multiple orders for each one.
    Have the trades loop run and create additional trades (add to volume) for each buy without affecting the ability of the EA to pick up new trade signals.[/list:u:mdmfkztz]

    Therefore the use of the "Less than "n" trades are running" block is counter-productive since it can stop the EA picking up new trade signals when the trades loop has added to volume (created new trades).

    So in my shared example, I'm trying to place a buy on each and every signal, if either there are no trades running, or BuyPrice > SL. Then, in the trades loop, I'd like it to place one additional "add to volume" trade when the "Pips away from SL" blocks are satisfied. There would then be up to three trades running with the same trailing stop loss.

    Please help!

    Thank you 🙂 🙂

    (I hope I've explained this clearly! My apologies in advance if its confusing.)

    1 Reply Last reply Reply Quote 0
    • fxDreema
      fxDreema last edited by 19 Oct 2013, 21:03

      Pips away from SL - this means the difference between the current price and SL.
      For buy -> Ask-SL, for sell -> SL-bid.
      For % of SL option, SL size is calculated as the difference between SL and Open Price.
      55% of SL, if OP-SL is 100 pips, this is 55 pips. But initially the trade is 100% pips away from SL, so this block will pass every time if Ask is 55 pips above SL, and it does that and the EA produces 3 trades in one shot.

      My idea for this block was to be able to build custom trailing stop with it, because in trailing stop the difference between the current price (Ask or Bid, depending on trade type) and SL. But I think you should use Pips away from open price or at least use value bigger than 100% for that option (% of SL).

      By the way, this Once per bar (block 7) limits the loop to work with only the newest trade once per bar. But in the loop block it can be also told to work with the newest trade only, all the time (setting the last option to 1)

      1 Reply Last reply Reply Quote 0
      • J
        james last edited by 20 Oct 2013, 15:58

        Hello again! 🙂

        I think my previous explanation may have been poor, because I don't think you understood my query. In fact I'm beginning to think I need another block!

        Anyway, I'll try to be clearer this time. I've amended and re-shared my example EA here: http://fxdreema.com/shared/MJUi8aI6

        This is as far as I seem to be able to take my idea using fxDreema. What's happening is this:

        The trade in Area #1 is opening properly, and subsequent trades are being placed when SL > Open Price.

        Then the trade loop in Area #2 takes over and adds to the volume, but only for the first trade opened by Area #1. The subsequent trades opened by Area #1 are ignored by Area #2.
        [/list:u:rpxj146r]

        My question therefore, is this; how do I get the trades loop in Area #2 to work independently and correctly on all trades opened by Area #1?

        I'm using local build 059.

        As always, grateful thanks. 🙂

        1 Reply Last reply Reply Quote 0
        • fxDreema
          fxDreema last edited by 20 Oct 2013, 17:11

          Once per bar passes one time per bar. Start trades loop self-executes as many times as many trades there are. Once per bar, sonnected after Start trades loop limits it to the last trade only.

          1 Reply Last reply Reply Quote 0
          • J
            james last edited by 20 Oct 2013, 21:55

            Thank you very much indeed for your reply.

            Unfortunately I don't fully understand what you are saying because I don't have a "Once per bar" block attached anywhere in the "Start trades loop" in Area #2. I took note of what you said earlier, but still find that the trades loop doesn't work on the subsequent trades that the EA makes.

            As I said, the blocks in Area #1 work perfectly, making subsequent trades after SL > Open Price. But after the first trade placed by Area #1, the ones after are ignored by Area #2.

            I want the Start Trades loop in Area #2 to work on all open trades. This it doesn't do. How do I make it do so?

            🙂

            1 Reply Last reply Reply Quote 0
            • fxDreema
              fxDreema last edited by 21 Oct 2013, 06:59

              I can see "Once per bar" in the project shared here on the first post. It's different in your account now.
              Anyway, for the project in your account...
              It's not a good idea to compare price levels with "==", you just can't expect that the price will be exactly "1.23456" (for example), it can skip this value so easily. Use ">=" or "<=" instead.
              Also, this "50%"... The keyword "%" is replaced by "/100" so in fact you have "+50/100" there, or "+0.5". Maybe I should edit the behaviour of "%" in case "+" or "-" is used, this is the first time I see it like this, but.... now better use *1.5 in such cases 🙂 But not in this case, I think. If your Open Price level is 1.3000, what can be 1.3000 + 50%? Do you really mean 1.9500 (1.3+half of it)?

              There are 2 main situation when somebody can easily check if something is not fine inside blocks.

              • The first situation is when one wants to see some value, then "Levels tesrer" block is really handy, it shows you the value in realtime. But also "Comment on chart" or "Alert message" are good.
              • And when it's not clear when some block passes or not - "Draw arrow" is the easiest way to check that. I also made special block for this "Logic points tester", and it works... but I found myself still using "Draw arrow" :)))
              1 Reply Last reply Reply Quote 0
              • J
                james last edited by 21 Oct 2013, 11:58

                Hello, and thank you for your - as always - helpful suggestions. 🙂

                I have again amended my example. Its here: http://fxdreema.com/shared/wkBAZyBY. You will see that I have incorporated your suggestions.

                The only thing I haven't done is change the +50% in block 17. I understand what you've said about this, and will change it later. For now, however, I'd really like to address the problem of the Start Trades loop in Area #2 not doing what I think it should. Have a look at this picture:

                Untitled 1.jpg

                In it you'll see that the first trade behaves as I think it should. Area #1 opens a trade, and Area #2 tracks it, adding to volume (draw arrow visible) and moving stop losses.

                However, the second trade gets no add to volume, but its stop loss is tracked.

                I'd like to be able to add volume to each and every trade, and have stop losses trailed.

                🙂

                ......
                Untitled 1.jpg

                1 Reply Last reply Reply Quote 0
                • fxDreema
                  fxDreema last edited by 21 Oct 2013, 13:35

                  On my demo account it works, but for the period I tested it I think I can't find situation where 2nd trade is opened while 1st trade is still working. But I noticed something in "Start trades loop" block - Loop direction is Oldest-to-newest, and also you set to work with 1 trade in the loop. In other words - Start trades loop filters only the oldest trade that is present. So... if there are 2 ot more trades at a time, only the oldest one will enter the loop.

                  I also found that 50% was not working because of some strange MQL behaviour - when we have something like 50/100, this results in 0, because it thinks that it has to treat the result (0.5) as integer. Weird, but I fixed that, so now better remove that "+50%", because it will add 0.5 to the right operand 🙂

                  1 Reply Last reply Reply Quote 0
                  • J
                    james last edited by 21 Oct 2013, 15:46

                    Yes. I agree with you that it works on the first trade opened, but not on the second or subsequent when the first trade is still running.

                    I've again altered my example, here: http://fxdreema.com/shared/YgIu0iurc.

                    You'll see that I've removed the 1 trade in loop restriction in the "Start trades block", and changed block 17 to be "(in loop) Pips away from Open Price" block with +2pips.

                    So with those amendments I now get multiple "add to volume" hits after the first trade, as in this picture:
                    Clipboard02.jpg

                    This isn't what I need. I need one additional add to volume per buy from Area #1 as in my post of Mon Oct 21, 2013 1:58 pm.

                    I'm trying to make the EA say:

                    • buy signal, therefore buy #1
                    • if price > buy price #1 by x, add to volume of buy #1 one time
                    • buy signal, therefore buy #2
                    • if price > buy price #2 by x, add to volume of buy #2 one time
                    • buy signal, therefore buy #3
                      ...and so on
                      ...and run trailing stops off each buy position for the buy position itself and its add volume.

                    You'll find that the US500 (S&P500) in January 2013 has a situation where this can occur.

                    I have a feeling that the "(in loop) Pips away from Open Price" block may need an additional option to do this.

                    🙂

                    ......
                    Clipboard02.jpg

                    1 Reply Last reply Reply Quote 0
                    • J
                      james last edited by 21 Oct 2013, 16:13

                      ...or perhaps change the "filter by type" choice in the Start Trade loop. At the moment there is:
                      *
                      Buys
                      Sells
                      Buys and Sells[/list:u:2gzrccvg]

                      How about this:
                      *
                      Buys created outside trade loop
                      Sells created outside trade loop
                      Buys and Sells created outside trade loop
                      Buys created inside trade loop
                      Sells created inside trade loop
                      Buys and Sells created inside trade loop
                      [/list]

                      Then using two "Start Trade loop" blocks, maybe I could achieve my aim? 🙂

                      1 Reply Last reply Reply Quote 0
                      • fxDreema
                        fxDreema last edited by 21 Oct 2013, 19:59

                        Maybe the problem is that "Once per trade" detects all trades as independent. Let's say I can make it to recognize when a trade is "added" and not touch it... but it is still independent for trailing stop for example. Maybe I should add options to recognize when trades are added to volume ot removed from volume in both places.

                        If this is the problem, there is workaroud - set some variable after Buy now (let's say with value 0) and after Once per trade - to 1. Before Once per trade ask if that variable is 0.

                        1 Reply Last reply Reply Quote 0
                        • J
                          james last edited by 21 Oct 2013, 22:23

                          If I've understood you correctly, then no, this won't work either. You can check if I've understood here: http://fxdreema.com/shared/X89LccS0d.

                          Here's a picture of the results:
                          Clipboard02.jpg
                          As you can see, this makes two trades at the next buy signal from Area #1 at 2013.01.18 00:01. The one at 0.15 size came from Area #1, and the one at 0.10 from Area #2.

                          Not being able to get this to work is indeed causing a problem. It stops me properly "pony-ing up" trades as they become profitable as a trend develops. Normally this would be in this manner:

                          1st buy signal from Area #1, therefore buy #1
                          *
                          if price > buy price #1 by x, add to volume of buy #1 one time
                          [/list:u:1ksesney]
                          2nd buy signal from Area #1, therefore buy #2
                          *
                          if price > buy price #2 by x, add to volume of buy #2 one time
                          [/list:u:1ksesney]
                          3rd buy signal from Area #1, therefore buy #3
                          *
                          if price > buy price #3 by x, add to volume of buy #3 one time
                          [/list:u:1ksesney]
                          [/list:u:1ksesney]
                          ...and so on
                          ...and run trailing stops off each buy position for the buy position itself and its add volume.

                          I've back-tested this idea on a spreadsheet and I know it's good. But I just can't find a way to make it work with fxDreema. Clearly if I were able to program in MQL I'd do it, but I'm relying on you! 🙂

                          I'm happy with the way the stop losses are working. Its just the trades.

                          ......
                          Clipboard02.jpg

                          1 Reply Last reply Reply Quote 0
                          • fxDreema
                            fxDreema last edited by 21 Oct 2013, 23:00

                            Well, the concept of adding to volume in MQL4 leads to some problems, because there is no function to add to volume, it's really creating an independent brand new trade that shares nothing with it's "mother". So even if you can program in MQL4 there are problems like this sometimes 🙂
                            At least there is a function to partially close trades, and this makes it possible to check if trade X has "mother" even if you restart everything.

                            I tested this on EURUSD and it looks fine, there are no trades opened in almost the same time, so I think that 2 pips for pips away are too small for this symbol and this results in adding to volume right after "Buy now" opens it's trade.

                            1 Reply Last reply Reply Quote 0
                            • fxDreema
                              fxDreema last edited by 21 Oct 2013, 23:16

                              Or you can control trades in other way. The best is if you use their parameters, so in case EA is restarted to be able to continue from where it was. If you use variables, this is not the case.

                              So you can ask for lot size before going to add to volume. I noticed that you are using different lot sizes for the initial trade and the other.
                              Or you can use another Buy now with different Group number that will be filtered out from the loop. One more trailing stop will be needed as well.

                              1 Reply Last reply Reply Quote 0
                              • J
                                james last edited by 22 Oct 2013, 07:49

                                Ah ha! An MT4 limitation! Definately wouldn't have come across that in the spreadsheet. 🙂 OK, so I'll try the route of using multiple buy/sell routines with their own individualised "Start trades loop" series using group numbers. This may mean I have to make the EA quite large, as I'll have quite a few of these, but hey! That's life! 😆

                                1 Reply Last reply Reply Quote 0
                                • fxDreema
                                  fxDreema last edited by 22 Oct 2013, 13:00

                                  Not exactly limitation, but something that MT4 is not designed to do. But I have idea how to trick it by using Comment attribute of trades. I decided to link all trades created with "Add to volume" with their parent trade, and when some of them is closed or modified - to close or modify others in that group. And this will take some time because multiple blocks and functions are depending on this...

                                  1 Reply Last reply Reply Quote 0
                                  • J
                                    james last edited by 22 Oct 2013, 13:24

                                    That's fantastic! Thank you. I look forward to when that's available, but I do understand that it's a big job and will take time. The stop losses seem to work as expected though, so hopefully that'll be one less item on your "to do" list...!
                                    🙂

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      james last edited by 22 Oct 2013, 15:06

                                      Me again - sorry! 🙂

                                      I've had a look at employing groups with this pony-ing idea. I can get this to work fine when I have 2 groups, but not with any more. The problem seems to be detecting when the SL of the last trade is above its own buy price - the "mother" as you put it! The measurement of this seems to work on the highest SL, which could have been set several trades before.

                                      Depending on how long you think it will be before you are able to get your idea of tricking MT4 by using Comment attribute of trades working, would it be possible to add an "Origin of trades" to the "Check the distance between two levels" block? Might this be a good idea anyway? Maybe this isn't possible. If so, please forgive my ignorance!

                                      My picture below is of a hypothetical "Check the distance between two levels" block, which is checking SL > Open Price, and incorporates an "Origin of trades" filter to pick up "mother".

                                      Many thanks, again.

                                      🙂

                                      Untitled 1.jpg

                                      ......
                                      Untitled 1.jpg

                                      1 Reply Last reply Reply Quote 0
                                      • fxDreema
                                        fxDreema last edited by 22 Oct 2013, 15:40

                                        "Check the distance between two levels" block has nothing to do with trades, it just calculates distance between two levels, no matter if they belong to trades, objects, or manually written values.

                                        This is something that I wrote hundreds times before, but when using "(in loop)", "Start 'whatever' loop" block should be used - there it is decided to which trade these levels (op, sl) belongs to.

                                        1 Reply Last reply Reply Quote 0
                                        • 1
                                        • 2
                                        • 1 / 2
                                        2 out of 26
                                        • First post
                                          2/26
                                          Last post

                                        Online Users

                                        E
                                        K
                                        E
                                        N
                                        N
                                        S
                                        E
                                        R
                                        F
                                        F
                                        P
                                        J
                                        P
                                        K
                                        E
                                        A
                                        W
                                        E
                                        M

                                        34
                                        Online

                                        128.9k
                                        Users

                                        21.9k
                                        Topics

                                        119.4k
                                        Posts

                                        Powered by NodeBB Forums | Contributors