fxDreema

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

    Stop ATR

    Questions & Answers
    2
    33
    9788
    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.
    • tcanuto
      tcanuto last edited by

      Hello fxDreema. How do I implement the Stop ATR in my EA? I believe that the mathematical formula is simple, like this:

      Market price - ATR * "x"

      Example.

      EURUSD this now quoted at 1.11650
      14 period ATR is currently 0.0015
      x is the multiplier want it to be 2.

      1.11650 - (0.0015 * 2) =
      SL is 1.11350.

      I believe it's correct the formula. So how to implement a project?
      Could you do me a sample project?

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

        Maybe something like this - http://prntscr.com/aj119m
        http://i.imgur.com/52Mrpgr.png

        Candle Close is Bid, but when working with indicators I prefer to use Candle Close.

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

          Interesting fxDreema. He worked for me here. Thank you.

          Now I wonder how can I leave the Stop ATR as a Donchian channel, for example?

          See the picture:
          https://c.mql5.com/18/21/nrtr_atr_stop_1.gif

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

            Now you want to make indicators 🙂 Unfortunately fxDreema works only for EAs and Scripts.

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

              No no ... I do not want to indicator. Only the ATR Stop function this way. The Stop ATR fixed line, such as a Donchian channel, for example. This indicator is above a Stop ATR, but do not want to display. It would be something to "Adjusting the result?"

              I tried to "Market Properties" using the Highest point (candle period) in block 20 Formula, and was almost what I need. But the values were higher than necessary. I tried vise-versa for block 25.
              https://fxdreema.com/shared/5FgqrGOue

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

                Of course you can do calculations, as many as you want. The problem is that if you use "Formula", this means 1 block for 1 calculation, which is kinda stupid. But there are other ways to calculate things as well. In these examples you can see them - https://fxdreema.com/examples/#Constants-and-Variables Also, there is a block "Custom MQL4 code".

                When you use "Formula" blocks, make sure that each calculation follows the previous one. I don't know why people prefer to connect many "Formula" blocks in parallel. It looks beautiful, but it's much better to connect multiple "Formula" blocks one after another, because calculations must be done in order. Don't rely on block numbers very much. Look at your block numbers - 25, 26, 16 - which one of these block will run first? Do you know and do you care? 16 runs first and you should care. Trace runs before Formula blocks.

                If you have issues with values... well, you should know them before going to work with them. ATR gives you values like 0.00010. Ask/Bid are values like 1.23456. Sometimes values must be converted.

                So, this is what I see - http://prntscr.com/akf0a0
                If ATR is let's say 0.0007, this is 7 pips. In Formula blocks you double that value and put it in both sides of the current price. Something like +/- 0.0014 (or 14 pips). This is pretty much what I see - http://prntscr.com/akf1kb (127 = 12.7 pips).

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

                  It is .. maybe there is no need to use the formula block.

                  Actually, the blocks 15 and 16 are only for visualization not important.

                  Interesting pips of viewing the image above.

                  I think it would be interesting in the Trace block put beyond color lines, but types of lines, thickness, etc., as we do in external imput of any indicator, for example.

                  In the case of this project, as you can see, the StopATRU and StopATRL lines are oscillating.

                  How do I let them straighter, as a Donchian channel for example? That's what I need.

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

                    Again, the Trace block is only for testing purposes, it's not designed to be used to indicate something. Trace is NOT an indicator. Trace shows you the history of a value, including values such as EMPTY_VALUE or -EMPTY_VALUE.

                    These lines are oscillating because the values you prot are oscillating. These lines are Ask and Bid prices shifted above and below. These are not Highest or Lowest prices of something, which is the case in Donchain Channel.

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

                      Yes I know. You can hide the ATR indicator Tester Visualization?

                      Captura de tela de 2016-03-30 16-10-45.png

                      ......
                      Captura de tela de 2016-03-30 16-10-45.png

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

                        So ... I found the formula Stop ATR I believe it will work:
                        StopLoss = Low[0] - 2 * ATR(5, Close[1]-2ATR(5), and High[0] - 3ATR(5)
                        https://www.instaforex.com/pt/forex_ind ... r_stop.php

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

                          Hello fxDreema. Well ... if you can not hide the indicator, I have to do with the blocks, and to think better.
                          But first my idea is to calculate the ATR in a block formula, for example, without using the ATR indicator.

                          Recalling that: If you can hide the window, we do not do all this work.

                          The true range is the largest of the:

                          Most recent period's high minus the most recent period's low
                          Absolute value of the most recent period's high minus the previous close
                          Absolute value of the most recent period's low minus the previous close

                          Formula: TR:
                          https://upload.wikimedia.org/math/1/6/1/161bbb13f7109a0ae8f4618a8708a474.png

                          The ATR at the moment of time t is calculated using the following formula: (This is one form of an exponential moving average):
                          https://upload.wikimedia.org/math/8/b/8/8b849a07cc6fa12d28d73a1d0db00548.png

                          More information about the formula, can be found here: https://en.wikipedia.org/wiki/Average_true_range

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

                            There is no function ATR in MQL4. There is iATR(), but it has some more inputs - https://docs.mql4.com/indicators/iatr

                            I never tested that, but I think this is the answer - https://docs.mql4.com/customind/hidetestindicators

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

                              Interesting fxDreema! How to put HideTestIndicator in a block? If I get it, forget the previous post and we will hide the indicator!

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

                                __There is no function ATR in MQL4. There is iATR(), but it has some more inputs - https://docs.mql4.com/indicators/iatr

                                I never tested that, but I think this is the answer - https://docs.mql4.com/customind/hidetestindicators[/quote:3atq74ol]

                                Well ... I tried and it seems that it worked in MT4.
                                https://fxdreema.com/shared/h31iU00gd

                                Now I can not hide in MT5.
                                https://fxdreema.com/shared/sd1jjRFQ

                                I researched this function in MT5, and unfortunately has not. So ... in this case ... how to hide in the MT5 platform?
                                https://www.mql5.com/pt/articles/81

                                Robots sold in MQL5 do not show their indicators

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

                                  Hello fxDreema. I tried 3 ways, but without success.
                                  https://fxdreema.com/shared/6iglX9bbb

                                  See the link for possible solutions here:
                                  https://www.mql5.com/en/docs/runtime/te ... torrelease

                                  https://www.mql5.com/en/forum/11193
                                  https://www.mql5.com/en/forum/9184

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

                                    Just do that http://prntscr.com/ancxsk
                                    http://i.imgur.com/TkQW68r.png

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

                                      Yes ... I did that and it worked in MT4, but I need also to MT5 , as mentioned in the post above .

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

                                        It looks that there is no such function in MQL5. There is one IndicatorRelease(), but it does something else and is called at the end. What people suggest (https://www.mql5.com/en/forum/9184) is to detect Visual Mode and prevent the EA from working in this case. I think that indicators appear only in Visual Mode.

                                        http://prntscr.com/aohfg7
                                        http://i.imgur.com/928hPRF.png

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

                                          So ... that way it worked! Thanks!

                                          But look at it this way: https://www.mql5.com/en/docs/runtime/te ... torrelease
                                          Hide the indicator?

                                          To prohibit the showing of the indicator on the chart after testing, call the IndicatorRelease() with the handle of the indicator in the handler OnDeinit(). The OnDeinit() function is always called after the completion and before the showing of the testing chart.

                                          
                                          //+------------------------------------------------------------------+ 
                                          //| Expert deinitialization function                                 | 
                                          //+------------------------------------------------------------------+ 
                                          void OnDeinit(const int reason) 
                                            { 
                                          //--- 
                                             bool hidden=IndicatorRelease(handle_ind); 
                                             if(hidden) Print("IndicatorRelease() successfully completed"); 
                                             else Print("IndicatorRelease() returned false. Error code ",GetLastError()); 
                                            }
                                          

                                          In order to prohibit the showing of the indicator on the chart, after the completion of a single test, use the function IndicatorRelease() in the handler OnDeinit().

                                          IndicatorRelease() https://www.mql5.com/en/docs/series/indicatorrelease
                                          OnDeinit() https://www.mql5.com/en/docs/runtime/event_fire#deinit

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

                                          Online Users

                                          K
                                          A
                                          D
                                          S

                                          12
                                          Online

                                          146.7k
                                          Users

                                          22.4k
                                          Topics

                                          122.6k
                                          Posts

                                          Powered by NodeBB Forums | Contributors