Zero-Lag Moving Average Arrays For ThinkOrSwim

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/


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:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I added more zero-lag moving averages. You can choose one of them.



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);
def priceMA105 = WMA(WMA(price, 5), 3);
plot ZLMA105 = (2 * priceMA105) - WMA(priceMA105, 3);
def priceMA110 = WMA(WMA(price, 110), 3);
plot ZLMA110 = (2 * priceMA110) - WMA(priceMA110, 110);
def priceMA115 = WMA(WMA(price, 115), 3);
plot ZLMA115 = (2 * priceMA115) - WMA(priceMA115, 115);
def priceMA120 = WMA(WMA(price, 120), 3);
plot ZLMA120 = (2 * priceMA120) - WMA(priceMA120, 120);
def priceMA125 = WMA(WMA(price, 125), 3);
plot ZLMA125 = (2 * priceMA125) - WMA(priceMA125, 125);
def priceMA130 = WMA(WMA(price, 130), 3);
plot ZLMA130 = (2 * priceMA130) - WMA(priceMA130, 130);
def priceMA135 = WMA(WMA(price, 135), 3);
plot ZLMA135 = (2 * priceMA135) - WMA(priceMA135, 135);
def priceMA140 = WMA(WMA(price, 140), 3);
plot ZLMA140 = (2 * priceMA140) - WMA(priceMA140, 140);
def priceMA145 = WMA(WMA(price, 145), 3);
plot ZLMA145 = (2 * priceMA145) - WMA(priceMA145, 145);
def priceMA150 = WMA(WMA(price, 150), 3);
plot ZLMA150 = (2 * priceMA150) - WMA(priceMA150, 150);
def priceMA155 = WMA(WMA(price, 155), 3);
plot ZLMA155 = (2 * priceMA155) - WMA(priceMA155, 155);
def priceMA160 = WMA(WMA(price, 160), 3);
plot ZLMA160 = (2 * priceMA160) - WMA(priceMA160, 160);
def priceMA165 = WMA(WMA(price, 165), 3);
plot ZLMA165 = (2 * priceMA165) - WMA(priceMA165, 165);
def priceMA170 = WMA(WMA(price, 170), 3);
plot ZLMA170 = (2 * priceMA170) - WMA(priceMA170, 170);
def priceMA175 = WMA(WMA(price, 175), 3);
plot ZLMA175 = (2 * priceMA175) - WMA(priceMA175, 175);
def priceMA180 = WMA(WMA(price, 180), 3);
plot ZLMA180 = (2 * priceMA180) - WMA(priceMA180, 180);
def priceMA185 = WMA(WMA(price, 185), 3);
plot ZLMA185 = (2 * priceMA185) - WMA(priceMA185, 185);
def priceMA190 = WMA(WMA(price, 190), 3);
plot ZLMA190 = (2 * priceMA190) - WMA(priceMA190, 190);
def priceMA195 = WMA(WMA(price, 195), 3);
plot ZLMA195 = (2 * priceMA195) - WMA(priceMA195, 195);
def priceMA200 = WMA(WMA(price, 200), 3);
plot ZLMA200 = (2 * priceMA200) - WMA(priceMA200,200);



ZLMA05.AssignValueColor( if ZLMA05 >= ZLMA05[1] and ZLMA05>priceMA200 then color.Green else if ZLMA05 < ZLMA05[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA05<= ZLMA05[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA05 >= ZLMA05[1] and ZLMA05 < ZLMA200 then color.Dark_green else color.gray);

ZLMA07.AssignValueColor( if ZlMA07 >= ZLMA07[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA07 < ZLMA07[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA07<= ZLMA07[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA07 >= ZLMA07[1] and ZLMA05 < ZLMA200 then color.Dark_green else color.gray);


ZLMA10.AssignValueColor( if ZLMA10 >= ZLMA10[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA10 < ZLMA10[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA10<= ZLMA10[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA10 >= ZLMA10[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA15.AssignValueColor( if ZLMA15 >= ZLMA15[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA15 < ZLMA15[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA15<= ZLMA15[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA15 >= ZLMA15[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA20.AssignValueColor( if ZLMA20 >= ZLMA20[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA20 < ZLMA20[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA20<= ZLMA20[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA20 >= ZLMA20[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA25.AssignValueColor( if ZLMA25 >= ZLMA25[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA25 < ZLMA25[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA25<= ZLMA25[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA25 >= ZLMA25[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA30.AssignValueColor( if ZLMA30 >= ZLMA30[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA30 < ZLMA30[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA30<= ZLMA30[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA30 >= ZLMA30[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA35.AssignValueColor( if ZLMA35 >= ZLMA35[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA35 < ZLMA35[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA35<= ZLMA35[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA35 >= ZLMA35[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA40.AssignValueColor( if ZLMA40 >= ZLMA40[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA40 < ZLMA40[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA40<= ZLMA40[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA40 >= ZLMA40[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA45.AssignValueColor( if ZLMA45 >= ZLMA45[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA45 < ZLMA45[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA45<= ZLMA45[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA45 >= ZLMA45[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA50.AssignValueColor( if ZLMA50 >= ZLMA50[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA50 < ZLMA50[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA50<= ZLMA50[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA50 >= ZLMA50[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA55.AssignValueColor( if ZLMA55 >= ZLMA55[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA55 < ZLMA55[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA55<= ZLMA55[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA55 >= ZLMA55[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA60.AssignValueColor( if ZLMA60 >= ZLMA60[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA60 < ZLMA60[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA60<= ZLMA60[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA60 >= ZLMA60[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA65.AssignValueColor( if ZLMA65 >= ZLMA65[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA65 < ZLMA65[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA65<= ZLMA65[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA65 >= ZLMA65[1] and ZLMA05 < priceMA200 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>ZLMA200 then color.Green else if ZLMA90 < ZLMA90[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA90<= ZLMA90[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA80 >= ZLMA90[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA95.AssignValueColor( if ZLMA95 >= ZLMA95[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA95 < ZLMA95[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA95<= ZLMA95[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA95 >= ZLMA95[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA100.AssignValueColor( if ZLMA100 >= ZLMA100[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA100 < ZLMA100[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA100<= ZLMA100[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA100 >= ZLMA100[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA105.AssignValueColor( if ZLMA105 >= ZLMA105[1] and ZLMA05>priceMA200 then color.Green else if ZLMA105 < ZLMA105[1] and ZLMA05>ZLMA100 then color.Dark_red else if ZLMA05<= ZLMA05[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA05 >= ZLMA05[1] and ZLMA05 < ZLMA100 then color.Dark_green else color.gray);


ZLMA110.AssignValueColor( if ZLMA110 >= ZLMA110[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA110 < ZLMA110[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA110<= ZLMA110[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA110 >= ZLMA110[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA115.AssignValueColor( if ZLMA115 >= ZLMA115[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA115 < ZLMA115[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA115<= ZLMA115[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA115 >= ZLMA115[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA120.AssignValueColor( if ZLMA120 >= ZLMA120[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA120 < ZLMA120[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA120<= ZLMA120[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA120 >= ZLMA120[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA125.AssignValueColor( if ZLMA125 >= ZLMA125[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA125 < ZLMA125[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA125<= ZLMA125[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA125 >= ZLMA125[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA130.AssignValueColor( if ZLMA130 >= ZLMA130[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA130 < ZLMA130[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA30<= ZLMA130[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA130 >= ZLMA130[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA135.AssignValueColor( if ZLMA135 >= ZLMA135[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA135 < ZLMA135[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA135<= ZLMA135[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA135 >= ZLMA135[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA140.AssignValueColor( if ZLMA140 >= ZLMA140[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA140 < ZLMA140[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA140<= ZLMA140[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA140 >= ZLMA140[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA145.AssignValueColor( if ZLMA145 >= ZLMA145[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA145 < ZLMA145[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA145<= ZLMA145[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA145 >= ZLMA145[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA150.AssignValueColor( if ZLMA150 >= ZLMA150[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA150 < ZLMA150[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA150<= ZLMA150[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA150 >= ZLMA150[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA155.AssignValueColor( if ZLMA155 >= ZLMA155[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA155 < ZLMA155[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA155<= ZLMA155[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA155 >= ZLMA155[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA160.AssignValueColor( if ZLMA160 >= ZLMA160[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA160 < ZLMA160[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA160<= ZLMA160[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA160 >= ZLMA160[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA165.AssignValueColor( if ZLMA165 >= ZLMA165[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA165 < ZLMA165[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA65<= ZLMA165[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA165 >= ZLMA165[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA170.AssignValueColor( if ZLMA170 >= ZLMA170[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA170 < ZLMA170[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA170<= ZLMA170[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA170 >= ZLMA170[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA175.AssignValueColor( if ZLMA175 >= ZLMA175[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA175 < ZLMA175[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA175<= ZLMA175[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA175 >= ZLMA175[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);


ZLMA180.AssignValueColor( if ZLMA180 >= ZLMA180[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA180 < ZLMA180[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA180<= ZLMA180[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA180 >= ZLMA180[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA185.AssignValueColor( if ZLMA185 >= ZLMA185[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA185 < ZLMA185[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA185<= ZLMA185[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA185 >= ZLMA185[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA190.AssignValueColor( if ZLMA190 >= ZLMA190[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA190 < ZLMA190[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA190<= ZLMA190[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA190 >= ZLMA190[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA195.AssignValueColor( if ZLMA195 >= ZLMA195[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA195 < ZLMA195[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA195<= ZLMA195[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA195 >= ZLMA195[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);

ZLMA200.AssignValueColor( if ZLMA200 >= ZLMA200[1] and ZLMA05>ZLMA200 then color.Green else if ZLMA200 < ZLMA200[1] and ZLMA05>ZLMA200 then color.Dark_red else if ZLMA200<= ZLMA200[1] and ZLMA05 <ZLMA200 then color.red else if ZLMA200 >= ZLMA200[1] and ZLMA05 < priceMA200 then color.Dark_green else color.gray);
 
Last edited by a moderator:
I removed some moving averages. Here is a new version from 5-day moving average to 50-day average. Enjoy your successful trading.

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);



ZLMA05.AssignValueColor( if ZLMA05 >= ZLMA05[1] and ZLMA05>priceMA50 then color.Green else if ZLMA05 < ZLMA05[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA05<= ZLMA05[1] and ZLMA05 <ZLMA50then color.red else if ZLMA05 >= ZLMA05[1] and ZLMA05 < ZLMA50 then color.Dark_green else color.gray);



ZLMA07.AssignValueColor( if ZlMA07 >= ZLMA07[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA07 < ZLMA07[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA07<= ZLMA07[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA07 >= ZLMA07[1] and ZLMA05 < ZLMA50 then color.Dark_green else color.gray);



ZLMA10.AssignValueColor( if ZLMA10 >= ZLMA10[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA10 < ZLMA10[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA10<= ZLMA10[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA10 >= ZLMA10[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA15.AssignValueColor( if ZLMA15 >= ZLMA15[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA15 < ZLMA15[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA15<= ZLMA15[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA15 >= ZLMA15[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA20.AssignValueColor( if ZLMA20 >= ZLMA20[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA20 < ZLMA20[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA20<= ZLMA20[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA20 >= ZLMA20[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA25.AssignValueColor( if ZLMA25 >= ZLMA25[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA25 < ZLMA25[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA25<= ZLMA25[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA25 >= ZLMA25[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA30.AssignValueColor( if ZLMA30 >= ZLMA30[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA30 < ZLMA30[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA30<= ZLMA30[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA30 >= ZLMA30[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA35.AssignValueColor( if ZLMA35 >= ZLMA35[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA35 < ZLMA35[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA35<= ZLMA35[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA35 >= ZLMA35[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);





ZLMA40.AssignValueColor( if ZLMA40 >= ZLMA40[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA40 < ZLMA40[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA40<= ZLMA40[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA40 >= ZLMA40[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA45.AssignValueColor( if ZLMA45 >= ZLMA45[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA45 < ZLMA45[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA45<= ZLMA45[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA45 >= ZLMA45[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA50.AssignValueColor( if ZLMA50 >= ZLMA50[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA50 < ZLMA50[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA50<= ZLMA50[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA50 >= ZLMA50[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);

[CODE=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);



ZLMA05.AssignValueColor( if ZLMA05 >= ZLMA05[1] and ZLMA05>priceMA50 then color.Green else if ZLMA05 < ZLMA05[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA05<= ZLMA05[1] and ZLMA05 <ZLMA50then color.red else if ZLMA05 >= ZLMA05[1] and ZLMA05 < ZLMA50 then color.Dark_green else color.gray);



ZLMA07.AssignValueColor( if ZlMA07 >= ZLMA07[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA07 < ZLMA07[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA07<= ZLMA07[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA07 >= ZLMA07[1] and ZLMA05 < ZLMA50 then color.Dark_green else color.gray);



ZLMA10.AssignValueColor( if ZLMA10 >= ZLMA10[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA10 < ZLMA10[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA10<= ZLMA10[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA10 >= ZLMA10[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA15.AssignValueColor( if ZLMA15 >= ZLMA15[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA15 < ZLMA15[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA15<= ZLMA15[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA15 >= ZLMA15[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA20.AssignValueColor( if ZLMA20 >= ZLMA20[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA20 < ZLMA20[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA20<= ZLMA20[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA20 >= ZLMA20[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA25.AssignValueColor( if ZLMA25 >= ZLMA25[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA25 < ZLMA25[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA25<= ZLMA25[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA25 >= ZLMA25[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA30.AssignValueColor( if ZLMA30 >= ZLMA30[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA30 < ZLMA30[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA30<= ZLMA30[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA30 >= ZLMA30[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA35.AssignValueColor( if ZLMA35 >= ZLMA35[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA35 < ZLMA35[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA35<= ZLMA35[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA35 >= ZLMA35[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);





ZLMA40.AssignValueColor( if ZLMA40 >= ZLMA40[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA40 < ZLMA40[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA40<= ZLMA40[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA40 >= ZLMA40[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA45.AssignValueColor( if ZLMA45 >= ZLMA45[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA45 < ZLMA45[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA45<= ZLMA45[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA45 >= ZLMA45[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);



ZLMA50.AssignValueColor( if ZLMA50 >= ZLMA50[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA50 < ZLMA50[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA50<= ZLMA50[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA50 >= ZLMA50[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);
[/CODE]
 
Last edited:
I removed some moving averages. Here is a new version from 5-day moving average to 50-day average. Enjoy your successful trading.

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);

ZLMA05.AssignValueColor( if ZLMA05 >= ZLMA05[1] and ZLMA05>priceMA50 then color.Green else if ZLMA05 < ZLMA05[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA05<= ZLMA05[1] and ZLMA05 <ZLMA50then color.red else if ZLMA05 >= ZLMA05[1] and ZLMA05 < ZLMA50 then color.Dark_green else color.gray);

ZLMA07.AssignValueColor( if ZlMA07 >= ZLMA07[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA07 < ZLMA07[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA07<= ZLMA07[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA07 >= ZLMA07[1] and ZLMA05 < ZLMA50 then color.Dark_green else color.gray);

ZLMA10.AssignValueColor( if ZLMA10 >= ZLMA10[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA10 < ZLMA10[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA10<= ZLMA10[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA10 >= ZLMA10[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);

ZLMA15.AssignValueColor( if ZLMA15 >= ZLMA15[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA15 < ZLMA15[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA15<= ZLMA15[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA15 >= ZLMA15[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);

ZLMA20.AssignValueColor( if ZLMA20 >= ZLMA20[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA20 < ZLMA20[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA20<= ZLMA20[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA20 >= ZLMA20[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);

ZLMA25.AssignValueColor( if ZLMA25 >= ZLMA25[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA25 < ZLMA25[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA25<= ZLMA25[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA25 >= ZLMA25[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);

ZLMA30.AssignValueColor( if ZLMA30 >= ZLMA30[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA30 < ZLMA30[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA30<= ZLMA30[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA30 >= ZLMA30[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);

ZLMA35.AssignValueColor( if ZLMA35 >= ZLMA35[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA35 < ZLMA35[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA35<= ZLMA35[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA35 >= ZLMA35[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);


ZLMA40.AssignValueColor( if ZLMA40 >= ZLMA40[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA40 < ZLMA40[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA40<= ZLMA40[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA40 >= ZLMA40[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);

ZLMA45.AssignValueColor( if ZLMA45 >= ZLMA45[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA45 < ZLMA45[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA45<= ZLMA45[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA45 >= ZLMA45[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);

ZLMA50.AssignValueColor( if ZLMA50 >= ZLMA50[1] and ZLMA05>ZLMA50 then color.Green else if ZLMA50 < ZLMA50[1] and ZLMA05>ZLMA50 then color.Dark_red else if ZLMA50<= ZLMA50[1] and ZLMA05 <ZLMA50 then color.red else if ZLMA50 >= ZLMA50[1] and ZLMA05 < priceMA50 then color.Dark_green else color.gray);
Daryl Guppy invented the Guppy MMA over twenty ago? He used 6 short term ema's and 6 long term Ema's. Adding more ma's only uses up more computer resources . Also just use the difference between the present MA vs the value of the MA 1 day ago, 4 colors Cyan / Magenta for short term Blue / Red for the long term
Code:
declare Lower;
input price = Close;
input dotsize = 3;
def priceMA05 = WMA(WMA(price, 5), 3);
def ZLMA05 = (2 * priceMA05) - WMA(priceMA05, 5);
def priceMA07 = WMA(WMA(price, 7), 3);
def ZLMA07 = (2 * priceMA07) - WMA(priceMA07, 7);
def priceMA10 = WMA(WMA(price, 10), 3);
def ZLMA10 = (2 * priceMA10) - WMA(priceMA10, 10);
def priceMA15 = WMA(WMA(price, 15), 3);
def ZLMA15 = (2 * priceMA15) - WMA(priceMA15, 15);
def priceMA20 = WMA(WMA(price, 20), 3);
def ZLMA20 = (2 * priceMA20) - WMA(priceMA20, 20);
def priceMA25 = WMA(WMA(price, 25), 3);
def ZLMA25 = (2 * priceMA25) - WMA(priceMA25, 25);
def priceMA30 = WMA(WMA(price, 30), 3);
def ZLMA30 = (2 * priceMA30) - WMA(priceMA30, 30);
def priceMA35 = WMA(WMA(price, 35), 3);
def ZLMA35 = (2 * priceMA35) - WMA(priceMA35, 35);
def priceMA40 = WMA(WMA(price, 40), 3);
def ZLMA40 = (2 * priceMA40) - WMA(priceMA40, 40);
def priceMA45 = WMA(WMA(price, 45), 3);
def ZLMA45 = (2 * priceMA45) - WMA(priceMA45, 45);
def priceMA50 = WMA(WMA(price, 50), 3);
def ZLMA50 = (2 * priceMA50) - WMA(priceMA50, 50);
def priceMA55 = WMA(WMA(price, 55), 3);
def ZLMA55 = (2 * priceMA55) - WMA(priceMA55, 55);
def priceMA60 = WMA(WMA(price, 60), 3);
def ZLMA60 = (2 * priceMA60) - WMA(priceMA60, 60);
def priceMA65 = WMA(WMA(price, 65), 3);
def ZLMA65 = (2 * priceMA65) - WMA(priceMA65, 65);
def priceMA70 = WMA(WMA(price, 75), 3);
def ZLMA70 = (2 * priceMA70) - WMA(priceMA70, 70);
def priceMA75 = WMA(WMA(price, 75), 3);
def ZLMA75 = (2 * priceMA75) - WMA(priceMA75, 75);
def priceMA80 = WMA(WMA(price, 80), 3);
def ZLMA80 = (2 * priceMA80) - WMA(priceMA80, 80);
def priceMA85 = WMA(WMA(price, 85), 3);
def ZLMA85 = (2 * priceMA85) - WMA(priceMA85, 85);
def priceMA90 = WMA(WMA(price, 90), 3);
def ZLMA90 = (2 * priceMA90) - WMA(priceMA90,90);
def priceMA95 = WMA(WMA(price, 95), 3);
def ZLMA95 = (2 * priceMA95) - WMA(priceMA95, 95);
def priceMA100 = WMA(WMA(price, 100), 3);
def ZLMA100 = (2 * priceMA100) - WMA(priceMA100, 100);
plot ZLMA05Dot = if IsNaN(Close) then Double.NaN else 1;
ZLMA05Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA05Dot.SetLineWeight(DotSize);
ZLMA05Dot.AssignValueColor( if ZLMA05 >= ZLMA05[1] then color.Cyan else color.Magenta);
plot ZLMA07Dot = if IsNaN(Close) then Double.NaN else 2;
ZLMA07Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA07Dot.SetLineWeight(DotSize);
ZLMA07DOT.AssignValueColor( if ZlMA07 >= ZLMA07[1] then color.Cyan else color.Magenta);
plot ZLMA10Dot = if IsNaN(Close) then Double.NaN else 3;
ZLMA10Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA10Dot.SetLineWeight(DotSize);
ZLMA10DOT.AssignValueColor( if ZLMA10 >= ZLMA10[1] then color.Cyan else color.Magenta);
plot ZLMA15Dot = if IsNaN(Close) then Double.NaN else 4;
ZLMA15Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA15Dot.SetLineWeight(DotSize);
ZLMA15DOT.AssignValueColor( if ZLMA15 >= ZLMA15[1] then color.Cyan else color.Magenta);
plot ZLMA20Dot = if IsNaN(Close) then Double.NaN else 5;
ZLMA20Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA20Dot.SetLineWeight(DotSize);
ZLMA20DOT.AssignValueColor( if ZLMA20 >= ZLMA20[1] then color.Cyan else color.Magenta);
plot ZLMA25Dot = if IsNaN(Close) then Double.NaN else 6;
ZLMA25Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA25Dot.SetLineWeight(DotSize);
ZLMA25Dot.AssignValueColor( if ZLMA25 >= ZLMA25[1] then color.Cyan else color.Magenta);
plot ZLMA30Dot = if IsNaN(Close) then Double.NaN else 7;
ZLMA30Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA30Dot.SetLineWeight(DotSize);
ZLMA30Dot.AssignValueColor( if ZLMA30 >= ZLMA30[1] then color.Blue else color.red);
plot ZLMA35Dot = if IsNaN(Close) then Double.NaN else 8;
ZLMA35Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA35Dot.SetLineWeight(DotSize);
ZLMA35Dot.AssignValueColor( if ZLMA35 >= ZLMA35[1] then color.Blue else color.red);
plot ZLMA40Dot = if IsNaN(Close) then Double.NaN else 9;
ZLMA40Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA40Dot.SetLineWeight(DotSize);
ZLMA40Dot.AssignValueColor( if ZLMA40 >= ZLMA40[1] then color.Blue else color.red);
plot ZLMA45Dot = if IsNaN(Close) then Double.NaN else 10;
ZLMA45Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA45Dot.SetLineWeight(DotSize);
ZLMA45Dot.AssignValueColor( if ZLMA45 >= ZLMA45[1] then color.Blue else color.red);
plot ZLMA50Dot = if IsNaN(Close) then Double.NaN else 11;
ZLMA50Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA50Dot.SetLineWeight(DotSize);
ZLMA50Dot.AssignValueColor( if ZLMA50 >= ZLMA50[1] then color.Blue else color.red);
plot ZLMA55Dot = if IsNaN(Close) then Double.NaN else 12;
ZLMA55Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA55Dot.SetLineWeight(DotSize);
ZLMA55Dot.AssignValueColor( if ZLMA55 >= ZLMA55[1] then color.Blue else color.red);
plot ZLMA60Dot = if IsNaN(Close) then Double.NaN else 13;
ZLMA60Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA60Dot.SetLineWeight(DotSize);
ZLMA60Dot.AssignValueColor( if ZLMA60 >= ZLMA60[1] then color.Blue else color.red);
plot ZLMA65Dot = if IsNaN(Close) then Double.NaN else 14;
ZLMA65Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA65Dot.SetLineWeight(DotSize);
ZLMA65Dot.AssignValueColor( if ZLMA65 >= ZLMA65[1] then color.Yellow else color.Dark_Orange);
plot ZLMA70Dot = if IsNaN(Close) then Double.NaN else 15;
ZLMA70Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA70Dot.SetLineWeight(DotSize);
ZLMA70Dot.AssignValueColor( if ZLMA70 >= ZLMA70[1] then color.Yellow else color.Dark_Orange);
plot ZLMA75Dot = if IsNaN(Close) then Double.NaN else 16;
ZLMA75Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA75Dot.SetLineWeight(DotSize);
ZLMA75Dot.AssignValueColor( if ZLMA75 >= ZLMA75[1] then color.Yellow else color.Dark_Orange);
plot ZLMA80Dot = if IsNaN(Close) then Double.NaN else 17;
ZLMA80Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA80Dot.SetLineWeight(DotSize);
ZLMA80Dot.AssignValueColor( if ZLMA80 >= ZLMA80[1] then color.Yellow else color.Dark_Orange);
plot ZLMA85Dot = if IsNaN(Close) then Double.NaN else 18;
ZLMA85Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA85Dot.SetLineWeight(DotSize);
ZLMA85Dot.AssignValueColor( if ZLMA85 >= ZLMA85[1] then color.Yellow else color.Dark_Orange);
plot ZLMA90Dot = if IsNaN(Close) then Double.NaN else 19;
ZLMA90Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA90Dot.SetLineWeight(DotSize);
ZLMA90Dot.AssignValueColor( if ZLMA90 >= ZLMA90[1] then color.Yellow else color.Dark_Orange);
plot ZLMA95Dot = if IsNaN(Close) then Double.NaN else 20;
ZLMA95Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA95Dot.SetLineWeight(DotSize);
ZLMA95Dot.AssignValueColor( if ZLMA95 >= ZLMA95[1] then color.Yellow else color.Dark_Orange);
plot ZLMA100Dot = if IsNaN(Close) then Double.NaN else 21;
ZLMA100Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
ZLMA100Dot.SetLineWeight(DotSize);
ZLMA100Dot.AssignValueColor( if ZLMA100 >= ZLMA100[1] then color.Yellow else color.Dark_Orange);
 
This indicator is not based on an exponential moving average (EMA), which has time delay. You can modify the codes as you would like in order to use 6 short-term moving averages and 6 long-term moving averages. It is very easy to do that with my present codes.
 
Last edited:
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/

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);
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);

Taking the average of an average does not give you 0 lag. It just smoothes out the inner average a little bit, and delays signals.
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
441 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top