Check sell before buy
-
Hi
I am new to this and hope for some help in the rigth direction
I have a simple long only strategy that opens trades (buy) when price cross an indicator level,
we can call the condition Aand close the trade (sell) when price cross an another indicator
we can call the condition BThe problem is i want to use a filter when enter buy (A)
and A give more than one signal when price rise to a new high and i risk getting in at the end of the moveSo the thing i want to do is to check that B condition has happened just before condition A
so i can act on the first buy signal -
If "happened just before" can be described as something happened in the previous candle, then just set bigger number in "Candle ID" parameter (in Condition click on More settings). MetaTrader knows candles history data and indicators data, so if this data can be used - use it. I mean... in the present moment you ask for information in the past, and this is the best way to do conditions, because the data is always there are can be easily read.
If two conditions should be true at the same time, then connect them one after another.
If you don't know the exact time when B happened (the time between B and A is not the same every time), then you should use variable. Let's say the variable is initially "0" and becomes "1" when B happens. When before checking A you check if that variable is "1"... and then reset it back to "0" for the next turn.
Variables can be defined in "Variables" (see on the right) and modified in many ways (for example "Modify Variables" block). Similar to this, blocks from category "Flags" can be used... they should be used in such situations actually. -
Thanks for the input
