## ########################################################
#ToS OnBalanceVolumeModified
## ########################################################
input signalLength = 10;
input averageType = "exponential" ;
def obvm = OnBalanceVolumeModified().obVM;
def ema = OnBalanceVolumeModified("signal length" = signalLength, "average type" = averageType).Signal; ;
def crossUP = if obvm crosses above ema then ema else double.NaN ;
def crossDN = if obvm crosses below ema then obvm else double.NaN ;
## ########################################################
# Charting & Formatting
DefineGlobalColor("bull", Color.green) ;
DefineGlobalColor("bear", Color.red) ;
DefineGlobalColor("crossup", Color.cyan) ;
DefineGlobalColor("crossdn", Color.magenta) ;
AddLabel(yes,
if obvm crosses above ema then "obv cross up!" else
if obvm crosses below ema then "obv cross down!" else
if obvm > ema then "obv trending above" else " | obv trending below",
if obvm crosses above ema then GlobalColor("crossup") else
if obvm crosses below ema then GlobalColor("crossdn") else
if obvm > ema then GlobalColor("bull") else GlobalColor("bear"));
input paintCandles = yes ;
AssignPriceColor(
if !paintCandles then color.current else
if obvm crosses above ema then GlobalColor("crossup") else
if obvm crosses below ema then GlobalColor("crossdn") else
if obvm > ema then GlobalColor("bull") else GlobalColor("bear"));
## ########################################################
#ToS OnBalanceVolumeModified
## ########################################################
declare lower;
declare real_size;
DefineGlobalColor("bull", Color.green) ;
DefineGlobalColor("bear", Color.red) ;
DefineGlobalColor("crossup", Color.cyan) ;
DefineGlobalColor("crossdn", Color.magenta) ;
input signalLength = 10;
input averageType = "exponential" ;
plot obvm = OnBalanceVolumeModified().obVM;
plot ema = OnBalanceVolumeModified("signal length" = signalLength, "average type" = averageType).Signal; ;
addcloud(obvm, ema, GlobalColor("bull"), GlobalColor("bear"));
plot crossUP = if obvm crosses above ema then ema else double.NaN ;
crossUP.SetPaintingStrategy(PaintingStrategy.ARROW_up);
crossUP.SetDefaultColor(GlobalColor("crossup")) ;
crossUP.SetLineWeight(3);
plot crossDN = if obvm crosses below ema then obvm else double.NaN ;
crossDN.SetPaintingStrategy(PaintingStrategy.ARROW_down);
crossDN.SetDefaultColor(GlobalColor("crossdn")) ;
crossDN.SetLineWeight(3);
input showLabel = yes ;
AddLabel(showLabel,
if obvm crosses above ema then "obv cross up!" else
if obvm crosses below ema then "obv cross down!" else
if obvm > ema then "obv trending above" else " | obv trending below",
if obvm crosses above ema then GlobalColor("crossup") else
if obvm crosses below ema then GlobalColor("crossdn") else
if obvm > ema then GlobalColor("bull") else GlobalColor("bear"));
input paintCandles = yes ;
AssignPriceColor(
if !paintCandles then color.current else
if obvm crosses above ema then GlobalColor("crossup") else
if obvm crosses below ema then GlobalColor("crossdn") else
if obvm > ema then GlobalColor("bull") else GlobalColor("bear"));
I've reviewed the code (#3) above and have the following comments/questions:
1) I'd like to code an upper OBV chart label. How can I modify the code to identify the moving average type, the moving average length, and color the label dark_green if the OBV closes above the moving average else color the label dark_red if the OBV closes below the moving average. Thanks...
## ########################################################
# OnBalanceVolumeModified
# mike request
## ########################################################
input signalLength = 10;
input averageType = "exponential" ;
def obvm = OnBalanceVolumeModified().obVM;
def ema = OnBalanceVolumeModified("signal length" = signalLength, "average type" = averageType).Signal; ;
def crossUP = if obvm crosses above ema then ema else double.NaN ;
def crossDN = if obvm crosses below ema then obvm else double.NaN ;
## ########################################################
# Charting & Formatting
DefineGlobalColor("bull", Color.dark_green) ;
DefineGlobalColor("bear", Color.dark_red) ;
DefineGlobalColor("crossup", Color.cyan) ;
DefineGlobalColor("crossdn", Color.magenta) ;
AddLabel(yes,
"OBVm average used: " +averageType +" | average length: " +signalLength+
if obvm crosses above ema then " | obv cross up!" else
if obvm crosses below ema then " | obv cross down!" else
if obvm > ema then " | obv trending above" else " | obv trending below",
if obvm crosses above ema then GlobalColor("crossup") else
if obvm crosses below ema then GlobalColor("crossdn") else
if obvm > ema then GlobalColor("bull") else GlobalColor("bear"));
input paintCandles = no ;
AssignPriceColor(
if !paintCandles then color.current else
if obvm crosses above ema then GlobalColor("crossup") else
if obvm crosses below ema then GlobalColor("crossdn") else
if obvm > ema then GlobalColor("bull") else GlobalColor("bear"));
Hello All,
Would it be possible to add in a label to tell me how much of the numerical difference and percentage? Sometimes I like to see values changes to determine my exit.
obvm - ema = positive value or negative value
thanks,
jrj4774
def numerical Difference = put your definition here ;
def percentage = put your definition here ;
AddLabel(yes, "difference: " +numerical Difference +" | pct: " +percentage,
if percentage>0 then color.green else color.red);
You left off a semicolonI'm completely a newbie here, and I'm trying to find similar syntax in how the line/logic statement.
But I am getting an error message on the value differences. I tried both way I can think of.
and then the label, I'm completely lost.
Thanks,
jrj4774
todef numerical Difference = obvm - ema
Every thinkscript statement must end with a semicolon.def numerical Difference = obvm - ema ;
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.