That's an interesting challenge! Unfortunately I don't have time to take it on myself, but here is some code that might help you get started with the idea if you can't find someone to help - this is one way to detect if an MA has crossed over two others:
Code: Select all
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ZenAndTheArtOfTrading / www.PineScriptMastery.com
// @version=4
study("MA Double-Cross", overlay=true)
// Get indicator values
ema1 = ema(close, 20)
ema2 = ema(close, 50)
ema3 = ema(close, 100)
// Declare cross variables
var crossedMA2 = false
cross = false
// Check if we've crossed MA2 then set flag
if cross(ema1, ema2) and not crossedMA2
crossedMA2 := true
else
crossedMA2 := false
// Check if we've crossed MA3 after first crossing MA2
if cross(ema1, ema3)
cross := true
crossedMA2 := false
// Change color if double-cross is confirmed
bgcolor(cross ? color.new(color.red,50) : na)
// Draw MAs
plot(ema1, color=color.green)
plot(ema2, color=color.orange)
plot(ema3, color=color.red)