Pending order based on price moving a percentage of ATR after a previous condition is met
-
Hello.
I am using pending orders to set a buy or sell stop after a certain condition is met at any time when trading is open. I would like the order to position at the price point based on a percentage of the ATR. The pending order block has custom price not custom price fraction so the penidng order is placed at a price that is equal to the ATR and not the price amount based on the ATR.
Does anyone have any suggestions to help with this? As so far I am struggling to solve it.
Thanks very much.
-
@mikev_303 Can you please share your project to take a look at it?
-
@l-andorrà Hello. Thanks for your help. Please see below.
-
@mikev_303 The logic is initially correct. What is the problem exactly?
-
@l-andorrà when the pending order is placed, the price level it is placed at is the actual ATR and not the price level the indicator was crossed over at plus or minus the ATR value.
So if the ATR was 40 pips and price was 0.6958 then it should put a pending order at 6978 (0.5 the ATR value) instead it places a pending order at 0.0020
The problem I see is the price function in the pending order is for custom price and not custom price fraction.
Not sure how to solve it.
-
@mikev_303 Ok. I see. Then wou will need to do that calculation in a previous block and store the result into a variable. This variable should then be embedded into the 'custom price' position of the blocks istead of its current setting.
-
@l-andorrà thanks very much. Looks like I need to learn something new. I haven't created a variable before, ill gove it a go and see what happens.
Hopefully it turns out ok. Thanks very much for your help.
-
@mikev_303 Try it and then come back for us to check it out. I'll be glad to review it.

-
Hello @l-andorrà I've written some variables. It is not working out for me at the moment and i'm not sure what i'm doing wrong.
I've tried to create what i talked about above. I've posted what I have done below.
-
@mikev_303 I see you are using a variable called 'Variable4' in block 12 but then it is not used anywhere else. Is this the whole project or just a part of it?
-
@l-andorrà I have used 'Vatiable4' in blocks 10 and 15 at the start in the adjust part of the open at price section
Thanks.
-
@mikev_303 Ok. You need to add the '*' symbol before it. You should insert '*Variable4' with no blank space in the 'Adjust' box.
-
@l-andorrà Thanks, did that, but it still not placing pending orders when I run it in simulation.
Any other suggestions?
-
@mikev_303 ATR is not a price level
edit: oh you knew that
-
-
@roar Hi. Thanks verymuch for your help. It's amazing when you see what you weren't doing it suddenly seems so simple. Much appreciated.
-
@roar I've managed to get the code just about right. However, the sell pending order is placing the sell stop on the wrong side of the moving average line, in the code I have tried to subtract the ATR away from the price when price crosses over the moving average line. However, no matter what I've tried it always adds it on instead, in the same manner it does in the buy pending order when the price crossed about the moving average line.
Not sure why it is adding the ATR onto price regardless of the code saying add or subtract.
https://fxdreema.com/shared/G4yZcl5zd
Thanks.
-
@mikev_303 you have calculated the correct levels into buy and sell variables. Now you dont have to use ATR + adjust in the order block, just insert the level as custom price:
