Jump to content
Medved Trader Forums
Sign in to follow this  
Stephen

Cross on multiple indicators

Recommended Posts

I have several indicators to trigger buy and sell points.  The indicators each use two lines.  So when all indicator lines cross in the same direction, it's a buy [or sell].  For example, when a 10 SMA crosses a 20 SMA at the same time as the macd signal crosses the macd main, it could be a buy signal.  The problem is that not all lines cross at the same time: the SMA's may cross a candle or two either before or after the macd lines.  I'd like to be able to have the alert come up even if the crosses are not on the exact same candle.  

In the Scan/paintbar editor there is a setting for "candles ago".  Does that setting apply to the cross specifically N number of candles ago, or does that setting apply to a cross *within* the last N candles?




			
		

Share this post


Link to post
Share on other sites

Here's a way to do it. Let's say you want to detect it if within 5 candles at least 2 of 3 crosses happened.

 

You define a FIFOQueue of 15 (5 candles times 3 crosses) capacity. (see https://www.medvedtrader.com/trader/WebHelp/state_keeping.htm - at the bottom of that page - for how to use FIFOQueue in an advanced paintbar or scan)

Then what you do is for each cross you add 1 to the queue if it happened and 0 if it didnt.

The FIFOQueue's Sum property will tell you the result. If it is more than 2, you trigger. If it is less, you don't.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×