Ignoring signal if there is no low below the entry price within the next 2 bar

how to Ignore entry signal if there is no low below the entry price within the next 2 bars ,vice versa for short trades,mainly for backtesting ,to determine fiseablity of fill or kill order type.

The Ref function can be used with a positive value range to look ahead to get values from future bars. A combination of that and LLV should get you what you're after.

Eg

LowestLowInNextTwoBars = Ref(LLV(L, 2), 2);
EntryPrice = C; // Or whatever you are using
NoEntry = LowestLowInNextTwoBars < EntryPrice;

Buy = 	Cross(MA(C, 5), MA(C, 10))  // Your criteria here
		AND NOT NoEntry;    // Only allow entry if NoEntry is False

Filter = 1;
AddColumn(L, "Low");
AddColumn(LowestLowInNextTwoBars, "LowestLowInNextTwoBars");

image

Normal caveats regarding overestimating results when looking ahead apply.

2 Likes

Just noticed it was:

you were after. In which case in the above code, you should use greater than:

NoEntry = LowestLowInNextTwoBars > EntryPrice;

1 Like

@HelixTrader gave you coding solution but it is just fantasy, not realizable in practice.

@Niftyalpha how exactly can you change the PAST ???
What you asked for is impossible to do in real-life. Once you placed the order that got filled, you can’t suddenly turn back the clock and cancel the trade done 2 days ago.

What you can do is NOT to act upon signal immediately but DELAY it for 1-2 bars to verify if the condition you set is valid. Something like

Setup = Cross( MA( C, 5 ), MA( C, 10 ) );

// only enter if signal was generated one or two bars ago and low is lower than entry 
Buy = ( Ref( Setup, -1 ) OR Ref( Setup, -2 ) ) AND Low < ValueWhen( Setup, Close );
1 Like

The trading platform i use ,which receives signals from Amibroker via an api ,has the capability of modifying (replace to market order or cancel )the initial order after a pre determined time ,I use it for intraday trading.

But that is not what you asked for originally and not what @HelixTrader provided “solution” for. You did not write that you place the limit order that is NOT filled and you really just need to cancel it if limit is not hit. There is a Knowledge Base article that covers backtesting limit orders - use search.

1 Like