Want to check the distance from latest trade in loop
-
I am trying to find the distance between the latest trade and the current price.
For ex: There are buy trade in group 1 and sell trade in group 2. I want to check on each candle open price, what is the distance between the current open price of candle and the open price of the latest trade in each of the group 1 and group 2. Lets say if the distance between the latest buy position in group 1 is >100 pips then buy position will take place else nothing. Similarly for group 2 also.I hope, my question is clear.
-
@drrohit7b Hello,
Start with this and adjust the pips away block accordingly. Then connect the action you need to block 3. This is for group one, and you will need to duplicate but set another to group 2.

-
I have actually tried it out but it is only for the fixed pips. I want to open trades after 2 conditions have been met.
Condition 1: Current price is more than 100 pips away from the latest open trade in the loop
Condition 2: Run condition 1 only once when new candle opensI have tried out a lot of things but some or the other errors are popping up. If the code is correct then it fails to performs when chosen long only or short only positions.
-
@drrohit7b I suggest you to use a variable to store the open price value of the last closed trade. Then you can use this block to compare that distance:
