Performing an action after a condition has been met
-
Hello everybody
I want to perform an action ( For example placing a buy order when kijun-sen cross above MA200) after a Primary condition has been met ( for example MA10 cross above MA200 and kijun-sen is under MA200).
Thanks guys. -
Do you mean that those actions should happen at different moments in time?
-
Yes, exactly.
-
@l-andorrà
Yes, exactly. -
@Maysam If they need to happen at different moments, you could try using some bool variables to store the true/false if a condition has been met. If that makes sense.
So, once a condition is met, it flips a bool from false to true (you can do this on the variables tab on the side or in a modify variables block if you wish).
Then you could do the same for the other if you wanted.
Furthermore, if need be, you could have a condition block that simply checks if that bool is set to true or false.
How you'd structure these will be dependent on your need and project, but I hope this helps you find the logic you're looking for, at least.
-
@MrDaisyBates
Thank you dear friend,
Your answer was very helpful. I am trying to see if I can get result with this logic or not. -
@Maysam If not, feel free to share a project link and maybe we can assist you further. Any time you have two conditions being simultaneously being met, two condition blocks is enough. But if you need to allow them to happen in a sequence or at different times, I've had much better luck with bools and simply controlling their state that way.
-
@MrDaisyBates said in Performing an action after a condition has been met:
If not, feel free to share a project link and maybe we can assist you further. Any time you have two conditions being simultaneously being met, two condition blocks is enough. But if you need to allow them to happen in a sequence or at different times, I've had much better luck with bools and simply controlling their state that way.
shared/kIan3J7wb
Thank you again
In this project I want to perform condition #03 When two previous conditions has been met.( conditions #01 , #02) . In fact, when the first two conditions are placed on a candle, the subsequent candles are checked for the establishment of the third condition. -
@Maysam Okay. So. To make sure I'm following.
You want condition 3 to be your signal. The other two are just mandatory criteria that must be met beforehand?
-
-
You can obviously do it as you please, but I'm hoping it illustrates what I mean by the bool logic to make it happen. Basically, if condition 1 isn't met, you can see your bool is set to false. If it is true, we move on to the second condition. And there, if the condition is not true, then we set the bool to false still. However, if the second condition is true, the first one must have also been true to even get to that point.
Then for your execution, you can see all we simply need to do is check if the bool is set to true or false. And if it's set to true, then we check for the signal condition.
-
@MrDaisyBates
Yes, exactly. -
I'm looking at your first condition. You might not want it set to "crosses above" and instead just above/below. At least the way I have it structured anyways. Unless you only want it to happen on that exact candle. "Crosses above" as you know is more of a single signal. If you want that, then you do you. Just a heads up.
-
@MrDaisyBates
The first two conditions are the signal and the third condition is the trigger (entry point). -
@MrDaisyBates
By the way, crosses above is the most important signal condition for me. -
@MrDaisyBates That's exactly what I wanted to say.

