fxDreema

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

    SL/TP Adjusting based on the last range

    Questions & Answers
    3
    14
    2300
    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.
    • B
      Boferer last edited by

      Hello!

      I´ve searched the forum for something similar, but I have only encountered examples which were not exactly dealing with this type of an issue(or maybe I overlooked them.)

      So I want to take the range of the last closed candle(10 pips for example), set pending orders from the newly opened price 70 % of the range up and down(buy and sell), and adjust the take profit and stop loss in the following way: TP of 30 % of the range for a buy order and a 70 % of the range for the SL. I have been playing around with the % of the price function, but this didnt seem to work for the range as I wanted it to.

      So for example:

      last candle range is 10 pips - 1.1400 to 1.1410
      The new candle opens at 1.1411
      We now want to put a buy pending order of the new opened price + 70 % of the range
      and a sell pending order of the new opened price - 70 % of the range
      and then have the TP/SLs as following: Buy pending order TP = (the new opened price + 70 % of the range) + 30 % of the range
      SL = (the new opened price - 70 % of the range) - 30 % of the range
      and vice versa for the sell pending order.
      so TP= (the new opened price - 70 % of the range) - 30 % of the range
      and SL = (the new opened price +70 % of the range) + 30 % of the range

      1 Reply Last reply Reply Quote 0
      • B
        Boferer last edited by

        I can work it off perfectly of the price, but the range part is the real problem where Im stuck

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

          This may be what you want?

          https://fxdreema.com/shared/w21RRTjsb

          alt text

          B 1 Reply Last reply Reply Quote 0
          • B
            Boferer @vish last edited by Boferer

            @vish It seems to be correct at first sight, but there are some discrepancies upon further investigation. However, this is more or less it. I have attached a picture I made in paint for visual representation. Also, one the first buy stop is triggered, the sell stop should get deleted, but I think I know how to do that so it shouldnt represent any problem.

            https://imgur.com/a/4yfNuiS

            I noticed I made an error defining the stop loss! My apologies. I´ll try to tinker around with the properties to see if I can get it to work with this example vish

            Update: I tinkered around with the input 9 and managed to get the SL´s converge, but they converge above the opening price of the new candle for some reason. I guess I need to dive deeper into the definition of the variable.

            1 Reply Last reply Reply Quote 0
            • B
              Boferer last edited by

              Anybody else has any other ideas? Im struggling to understand where vish´s part interacts with the last range. I cant find it, but maybe I do not know where to look.

              1 Reply Last reply Reply Quote 0
              • B
                Boferer last edited by

                Unfortunately, I ran into a dead end it seems once again. Well, only time will tell if this is possible.

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

                  Try this: https://fxdreema.com/shared/nDHEjiQzb
                  I used one "double" variable called Range:

                  0_1554741024256_dc6854ec-90be-4ff9-9f26-7457ea383c9b-image.png

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

                    @fxdreema I highly appreciate your help 🙂 This is extremely close. The issue with this one is that it doesnt capture the range in a proper way (e.g. when the last range was 40 pips, it doesnt register it), but besides that it functions as it should. I see getting the EA to register the lenght of the last range (40 pips, 30 pips etc whatever it is) to be the hardest challenge.

                    Also, I dont understand why the condition has adjustment of +8 pips.

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

                      Works good for me. Why is that 8 pips... it's some minimum size for the candle, you probably don't want to put orders after a doji candle.

                      1 Reply Last reply Reply Quote 0
                      • B
                        Boferer last edited by

                        I´ll test it again then! 🙂 Thank you for your help! I appreciate it heavily.

                        B 1 Reply Last reply Reply Quote 0
                        • B
                          Boferer @Boferer last edited by

                          So in the end, it seems we got it to work! One more thing I need help with though: I want to create a button which will make the EA run when pressed regardless of any other circumstances

                          e.g. when the button will be pressed, the EA will automatically take the last candle´s range and put the orders.

                          I browsed the forum and found FxDreema´s & Miro´s answers on these links respectively. However, I tried to use them, but the blocks just wouldnt run even when I used the "Run Blocks" feature.

                          https://fxdreema.com/forum/topic/4417/buttons/2

                          https://fxdreema.com/forum/topic/6505/how-to-work-with-the-buttons

                          Any ideas how I could do this?

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

                            Show something from what you did. There is a big chance that there is some mistake in what you did, but no we can't guess what it is

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

                              @fxdreema https://imgur.com/a/TLfta1W

                              This is what I tried out.

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

                                It's enough to create the button once, so use Draw Button in Init, not in Tick. Block 10 is only to be used in "on Chart": https://fxdreema.com/demo/mt4-event-chart

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

                                Online Users

                                M
                                N
                                G
                                H
                                S
                                E
                                G
                                D

                                29
                                Online

                                146.7k
                                Users

                                22.4k
                                Topics

                                122.6k
                                Posts

                                Powered by NodeBB Forums | Contributors