STC plot with displacement

dsvitale

New member
VIP
I have tried and cannot figure out how to add a displacement to the STC plot below. Please help

Code:
# TOS Schaff Cycle
declare lower ;
input show_label = yes ;
input OB = 80 ;
input OS = 20 ;
# ########################################################
#Using GlobalColors makes the colors modifiable
DefineGlobalColor("maxxed", CreateColor(0, 70, 30)) ;
DefineGlobalColor("rising",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("bear",  CreateColor(225, 0, 0)) ;
DefineGlobalColor("begin", CreateColor(50, 200, 255)) ;
DefineGlobalColor("zero", CreateColor (200, 125, 255)) ;
# ########################################################
Plot Schaff  = SchaffTrendCycle()."STC" ;
# ########################################################
#Schaff> Schaff[1] this statement is saying if the current candle is greater than the previous candle
#that is what [1] denotes. Thus defining uptick. The same is then done for downticks.
Schaff.AssignValueColor(
if Schaff> OB then GlobalColor("maxxed") else
if Schaff< OS and Schaff< Schaff[1] then GlobalColor("zero") else
if Schaff< OS and Schaff> Schaff[1] then GlobalColor("begin") else
if Schaff> Schaff[1] then GlobalColor("rising")
     else GlobalColor("bear"));
Schaff.SetLineWeight(3);
# ########################################################

plot OverBought = OB;
plot OverSold = OS;
plot UpArrow = if Schaff crosses above OverSold then OverSold else Double.NaN;
plot DownArrow = if Schaff crosses below OverBought then OverBought else Double.NaN;

DefineGlobalColor("OBcolor", CreateColor(171, 171, 225)) ;
DefineGlobalColor("OScolor", CreateColor(220, 220, 128)) ;
OverBought.SetDefaultColor(GlobalColor("OBcolor"));
OverSold.SetDefaultColor(GlobalColor("OScolor"));
UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpArrow.SetDefaultColor(color.dark_green);
DownArrow.SetDefaultColor(color.dark_red);
# ########################################################
# The same logic that was used in coloring the plot can be used in labels
AddLabel(show_label,
         if Schaff> OB then "Schaff maxxed" else
         if Schaff< OS and Schaff< Schaff[1] then "Schaff bottomed" else
         if Schaff< OS and Schaff> Schaff[1] then "Schaff Trend BEGIN" else
         if Schaff> Schaff[1] then "Schaff rising " +round(Schaff,2)
              else "Schaff falling " +round(Schaff,2) ,
         if Schaff> OB then GlobalColor("maxxed") else
         if Schaff< OS and Schaff< Schaff[1] then GlobalColor("zero") else
         if Schaff< OS and Schaff> Schaff[1] then GlobalColor("begin") else
         if Schaff> Schaff[1] then GlobalColor("rising")
              else GlobalColor("bear"));
AddCloud(if Schaff >= OB then Schaff else Double.NaN, OB,
GlobalColor("maxxed"), GlobalColor("maxxed"));
AddCloud(if Schaff <= OS then OS else Double.NaN, Schaff,
GlobalColor("zero"), GlobalColor("zero"));
# ########################################################
 
Last edited by a moderator:
Solution
I have tried and cannot figure out how to add a displacement to the STC plot below. Please help

Code:
# TOS Schaff Cycle
declare lower ;
input show_label = yes ;
input OB = 80 ;
input OS = 20 ;
# ########################################################
#Using GlobalColors makes the colors modifiable
DefineGlobalColor("maxxed", CreateColor(0, 70, 30)) ;
DefineGlobalColor("rising",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("bear",  CreateColor(225, 0, 0)) ;
DefineGlobalColor("begin", CreateColor(50, 200, 255)) ;
DefineGlobalColor("zero", CreateColor (200, 125, 255)) ;
# ########################################################
Plot Schaff  = SchaffTrendCycle()."STC" ;
# ########################################################...
I have tried and cannot figure out how to add a displacement to the STC plot below. Please help

Code:
# TOS Schaff Cycle
declare lower ;
input show_label = yes ;
input OB = 80 ;
input OS = 20 ;
# ########################################################
#Using GlobalColors makes the colors modifiable
DefineGlobalColor("maxxed", CreateColor(0, 70, 30)) ;
DefineGlobalColor("rising",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("bear",  CreateColor(225, 0, 0)) ;
DefineGlobalColor("begin", CreateColor(50, 200, 255)) ;
DefineGlobalColor("zero", CreateColor (200, 125, 255)) ;
# ########################################################
Plot Schaff  = SchaffTrendCycle()."STC" ;
# ########################################################
#Schaff> Schaff[1] this statement is saying if the current candle is greater than the previous candle
#that is what [1] denotes. Thus defining uptick. The same is then done for downticks.
Schaff.AssignValueColor(
if Schaff> OB then GlobalColor("maxxed") else
if Schaff< OS and Schaff< Schaff[1] then GlobalColor("zero") else
if Schaff< OS and Schaff> Schaff[1] then GlobalColor("begin") else
if Schaff> Schaff[1] then GlobalColor("rising")
     else GlobalColor("bear"));
Schaff.SetLineWeight(3);
# ########################################################

plot OverBought = OB;
plot OverSold = OS;
plot UpArrow = if Schaff crosses above OverSold then OverSold else Double.NaN;
plot DownArrow = if Schaff crosses below OverBought then OverBought else Double.NaN;

DefineGlobalColor("OBcolor", CreateColor(171, 171, 225)) ;
DefineGlobalColor("OScolor", CreateColor(220, 220, 128)) ;
OverBought.SetDefaultColor(GlobalColor("OBcolor"));
OverSold.SetDefaultColor(GlobalColor("OScolor"));
UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpArrow.SetDefaultColor(color.dark_green);
DownArrow.SetDefaultColor(color.dark_red);
# ########################################################
# The same logic that was used in coloring the plot can be used in labels
AddLabel(show_label,
         if Schaff> OB then "Schaff maxxed" else
         if Schaff< OS and Schaff< Schaff[1] then "Schaff bottomed" else
         if Schaff< OS and Schaff> Schaff[1] then "Schaff Trend BEGIN" else
         if Schaff> Schaff[1] then "Schaff rising " +round(Schaff,2)
              else "Schaff falling " +round(Schaff,2) ,
         if Schaff> OB then GlobalColor("maxxed") else
         if Schaff< OS and Schaff< Schaff[1] then GlobalColor("zero") else
         if Schaff< OS and Schaff> Schaff[1] then GlobalColor("begin") else
         if Schaff> Schaff[1] then GlobalColor("rising")
              else GlobalColor("bear"));
AddCloud(if Schaff >= OB then Schaff else Double.NaN, OB,
GlobalColor("maxxed"), GlobalColor("maxxed"));
AddCloud(if Schaff <= OS then OS else Double.NaN, Schaff,
GlobalColor("zero"), GlobalColor("zero"));
# ########################################################

Try adding this input and change the plot as below. Change offset to your liking.

Input offset = 0;
Plot Schaff = SchaffTrendCycle()."STC" [offset];
 
Solution

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
367 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