Hi, not sure if I understood everything that you want. But this should get you started and is easy enough to adapt. int n = 100; // bars to look for int ma_tf = Period(); int ma_period = 3; int ma_method = MODE_SMA; int min_greenbars = 4; bool stop ...