ATR for Stop Loss
-
Hi everyone, I would like to set the Stop Loss of my operation in the following way: (Price when I opened the order) minus (ATR value at the time of opening the order x 2). Made this calculation and found the value, I would like it to be set as a stop loss in my buy now button, but something is not working, can anyone explain what and give me a hand ??
this is the link https://fxdreema.com/shared/jthcJNmpc -
and also some time FX gives me this error -
You can save a lot of blocks and variables by doing this:

-
@l-andorrà In this way, the ATR period parameter is missing.
-
@l-andorrà Please disregard my previous answer. It's OK.
There is something wrong with this ATR. SL is a far cry from what was expected.
https://fxdreema.com/shared/yNSm01EKc
PG 0 19:19:51.568 Tester EURUSD,M1 (FxPro-MT5): every tick generating
GP 0 19:19:51.568 Tester EURUSD,M1: testing of Experts\Advisors\Turtle Trading Original.ex5 from 2021.01.01 00:00 to 2021.03.08 00:00 started with inputs:
JE 0 19:19:51.568 Tester Entrada1=20
EH 0 19:19:51.568 Tester Saida1=10
CS 0 19:19:51.568 Tester Stop_ATR=10
GN 0 19:19:51.568 Tester Derrapagem=3
FG 0 19:19:51.568 Tester MagicStart=1465
JS 0 19:19:57.685 Turtle Trading Original (EURUSD,M1) 2021.01.04 00:00:01 Alert: You want to trade 1.634895203217474e-05 lot, but your broker's minimum is 0.01 lot. The trade/order will continue with 0.01 lot instead of 1.634895203217474e-05 lot. The same rule will be applied for next trades/orders with desired lot size lower than the minimum. You will not see this message again until you restart the program.
OQ 0 19:19:57.685 Trade 2021.01.04 00:00:01 market buy 0.01 EURUSD sl: 0.00068 (1.22378 / 1.22400 / 1.22378)
LO 0 19:19:57.685 Trades 2021.01.04 00:00:01 deal #2 buy 0.01 EURUSD at 1.22400 done (based on order #2)
NQ 0 19:19:57.685 Trade 2021.01.04 00:00:01 deal performed [#2 buy 0.01 EURUSD at 1.22400]
OD 0 19:19:57.685 Trade 2021.01.04 00:00:01 order performed buy 0.01 at 1.22400 [#2 buy 0.01 EURUSD at 1.22400] -
@tcanuto Are you sure your variable 'Stop_ART' is providing an integer number result? Otherwise it will not work.
-
@l-andorrà Yes. It's like integer.

-
@tcanuto How is your variable '(Multiplo_ART)' calculated?
-
@l-andorrà Yes. It is calculated.
-
@tcanuto hi there,
Try this:
- Create a 'double' type variable myATR
- Create an 'int' type constant Multiplo_ATR
- Assign ATR value to variable myATR (Modify Variables block)
- Convert ATR value to pips: write "*(0.1/Point())" in adjust field without quotes.
- In 'Buy now' block, select 'Fixed pips' for Stop-Loss mode
- Write "myATR*Multiplo_ATR" in pips field without quotes.
That should do the work!

notify: @l-andorrà
-
@paragorundu What I need is simply the value of the ATR for distance from the opening price of a position. Will this formula do that?
@l-andorrà did you understand?
-
@tcanuto I agree woth paragorundu. I recommend you to use his system.
-
@tcanuto this formula converts ATR value to a format which can be used as pips. So you can set Stop Loss or Take Profit regarding to ATR value (pips) as I advice. That's what I understand from your request.
-
Thanks @paragorundu and @l-andorrà for the info.
There was a problem with the result. The ATR value is 711, so it should be 711 * 2 = 1422 pips away, but the SL value came out with 4000. See the image below:
Project: https://fxdreema.com/shared/HWHm5SOCd

Project: https://fxdreema.com/shared/HWHm5SOCd

-
Well, I found out that the variable name was wrong. Adjusted. But the SL was too far away but it seems that the result is 10x more. I will try to multiply by 0.01 in EURUSD, because the FxPro is 5 digits.
-
Well, I found out that the variable name was wrong. Adjusted. But the SL was too far away but it seems that the result is 10x more. I will try to multiply by 0.01 in EURUSD, because the FxPro is 5 digits.
@l-andorrà @paragorundu -
Now it worked! Thanks for the help of all of you @l-andorrà @paragorundu

-
@tcanuto happy to hear that
Great! -
@tcanuto You're welcome.