fxDreema

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

    Please help: Place ATR Stop Loss?

    Questions & Answers
    4
    11
    4651
    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
      teobusetti last edited by

      Hi everyone!

      I am trying to create an EA that buys (sells) when the price breaks above (below) the highest high (lowest low) of X previous days.

      I am curenlty having 2 problems:

      1. I am trying to include a trend filter so that the trade is placed only if the fast SMA is above (below) the slow SMA. However in the EA I have built there are some sell trades that are placed against the trend (i.e. when the fast SMA is above the slow SMA) - see screenshot. Would anyone be able to tell me where i went wrong?

      2. I would like to place a stop loss based on [(highest high of X days) - 3x ATR] or [(lowest low of X days) + 3x ATR]. I have tried a few solutions, but cannot seem to make it work. Does anyone have suggestions?

      Thanks a lot!

      EA: https://fxdreema.com/shared/zeFLoMrCd

      Screen Shot 2016-07-13 at 08.21.21.png

      ......
      Screen Shot 2016-07-13 at 08.21.21.png

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

        in blocks where you compare MA, you compare null candle, it means that as time goes this flight up and down and can cross and not cross, you can try compare candle 1 (More Settings - Candle ID in block for comparison).
        Be sure, that you have same period in EA like in chart for visualization results
        check what happens with visual tester mode

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

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

          What if you backtest on Daily and you don't use block 1. If it's the same.. well, maybe at the time the conditions were true. If you want to see everything at this particular moment when the Sell is created, you can put "Terminate" immediately after the sell block and the EA will stop there. Or use "Delay" (but edit its settings so it can pause the EA while backtesting) and in Visual mode you can see exactly what is going on at the moment 🙂

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

            __in blocks where you compare MA, you compare null candle, it means that as time goes this flight up and down and can cross and not cross, you can try compare candle 1 (More Settings - Candle ID in block for comparison).
            Be sure, that you have same period in EA like in chart for visualization results
            check what happens with visual tester mode[/quote:2rinftm2]

            Hi miro1360, thanks for the suggestion. I shall try it and let you know 🙂

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

              __What if you backtest on Daily and you don't use block 1. If it's the same.. well, maybe at the time the conditions were true. If you want to see everything at this particular moment when the Sell is created, you can put "Terminate" immediately after the sell block and the EA will stop there. Or use "Delay" (but edit its settings so it can pause the EA while backtesting) and in Visual mode you can see exactly what is going on at the moment :)[/quote:1yknj4ew]

              Hi! Thank you for the input 🙂
              The conditions shown in the screenshot are already the 'correct' conditions, if you will - i.e. Daily chart with 50 SMA and 100 SMA, but as you can see, the entry point for the sell trade does not seem correct...

              Would you also have any suggestions on how to implement the ATR stop loss? For example, for a buy order I am trying to set an an initial stop loss = (Entry price) - (3 x ATR) , when the 10-day lowest low becomes higher than the stop loss, I would like this to become the exit point....if it makes sense...
              I have tried many different possibilities, but cannot seem to get it right. This is what I have now https://fxdreema.com/shared/boFwQ4rMb 😄

              Cheers guys!

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

                In 14 and 22, will it work if you use < and >

                Block 32 like that... check this one: https://fxdreema.com/demo/mt4-loop-how-it-works

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

                  __In 14 and 22, will it work if you use < and >

                  Block 32 like that... check this one: https://fxdreema.com/demo/mt4-loop-how-it-works[/quote:3dvs59po]

                  Hi fxdreema, thanks for your suggestion! I see m to have solved the first problem

                  However, I still cannot understand how to set a stop loss for a buy order = candle high - 3xATR
                  I have tried like you suggested (block 36, 38, 45, 46 ,47) but by backtesting it I can see it is not working as supposed (see screenshot) - do you have any ideas of where I could be going wrong?
                  https://fxdreema.com/shared/pDctZiDGc

                  Thanks 🙂

                  ......
                  Screen Shot 2016-07-17 at 19.16.15.png

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

                    Be careful with these words - price level, pips, price fraction. This variable "SL_buy" contains price level value, but then in block 46 this variable is used for "Custom (pips)". Try this instead: http://prntscr.com/bu5v10

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

                      __Be careful with these words - price level, pips, price fraction. This variable "SL_buy" contains price level value, but then in block 46 this variable is used for "Custom (pips)". Try this instead: http://prntscr.com/bu5v10[/quote:3l6hdyj9]

                      Thanks!! seems to be working better 🙂
                      But is not quite there yet, I cannot understand why it draws the Stop Loss on the last candle, rather than on the entry candle https://fxdreema.com/shared/uB2iAc00d

                      I have set "candle ID"=1 with respect to the open price, in bloc 38 but it is not working as i would like...
                      Would you please be able to suggest how to edit it?

                      ......
                      Screen Shot 2016-07-18 at 21.49.38.png
                      Screen Shot 2016-07-18 at 21.51.54.png

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

                        If I understood this right, you want to modify your stop just once. Now the bot modifies it on every tick though, and so forgets about your open bar as time passes.
                        Use "check stop-loss" (needs to equal 0) and modify the stop only then.

                        Need small help? Tag me in your post
                        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

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

                          __If I understood this right, you want to modify your stop just once. Now the bot modifies it on every tick though, and so forgets about your open bar as time passes.
                          Use "check stop-loss" (needs to equal 0) and modify the stop only then.[/quote:17xwgd3b]

                          Thanks 🙂 exactly what I was looking for!!

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

                          Online Users

                          S
                          L
                          E
                          M
                          A
                          H
                          S

                          15
                          Online

                          146.7k
                          Users

                          22.4k
                          Topics

                          122.6k
                          Posts

                          Powered by NodeBB Forums | Contributors