partial close based on candle size of the past
-
Hope you can also help me on the way with this one. I want to partially close an order when it has reached a certain profit level, this profit is based on a candle size from a past candle.
For example:
- I enter on a candle 1 high (buy order):
-When we reach a profit level that is equal to the size of candle 1 than I want to close 50% of trade.
I tried this, but it does not seem to work I used the blocks in the picture, where you see I stored the desired candle under Modify variables.

Hope this is clear.
Thanks in advance.
- I enter on a candle 1 high (buy order):
-
Candle 1 is fixed candle on which trade is opened, or it is changeable candle as market is moving?
-
It is a fixed candle, so when order is opened candle 1 will be used. This same candle still needs to be used after other candles have formed.
-
use on Trade section for storing candle size into variable while Trade is created (pending is triggered) ..

and rest in onTick:

note, that this is working for one trade, when you have opened more trades, you need complicated system of differentiate between trades

-
Thanks for your response. Just a last question regarding your note, saying this will only work on one trade. Do you mean that if I have multiple orders each of them will not have their candle 1 stored separately? I thought the stored variable for one trade is is only connected to that trade, so being unique. Or am I wrong?
-
one variable is holding one value until is changed, when is changed, new value is in this variable

-
Ok thanks, so if I understand it correctly the variable with that specific name will be overridden when a new order is placed as it uses the same variable name.
-
yes, that is how variables works

-
This is the best explanation for what variables are that I know - https://www.youtube.com/watch?v=aeoGGabJhAQ
-
Thanks will have a look at that.
-
Another question about this. I noticed a partial close will create new orders in mt4 so it will replace the existing variable (which is stored in memory). Is there a way to avoid this? I don't want that partial closes will use a new candle 1 to write to an existing variable. Hope it is clear.
-
maybe like this, but I have not tried if it is working


note, block numbers order is important (4,7,10 --- from lowest)