petergluis
Active member
I wrote a new indicator based on Zero-lag moving average. I call it Zero-lag Moving Average Rainbow or Array. You can choose the price that you prefer (close, high, low, open, WMA, etc). Enjoy your successful trading.
https://usethinkscript.com/threads/redk-dual-color-zero-lag-moving-average-for-thinkorswim.10113/
https://usethinkscript.com/threads/redk-dual-color-zero-lag-moving-average-for-thinkorswim.10113/
Ruby:
input price = close;
def priceMA05 = WMA(WMA(price, 5), 3);
plot ZLMA05 = (2 * priceMA05) - WMA(priceMA05, 5);
def priceMA07 = WMA(WMA(price, 7), 3);
plot ZLMA07 = (2 * priceMA07) - WMA(priceMA07, 7);
def priceMA10 = WMA(WMA(price, 10), 3);
plot ZLMA10 = (2 * priceMA10) - WMA(priceMA10, 10);
def priceMA15 = WMA(WMA(price, 15), 3);
plot ZLMA15 = (2 * priceMA15) - WMA(priceMA15, 15);
def priceMA20 = WMA(WMA(price, 20), 3);
plot ZLMA20 = (2 * priceMA20) - WMA(priceMA20, 20);
def priceMA25 = WMA(WMA(price, 25), 3);
plot ZLMA25 = (2 * priceMA25) - WMA(priceMA25, 25);
def priceMA30 = WMA(WMA(price, 30), 3);
plot ZLMA30 = (2 * priceMA30) - WMA(priceMA30, 30);
def priceMA35 = WMA(WMA(price, 35), 3);
plot ZLMA35 = (2 * priceMA35) - WMA(priceMA35, 35);
def priceMA40 = WMA(WMA(price, 40), 3);
plot ZLMA40 = (2 * priceMA40) - WMA(priceMA40, 40);
def priceMA45 = WMA(WMA(price, 45), 3);
plot ZLMA45 = (2 * priceMA45) - WMA(priceMA45, 45);
def priceMA50 = WMA(WMA(price, 50), 3);
plot ZLMA50 = (2 * priceMA50) - WMA(priceMA50, 50);
def priceMA55 = WMA(WMA(price, 55), 3);
plot ZLMA55 = (2 * priceMA55) - WMA(priceMA55, 55);
def priceMA60 = WMA(WMA(price, 60), 3);
plot ZLMA60 = (2 * priceMA60) - WMA(priceMA60, 60);
def priceMA65 = WMA(WMA(price, 65), 3);
plot ZLMA65 = (2 * priceMA65) - WMA(priceMA65, 65);
def priceMA70 = WMA(WMA(price, 75), 3);
plot ZLMA70 = (2 * priceMA70) - WMA(priceMA70, 70);
def priceMA75 = WMA(WMA(price, 75), 3);
plot ZLMA75 = (2 * priceMA75) - WMA(priceMA75, 75);
def priceMA80 = WMA(WMA(price, 80), 3);
plot ZLMA80 = (2 * priceMA80) - WMA(priceMA80, 80);
def priceMA85 = WMA(WMA(price, 85), 3);
plot ZLMA85 = (2 * priceMA85) - WMA(priceMA85, 85);
def priceMA90 = WMA(WMA(price, 90), 3);
plot ZLMA90 = (2 * priceMA90) - WMA(priceMA90,90);
def priceMA95 = WMA(WMA(price, 95), 3);
plot ZLMA95 = (2 * priceMA95) - WMA(priceMA95, 95);
def priceMA100 = WMA(WMA(price, 100), 3);
plot ZLMA100 = (2 * priceMA100) - WMA(priceMA100, 100);
ZLMA05.AssignValueColor( if ZLMA05 >= ZLMA05[1] and ZLMA05>priceMA100 then color.Green else if ZLMA05 < ZLMA05[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA05<= ZLMA05[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA05 >= ZLMA05[1] and ZLMA05 < ZLMA100 then color.Dark_green else color.gray);
ZLMA07.AssignValueColor( if ZlMA07 >= ZLMA07[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA07 < ZLMA07[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA07<= ZLMA07[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA07 >= ZLMA07[1] and ZLMA05 < ZLMA100 then color.Dark_green else color.gray);
ZLMA10.AssignValueColor( if ZLMA10 >= ZLMA10[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA10 < ZLMA10[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA10<= ZLMA10[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA10 >= ZLMA10[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA15.AssignValueColor( if ZLMA15 >= ZLMA15[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA15 < ZLMA15[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA15<= ZLMA15[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA15 >= ZLMA15[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA20.AssignValueColor( if ZLMA20 >= ZLMA20[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA20 < ZLMA20[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA20<= ZLMA20[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA20 >= ZLMA20[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA25.AssignValueColor( if ZLMA25 >= ZLMA25[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA25 < ZLMA25[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA25<= ZLMA25[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA25 >= ZLMA25[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA30.AssignValueColor( if ZLMA30 >= ZLMA30[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA30 < ZLMA30[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA30<= ZLMA30[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA30 >= ZLMA30[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA35.AssignValueColor( if ZLMA35 >= ZLMA35[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA35 < ZLMA35[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA35<= ZLMA35[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA35 >= ZLMA35[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA40.AssignValueColor( if ZLMA40 >= ZLMA40[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA40 < ZLMA40[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA40<= ZLMA40[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA40 >= ZLMA40[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA45.AssignValueColor( if ZLMA45 >= ZLMA45[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA45 < ZLMA45[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA45<= ZLMA45[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA45 >= ZLMA45[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA50.AssignValueColor( if ZLMA50 >= ZLMA50[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA50 < ZLMA50[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA50<= ZLMA50[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA50 >= ZLMA50[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA55.AssignValueColor( if ZLMA55 >= ZLMA55[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA55 < ZLMA55[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA55<= ZLMA55[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA55 >= ZLMA55[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA60.AssignValueColor( if ZLMA60 >= ZLMA60[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA60 < ZLMA60[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA60<= ZLMA60[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA60 >= ZLMA60[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA65.AssignValueColor( if ZLMA65 >= ZLMA65[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA65 < ZLMA65[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA65<= ZLMA65[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA65 >= ZLMA65[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA70.AssignValueColor( if ZLMA70 >= ZLMA70[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA70 < ZLMA70[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA70<= ZLMA70[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA70 >= ZLMA70[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA75.AssignValueColor( if ZLMA75 >= ZLMA75[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA75 < ZLMA75[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA75<= ZLMA75[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA75 >= ZLMA75[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA80.AssignValueColor( if ZLMA80 >= ZLMA80[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA80 < ZLMA80[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA80<= ZLMA80[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA80 >= ZLMA80[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA85.AssignValueColor( if ZLMA85 >= ZLMA85[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA85 < ZLMA85[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA85<= ZLMA85[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA85 >= ZLMA85[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA90.AssignValueColor( if ZLMA90 >= ZLMA90[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA90 < ZLMA90[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA90<= ZLMA90[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA90 >= ZLMA90[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA95.AssignValueColor( if ZLMA95 >= ZLMA95[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA95 < ZLMA95[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA95<= ZLMA95[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA95 >= ZLMA95[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
ZLMA100.AssignValueColor( if ZLMA100 >= ZLMA100[1] and ZLMA05>ZLMA100 then color.Green else if ZLMA100 < ZLMA100[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA100<= ZLMA100[1] and ZLMA05 <ZLMA100 then color.red else if ZLMA100 >= ZLMA100[1] and ZLMA05 < priceMA100 then color.Dark_green else color.gray);
Last edited by a moderator: