FearZone GreedZone For ThinkOrSwim

Can someone convert this indicator?
https://www.tradingview.com/script/KcegW4xu-Fearzone-Expo-Contrarian-Indicator/

and combine it with this indicator?
https://usethinkscript.com/threads/convert-tradingview-greedzone-indicator.15817/

Can anyone please convert , i would be really grateful to you
check the below.

CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © Zeiierman
#//Copyright by Zeiierman.
#//The information contained in my scripts/indicators/ideas does not constitute financial advice or a solicitation to buy or sell any securities of any type.
#//I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from use of or reliance on such information.
#//All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, or individual’s trading does not guarantee future results or returns.
#//Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
#//My scripts/indicators/ideas are only for educational purposes!
#study("Fearzone (Expo) - Contrarian Indicator", overlay=true, shorttitle="FearZone (Expo)")
#study("GreedZone indicator ", overlay=true, shorttitle="GreedZone (Expo)")
# Converted and mod by Sam4Cok@Samer800     - 06/2023

input ShowZonezStyle   = {Default "Candle Sticks", "Wedges", "Don't Show"};
input ZonesStartAlert = {Default Dots, Arrows, "Don't Show"};
input source = ohlc4;            # "Source"
input FearzoneMovAvgType  = AverageType.SIMPLE;
input FearzonePeriod = 30;         # "Fearzone Period"
input FearzoneStdevPeriod = 50;    # "Stdev Period Fearzone"
input GreedZoneMovAvgType  = AverageType.SIMPLE;
input GreedZonePeriod = 30;        # "GreedZone Period"
input GreedZoneStdevPeriod = 50;   # "Stdev Period GreedZone"

def na = Double.NaN;
def tr = TrueRange(high, close, low);
def Candlesticks = ShowZonezStyle==ShowZonezStyle."Candle Sticks";
def Wedges = ShowZonezStyle==ShowZonezStyle."Wedges";
def dots = ZonesStartAlert==ZonesStartAlert.Dots;
def AlertCircle = ZonesStartAlert!=ZonesStartAlert."Don't Show";

DefineGlobalColor("up", CreateColor(38,166,154));
DefineGlobalColor("dn", CreateColor(239,83,80));

#// Condition One - Fear
def HZone = Highest(source, FearzonePeriod);
def FZ1 = (HZone - source) / HZone;
def FAVG1 = MovingAverage(FearzoneMovAvgType, FZ1, FearzoneStdevperiod);
def FSTDEV1 = StDev(FZ1, FearzoneStdevperiod);
def FZ1Limit = FAVG1 + FSTDEV1;
#// Condition One - Greed
def LZone = lowest(source, GreedZonePeriod);
def GZ1 = (LZone - source)/ LZone;
def GAVG1 = MovingAverage(GreedZoneMovAvgType, GZ1, GreedZoneStdevperiod);
def GSTDEV1 = StDev(GZ1, GreedZoneStdevperiod);
def GZ1Limit = GAVG1 - GSTDEV1;
#// Condition Two - Fear
def FZ2 = MovingAverage(FearzoneMovAvgType, source, FearzonePeriod);
def FAVG2 = MovingAverage(FearzoneMovAvgType, FZ2, FearzoneStdevperiod);
def FSTDEV2 = StDev(FZ2, FearzoneStdevperiod);
def FZ2Limit = FAVG2 - FSTDEV2;
#// Condition Two - Greed
def GZ2 = MovingAverage(GreedZoneMovAvgType, source, GreedZonePeriod);
def GAVG2 = MovingAverage(GreedZoneMovAvgType, GZ2, GreedZoneStdevperiod);
def GSTDEV2 = StDev(GZ2, GreedZoneStdevperiod);
def GZ2Limit = GAVG2 + GSTDEV2;
#// FearZone
def Fearzone_Con = FZ1 > FZ1Limit and FZ2 < FZ2Limit;
def FearZoneOpen = if Fearzone_Con then  source - tr else na;
def FearZoneClose = if Fearzone_Con then source - 2 * tr else na;
#// GreedZone
def Greedzone_Con = GZ1 < GZ1Limit and GZ2 > GZ2Limit;
def GreedZoneOpen = if Greedzone_Con then source + tr else na;
def GreedZoneClose = if Greedzone_Con then source + 2 * tr else na;
#/ Alerts
def FearAler =  AlertCircle and Fearzone_Con and !Fearzone_Con[1];#? #FC6C85 : na
def GreedAlert =  AlertCircle and Greedzone_Con and !Greedzone_Con[1];#? #FC6C85 : na

#-- Plots
plot FearZone = if FearAler then low - tr/3 else na;    # "Alert Circles"
FearZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_UP);
FearZone.SetDefaultColor(Color.RED);#GlobalColor("dn"));
FearZone.SetLineWeight(2);

plot GreedZone = if GreedAlert then high + tr/3 else na;    # "Alert Circles"
GreedZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_DOWN);
GreedZone.SetDefaultColor(Color.GREEN);#GlobalColor("dn"));
GreedZone.SetLineWeight(2);

plot FearWedges = if Wedges and Fearzone_Con then low else na;    # "Alert Circles"
FearWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
FearWedges.SetDefaultColor(GlobalColor("dn"));#GlobalColor("dn"));
FearWedges.SetLineWeight(2);

plot GreedWedges = if Wedges and Greedzone_Con then high else na;    # "Alert Circles"
GreedWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
GreedWedges.SetDefaultColor(GlobalColor("up"));#GlobalColor("dn"));
GreedWedges.SetLineWeight(2);

#-- Candle Sticks
AddChart(high = if Candlesticks then FearZoneOpen else na,
         low  = FearZoneClose, open = FearZoneOpen, close = FearZoneClose,
         type = ChartType.CANDLE, growcolor =  GlobalColor("dn"));

AddChart(high = if Candlesticks then GreedZoneOpen else na ,
         low = GreedZoneClose , open = GreedZoneClose,  close = GreedZoneOpen,
         type = ChartType.CANDLE, growcolor =  GlobalColor("up"));


#---- END of CODE
 
check the below.

CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © Zeiierman
#//Copyright by Zeiierman.
#//The information contained in my scripts/indicators/ideas does not constitute financial advice or a solicitation to buy or sell any securities of any type.
#//I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from use of or reliance on such information.
#//All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, or individual’s trading does not guarantee future results or returns.
#//Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
#//My scripts/indicators/ideas are only for educational purposes!
#study("Fearzone (Expo) - Contrarian Indicator", overlay=true, shorttitle="FearZone (Expo)")
#study("GreedZone indicator ", overlay=true, shorttitle="GreedZone (Expo)")
# Converted and mod by Sam4Cok@Samer800     - 06/2023

input ShowZonezStyle   = {Default "Candle Sticks", "Wedges", "Don't Show"};
input ZonesStartAlert = {Default Dots, Arrows, "Don't Show"};
input source = ohlc4;            # "Source"
input FearzoneMovAvgType  = AverageType.SIMPLE;
input FearzonePeriod = 30;         # "Fearzone Period"
input FearzoneStdevPeriod = 50;    # "Stdev Period Fearzone"
input GreedZoneMovAvgType  = AverageType.SIMPLE;
input GreedZonePeriod = 30;        # "GreedZone Period"
input GreedZoneStdevPeriod = 50;   # "Stdev Period GreedZone"

def na = Double.NaN;
def tr = TrueRange(high, close, low);
def Candlesticks = ShowZonezStyle==ShowZonezStyle."Candle Sticks";
def Wedges = ShowZonezStyle==ShowZonezStyle."Wedges";
def dots = ZonesStartAlert==ZonesStartAlert.Dots;
def AlertCircle = ZonesStartAlert!=ZonesStartAlert."Don't Show";

DefineGlobalColor("up", CreateColor(38,166,154));
DefineGlobalColor("dn", CreateColor(239,83,80));

#// Condition One - Fear
def HZone = Highest(source, FearzonePeriod);
def FZ1 = (HZone - source) / HZone;
def FAVG1 = MovingAverage(FearzoneMovAvgType, FZ1, FearzoneStdevperiod);
def FSTDEV1 = StDev(FZ1, FearzoneStdevperiod);
def FZ1Limit = FAVG1 + FSTDEV1;
#// Condition One - Greed
def LZone = lowest(source, GreedZonePeriod);
def GZ1 = (LZone - source)/ LZone;
def GAVG1 = MovingAverage(GreedZoneMovAvgType, GZ1, GreedZoneStdevperiod);
def GSTDEV1 = StDev(GZ1, GreedZoneStdevperiod);
def GZ1Limit = GAVG1 - GSTDEV1;
#// Condition Two - Fear
def FZ2 = MovingAverage(FearzoneMovAvgType, source, FearzonePeriod);
def FAVG2 = MovingAverage(FearzoneMovAvgType, FZ2, FearzoneStdevperiod);
def FSTDEV2 = StDev(FZ2, FearzoneStdevperiod);
def FZ2Limit = FAVG2 - FSTDEV2;
#// Condition Two - Greed
def GZ2 = MovingAverage(GreedZoneMovAvgType, source, GreedZonePeriod);
def GAVG2 = MovingAverage(GreedZoneMovAvgType, GZ2, GreedZoneStdevperiod);
def GSTDEV2 = StDev(GZ2, GreedZoneStdevperiod);
def GZ2Limit = GAVG2 + GSTDEV2;
#// FearZone
def Fearzone_Con = FZ1 > FZ1Limit and FZ2 < FZ2Limit;
def FearZoneOpen = if Fearzone_Con then  source - tr else na;
def FearZoneClose = if Fearzone_Con then source - 2 * tr else na;
#// GreedZone
def Greedzone_Con = GZ1 < GZ1Limit and GZ2 > GZ2Limit;
def GreedZoneOpen = if Greedzone_Con then source + tr else na;
def GreedZoneClose = if Greedzone_Con then source + 2 * tr else na;
#/ Alerts
def FearAler =  AlertCircle and Fearzone_Con and !Fearzone_Con[1];#? #FC6C85 : na
def GreedAlert =  AlertCircle and Greedzone_Con and !Greedzone_Con[1];#? #FC6C85 : na

#-- Plots
plot FearZone = if FearAler then low - tr/3 else na;    # "Alert Circles"
FearZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_UP);
FearZone.SetDefaultColor(Color.RED);#GlobalColor("dn"));
FearZone.SetLineWeight(2);

plot GreedZone = if GreedAlert then high + tr/3 else na;    # "Alert Circles"
GreedZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_DOWN);
GreedZone.SetDefaultColor(Color.GREEN);#GlobalColor("dn"));
GreedZone.SetLineWeight(2);

plot FearWedges = if Wedges and Fearzone_Con then low else na;    # "Alert Circles"
FearWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
FearWedges.SetDefaultColor(GlobalColor("dn"));#GlobalColor("dn"));
FearWedges.SetLineWeight(2);

plot GreedWedges = if Wedges and Greedzone_Con then high else na;    # "Alert Circles"
GreedWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
GreedWedges.SetDefaultColor(GlobalColor("up"));#GlobalColor("dn"));
GreedWedges.SetLineWeight(2);

#-- Candle Sticks
AddChart(high = if Candlesticks then FearZoneOpen else na,
         low  = FearZoneClose, open = FearZoneOpen, close = FearZoneClose,
         type = ChartType.CANDLE, growcolor =  GlobalColor("dn"));

AddChart(high = if Candlesticks then GreedZoneOpen else na ,
         low = GreedZoneClose , open = GreedZoneClose,  close = GreedZoneOpen,
         type = ChartType.CANDLE, growcolor =  GlobalColor("up"));


#---- END of CODE
thank you so much..wedges does not plot ..but candlesstick does. thats enough for mr ..thanks alot for your help
 
check the below.

CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © Zeiierman
#//Copyright by Zeiierman.
#//The information contained in my scripts/indicators/ideas does not constitute financial advice or a solicitation to buy or sell any securities of any type.
#//I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from use of or reliance on such information.
#//All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, or individual’s trading does not guarantee future results or returns.
#//Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
#//My scripts/indicators/ideas are only for educational purposes!
#study("Fearzone (Expo) - Contrarian Indicator", overlay=true, shorttitle="FearZone (Expo)")
#study("GreedZone indicator ", overlay=true, shorttitle="GreedZone (Expo)")
# Converted and mod by Sam4Cok@Samer800     - 06/2023

input ShowZonezStyle   = {Default "Candle Sticks", "Wedges", "Don't Show"};
input ZonesStartAlert = {Default Dots, Arrows, "Don't Show"};
input source = ohlc4;            # "Source"
input FearzoneMovAvgType  = AverageType.SIMPLE;
input FearzonePeriod = 30;         # "Fearzone Period"
input FearzoneStdevPeriod = 50;    # "Stdev Period Fearzone"
input GreedZoneMovAvgType  = AverageType.SIMPLE;
input GreedZonePeriod = 30;        # "GreedZone Period"
input GreedZoneStdevPeriod = 50;   # "Stdev Period GreedZone"

def na = Double.NaN;
def tr = TrueRange(high, close, low);
def Candlesticks = ShowZonezStyle==ShowZonezStyle."Candle Sticks";
def Wedges = ShowZonezStyle==ShowZonezStyle."Wedges";
def dots = ZonesStartAlert==ZonesStartAlert.Dots;
def AlertCircle = ZonesStartAlert!=ZonesStartAlert."Don't Show";

DefineGlobalColor("up", CreateColor(38,166,154));
DefineGlobalColor("dn", CreateColor(239,83,80));

#// Condition One - Fear
def HZone = Highest(source, FearzonePeriod);
def FZ1 = (HZone - source) / HZone;
def FAVG1 = MovingAverage(FearzoneMovAvgType, FZ1, FearzoneStdevperiod);
def FSTDEV1 = StDev(FZ1, FearzoneStdevperiod);
def FZ1Limit = FAVG1 + FSTDEV1;
#// Condition One - Greed
def LZone = lowest(source, GreedZonePeriod);
def GZ1 = (LZone - source)/ LZone;
def GAVG1 = MovingAverage(GreedZoneMovAvgType, GZ1, GreedZoneStdevperiod);
def GSTDEV1 = StDev(GZ1, GreedZoneStdevperiod);
def GZ1Limit = GAVG1 - GSTDEV1;
#// Condition Two - Fear
def FZ2 = MovingAverage(FearzoneMovAvgType, source, FearzonePeriod);
def FAVG2 = MovingAverage(FearzoneMovAvgType, FZ2, FearzoneStdevperiod);
def FSTDEV2 = StDev(FZ2, FearzoneStdevperiod);
def FZ2Limit = FAVG2 - FSTDEV2;
#// Condition Two - Greed
def GZ2 = MovingAverage(GreedZoneMovAvgType, source, GreedZonePeriod);
def GAVG2 = MovingAverage(GreedZoneMovAvgType, GZ2, GreedZoneStdevperiod);
def GSTDEV2 = StDev(GZ2, GreedZoneStdevperiod);
def GZ2Limit = GAVG2 + GSTDEV2;
#// FearZone
def Fearzone_Con = FZ1 > FZ1Limit and FZ2 < FZ2Limit;
def FearZoneOpen = if Fearzone_Con then  source - tr else na;
def FearZoneClose = if Fearzone_Con then source - 2 * tr else na;
#// GreedZone
def Greedzone_Con = GZ1 < GZ1Limit and GZ2 > GZ2Limit;
def GreedZoneOpen = if Greedzone_Con then source + tr else na;
def GreedZoneClose = if Greedzone_Con then source + 2 * tr else na;
#/ Alerts
def FearAler =  AlertCircle and Fearzone_Con and !Fearzone_Con[1];#? #FC6C85 : na
def GreedAlert =  AlertCircle and Greedzone_Con and !Greedzone_Con[1];#? #FC6C85 : na

#-- Plots
plot FearZone = if FearAler then low - tr/3 else na;    # "Alert Circles"
FearZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_UP);
FearZone.SetDefaultColor(Color.RED);#GlobalColor("dn"));
FearZone.SetLineWeight(2);

plot GreedZone = if GreedAlert then high + tr/3 else na;    # "Alert Circles"
GreedZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_DOWN);
GreedZone.SetDefaultColor(Color.GREEN);#GlobalColor("dn"));
GreedZone.SetLineWeight(2);

plot FearWedges = if Wedges and Fearzone_Con then low else na;    # "Alert Circles"
FearWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
FearWedges.SetDefaultColor(GlobalColor("dn"));#GlobalColor("dn"));
FearWedges.SetLineWeight(2);

plot GreedWedges = if Wedges and Greedzone_Con then high else na;    # "Alert Circles"
GreedWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
GreedWedges.SetDefaultColor(GlobalColor("up"));#GlobalColor("dn"));
GreedWedges.SetLineWeight(2);

#-- Candle Sticks
AddChart(high = if Candlesticks then FearZoneOpen else na,
         low  = FearZoneClose, open = FearZoneOpen, close = FearZoneClose,
         type = ChartType.CANDLE, growcolor =  GlobalColor("dn"));

AddChart(high = if Candlesticks then GreedZoneOpen else na ,
         low = GreedZoneClose , open = GreedZoneClose,  close = GreedZoneOpen,
         type = ChartType.CANDLE, growcolor =  GlobalColor("up"));


#---- END of CODE
hello @samer800 do you think it is possible to create a multi time frame labels for this indicator? that will be very powerful. thank you in advance
 
check the below.

CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © Zeiierman
#//Copyright by Zeiierman.
#//The information contained in my scripts/indicators/ideas does not constitute financial advice or a solicitation to buy or sell any securities of any type.
#//I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from use of or reliance on such information.
#//All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, or individual’s trading does not guarantee future results or returns.
#//Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
#//My scripts/indicators/ideas are only for educational purposes!
#study("Fearzone (Expo) - Contrarian Indicator", overlay=true, shorttitle="FearZone (Expo)")
#study("GreedZone indicator ", overlay=true, shorttitle="GreedZone (Expo)")
# Converted and mod by Sam4Cok@Samer800     - 06/2023

input ShowZonezStyle   = {Default "Candle Sticks", "Wedges", "Don't Show"};
input ZonesStartAlert = {Default Dots, Arrows, "Don't Show"};
input source = ohlc4;            # "Source"
input FearzoneMovAvgType  = AverageType.SIMPLE;
input FearzonePeriod = 30;         # "Fearzone Period"
input FearzoneStdevPeriod = 50;    # "Stdev Period Fearzone"
input GreedZoneMovAvgType  = AverageType.SIMPLE;
input GreedZonePeriod = 30;        # "GreedZone Period"
input GreedZoneStdevPeriod = 50;   # "Stdev Period GreedZone"

def na = Double.NaN;
def tr = TrueRange(high, close, low);
def Candlesticks = ShowZonezStyle==ShowZonezStyle."Candle Sticks";
def Wedges = ShowZonezStyle==ShowZonezStyle."Wedges";
def dots = ZonesStartAlert==ZonesStartAlert.Dots;
def AlertCircle = ZonesStartAlert!=ZonesStartAlert."Don't Show";

DefineGlobalColor("up", CreateColor(38,166,154));
DefineGlobalColor("dn", CreateColor(239,83,80));

#// Condition One - Fear
def HZone = Highest(source, FearzonePeriod);
def FZ1 = (HZone - source) / HZone;
def FAVG1 = MovingAverage(FearzoneMovAvgType, FZ1, FearzoneStdevperiod);
def FSTDEV1 = StDev(FZ1, FearzoneStdevperiod);
def FZ1Limit = FAVG1 + FSTDEV1;
#// Condition One - Greed
def LZone = lowest(source, GreedZonePeriod);
def GZ1 = (LZone - source)/ LZone;
def GAVG1 = MovingAverage(GreedZoneMovAvgType, GZ1, GreedZoneStdevperiod);
def GSTDEV1 = StDev(GZ1, GreedZoneStdevperiod);
def GZ1Limit = GAVG1 - GSTDEV1;
#// Condition Two - Fear
def FZ2 = MovingAverage(FearzoneMovAvgType, source, FearzonePeriod);
def FAVG2 = MovingAverage(FearzoneMovAvgType, FZ2, FearzoneStdevperiod);
def FSTDEV2 = StDev(FZ2, FearzoneStdevperiod);
def FZ2Limit = FAVG2 - FSTDEV2;
#// Condition Two - Greed
def GZ2 = MovingAverage(GreedZoneMovAvgType, source, GreedZonePeriod);
def GAVG2 = MovingAverage(GreedZoneMovAvgType, GZ2, GreedZoneStdevperiod);
def GSTDEV2 = StDev(GZ2, GreedZoneStdevperiod);
def GZ2Limit = GAVG2 + GSTDEV2;
#// FearZone
def Fearzone_Con = FZ1 > FZ1Limit and FZ2 < FZ2Limit;
def FearZoneOpen = if Fearzone_Con then  source - tr else na;
def FearZoneClose = if Fearzone_Con then source - 2 * tr else na;
#// GreedZone
def Greedzone_Con = GZ1 < GZ1Limit and GZ2 > GZ2Limit;
def GreedZoneOpen = if Greedzone_Con then source + tr else na;
def GreedZoneClose = if Greedzone_Con then source + 2 * tr else na;
#/ Alerts
def FearAler =  AlertCircle and Fearzone_Con and !Fearzone_Con[1];#? #FC6C85 : na
def GreedAlert =  AlertCircle and Greedzone_Con and !Greedzone_Con[1];#? #FC6C85 : na

#-- Plots
plot FearZone = if FearAler then low - tr/3 else na;    # "Alert Circles"
FearZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_UP);
FearZone.SetDefaultColor(Color.RED);#GlobalColor("dn"));
FearZone.SetLineWeight(2);

plot GreedZone = if GreedAlert then high + tr/3 else na;    # "Alert Circles"
GreedZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_DOWN);
GreedZone.SetDefaultColor(Color.GREEN);#GlobalColor("dn"));
GreedZone.SetLineWeight(2);

plot FearWedges = if Wedges and Fearzone_Con then low else na;    # "Alert Circles"
FearWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
FearWedges.SetDefaultColor(GlobalColor("dn"));#GlobalColor("dn"));
FearWedges.SetLineWeight(2);

plot GreedWedges = if Wedges and Greedzone_Con then high else na;    # "Alert Circles"
GreedWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
GreedWedges.SetDefaultColor(GlobalColor("up"));#GlobalColor("dn"));
GreedWedges.SetLineWeight(2);

#-- Candle Sticks
AddChart(high = if Candlesticks then FearZoneOpen else na,
         low  = FearZoneClose, open = FearZoneOpen, close = FearZoneClose,
         type = ChartType.CANDLE, growcolor =  GlobalColor("dn"));

AddChart(high = if Candlesticks then GreedZoneOpen else na ,
         low = GreedZoneClose , open = GreedZoneClose,  close = GreedZoneOpen,
         type = ChartType.CANDLE, growcolor =  GlobalColor("up"));


#---- END of CODE
check the below.

CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © Zeiierman
#//Copyright by Zeiierman.
#//The information contained in my scripts/indicators/ideas does not constitute financial advice or a solicitation to buy or sell any securities of any type.
#//I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from use of or reliance on such information.
#//All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, or individual’s trading does not guarantee future results or returns.
#//Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
#//My scripts/indicators/ideas are only for educational purposes!
#study("Fearzone (Expo) - Contrarian Indicator", overlay=true, shorttitle="FearZone (Expo)")
#study("GreedZone indicator ", overlay=true, shorttitle="GreedZone (Expo)")
# Converted and mod by Sam4Cok@Samer800     - 06/2023

input ShowZonezStyle   = {Default "Candle Sticks", "Wedges", "Don't Show"};
input ZonesStartAlert = {Default Dots, Arrows, "Don't Show"};
input source = ohlc4;            # "Source"
input FearzoneMovAvgType  = AverageType.SIMPLE;
input FearzonePeriod = 30;         # "Fearzone Period"
input FearzoneStdevPeriod = 50;    # "Stdev Period Fearzone"
input GreedZoneMovAvgType  = AverageType.SIMPLE;
input GreedZonePeriod = 30;        # "GreedZone Period"
input GreedZoneStdevPeriod = 50;   # "Stdev Period GreedZone"

def na = Double.NaN;
def tr = TrueRange(high, close, low);
def Candlesticks = ShowZonezStyle==ShowZonezStyle."Candle Sticks";
def Wedges = ShowZonezStyle==ShowZonezStyle."Wedges";
def dots = ZonesStartAlert==ZonesStartAlert.Dots;
def AlertCircle = ZonesStartAlert!=ZonesStartAlert."Don't Show";

DefineGlobalColor("up", CreateColor(38,166,154));
DefineGlobalColor("dn", CreateColor(239,83,80));

#// Condition One - Fear
def HZone = Highest(source, FearzonePeriod);
def FZ1 = (HZone - source) / HZone;
def FAVG1 = MovingAverage(FearzoneMovAvgType, FZ1, FearzoneStdevperiod);
def FSTDEV1 = StDev(FZ1, FearzoneStdevperiod);
def FZ1Limit = FAVG1 + FSTDEV1;
#// Condition One - Greed
def LZone = lowest(source, GreedZonePeriod);
def GZ1 = (LZone - source)/ LZone;
def GAVG1 = MovingAverage(GreedZoneMovAvgType, GZ1, GreedZoneStdevperiod);
def GSTDEV1 = StDev(GZ1, GreedZoneStdevperiod);
def GZ1Limit = GAVG1 - GSTDEV1;
#// Condition Two - Fear
def FZ2 = MovingAverage(FearzoneMovAvgType, source, FearzonePeriod);
def FAVG2 = MovingAverage(FearzoneMovAvgType, FZ2, FearzoneStdevperiod);
def FSTDEV2 = StDev(FZ2, FearzoneStdevperiod);
def FZ2Limit = FAVG2 - FSTDEV2;
#// Condition Two - Greed
def GZ2 = MovingAverage(GreedZoneMovAvgType, source, GreedZonePeriod);
def GAVG2 = MovingAverage(GreedZoneMovAvgType, GZ2, GreedZoneStdevperiod);
def GSTDEV2 = StDev(GZ2, GreedZoneStdevperiod);
def GZ2Limit = GAVG2 + GSTDEV2;
#// FearZone
def Fearzone_Con = FZ1 > FZ1Limit and FZ2 < FZ2Limit;
def FearZoneOpen = if Fearzone_Con then  source - tr else na;
def FearZoneClose = if Fearzone_Con then source - 2 * tr else na;
#// GreedZone
def Greedzone_Con = GZ1 < GZ1Limit and GZ2 > GZ2Limit;
def GreedZoneOpen = if Greedzone_Con then source + tr else na;
def GreedZoneClose = if Greedzone_Con then source + 2 * tr else na;
#/ Alerts
def FearAler =  AlertCircle and Fearzone_Con and !Fearzone_Con[1];#? #FC6C85 : na
def GreedAlert =  AlertCircle and Greedzone_Con and !Greedzone_Con[1];#? #FC6C85 : na

#-- Plots
plot FearZone = if FearAler then low - tr/3 else na;    # "Alert Circles"
FearZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_UP);
FearZone.SetDefaultColor(Color.RED);#GlobalColor("dn"));
FearZone.SetLineWeight(2);

plot GreedZone = if GreedAlert then high + tr/3 else na;    # "Alert Circles"
GreedZone.SetPaintingStrategy(if dots then PaintingStrategy.POINTS else PaintingStrategy.ARROW_DOWN);
GreedZone.SetDefaultColor(Color.GREEN);#GlobalColor("dn"));
GreedZone.SetLineWeight(2);

plot FearWedges = if Wedges and Fearzone_Con then low else na;    # "Alert Circles"
FearWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
FearWedges.SetDefaultColor(GlobalColor("dn"));#GlobalColor("dn"));
FearWedges.SetLineWeight(2);

plot GreedWedges = if Wedges and Greedzone_Con then high else na;    # "Alert Circles"
GreedWedges.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
GreedWedges.SetDefaultColor(GlobalColor("up"));#GlobalColor("dn"));
GreedWedges.SetLineWeight(2);

#-- Candle Sticks
AddChart(high = if Candlesticks then FearZoneOpen else na,
         low  = FearZoneClose, open = FearZoneOpen, close = FearZoneClose,
         type = ChartType.CANDLE, growcolor =  GlobalColor("dn"));

AddChart(high = if Candlesticks then GreedZoneOpen else na ,
         low = GreedZoneClose , open = GreedZoneClose,  close = GreedZoneOpen,
         type = ChartType.CANDLE, growcolor =  GlobalColor("up"));


#---- END of CODE
Hello Sameer, why it is different in TV ,and TOS ..today for SPY 5min it plotted fearzone candles ..but in TOS i do not see those ..Can you please check..its really helping this indicator ..i want to avoid using TV
 
Hello Sameer, why it is different in TV ,and TOS ..today for SPY 5min it plotted fearzone candles ..but in TOS i do not see those ..Can you please check..its really helping this indicator ..i want to avoid using TV
Extended hours in TV differs from TOS. To compare any indicator in TV and TOS, you have to turn of the extended hours in both platforms
 
Hi, I´m new to all this stuff and I really dont understand that much of script and coding, could someone explain the logic behind this indicator? Looks great but I want to understand it! Thanks!
 
Hi, I´m new to all this stuff and I really dont understand that much of script and coding, could someone explain the logic behind this indicator? Looks great but I want to understand it! Thanks!
This calculates when moving averages rise above / below standard deviation bands to determine when a stock is in fear / greed zones
 
Last edited:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
358 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