How To Paint Candles With Momentum

hockeycoachdoug

Active member
2019 Donor
VIP
Would someone be willing to help me/ show a tutorial of how to make a paintbar study from an indicator?
I have a cycle indicator that I want to convert to a paintbar study. All I want is for when the indicator value (CycleLineColor) increases on the next bar it paints the bar green and when the indicator value goes down the next bar it paints the bar red. Doesn't matter if the indicator value is above or below the zero line. Just looking for the bars to paint green or red when the indicator value goes up or down. There could be multiple bars in a row of the same color as long as the signal line keeps increasing/ decreasing. Here is the indicator-
Code:
declare lower;
#plot Data = close;
input   FastCycleLength = 5;
input   SlowCycleLength = 8;
#def   CycleLineColor=DefineGlobalColor(Color.RED);
#input   CycleHistColor=Color.BLUE;
#input   ZeroLineColor1 = GetColor(1);
DefineGlobalColor("CycleLineColor", Color.RED);
DefineGlobalColor("CyclehistColor", Color.BLUE);
DefineGlobalColor("ZeroLineColor", Color.YELLOW);
def H = high;
def L = low;
#def FastVar(0),SlowVar(0),DiffVar(0);

def FastVar = ExpAverage((H + L) / 2, FastCycleLength);
def SlowVar = Average((H + L) / 2, SlowCycleLength);
def DiffVar = FastVar - SlowVar;

plot pDiffVar = DiffVar;
pDiffVar.SetDefaultColor(GlobalColor("CycleLineColor"));
plot pDiffVar2 = DiffVar;
pDiffVar2.SetDefaultColor(GlobalColor("CycleHistColor"));
plot pZeroLine = 0;
pZeroLine.SetDefaultColor(GlobalColor("ZeroLineColor"));
#Plot1(DiffVar,"Cycle",CycleLineColor);
#Plot2(DiffVar,"CycleHist",CycleHistColor);
#Plot3(0    ,"Zero",ZeroLineColor);
 
Solution
Would someone be willing to help me/ show a tutorial of how to make a paintbar study from an indicator?
I have a cycle indicator that I want to convert to a paintbar study. All I want is for when the indicator value (CycleLineColor) increases on the next bar it paints the bar green and when the indicator value goes down the next bar it paints the bar red. Doesn't matter if the indicator value is above or below the zero line. Just looking for the bars to paint green or red when the indicator value goes up or down. There could be multiple bars in a row of the same color as long as the signal line keeps increasing/ decreasing. Here is the indicator-
Code:
declare lower;
#plot Data = close;
input   FastCycleLength = 5;
input...
Would someone be willing to help me/ show a tutorial of how to make a paintbar study from an indicator?
I have a cycle indicator that I want to convert to a paintbar study. All I want is for when the indicator value (CycleLineColor) increases on the next bar it paints the bar green and when the indicator value goes down the next bar it paints the bar red. Doesn't matter if the indicator value is above or below the zero line. Just looking for the bars to paint green or red when the indicator value goes up or down. There could be multiple bars in a row of the same color as long as the signal line keeps increasing/ decreasing. Here is the indicator-
Code:
declare lower;
#plot Data = close;
input   FastCycleLength = 5;
input   SlowCycleLength = 8;
#def   CycleLineColor=DefineGlobalColor(Color.RED);
#input   CycleHistColor=Color.BLUE;
#input   ZeroLineColor1 = GetColor(1);
DefineGlobalColor("CycleLineColor", Color.RED);
DefineGlobalColor("CyclehistColor", Color.BLUE);
DefineGlobalColor("ZeroLineColor", Color.YELLOW);
def H = high;
def L = low;
#def FastVar(0),SlowVar(0),DiffVar(0);

def FastVar = ExpAverage((H + L) / 2, FastCycleLength);
def SlowVar = Average((H + L) / 2, SlowCycleLength);
def DiffVar = FastVar - SlowVar;

plot pDiffVar = DiffVar;
pDiffVar.SetDefaultColor(GlobalColor("CycleLineColor"));
plot pDiffVar2 = DiffVar;
pDiffVar2.SetDefaultColor(GlobalColor("CycleHistColor"));
plot pZeroLine = 0;
pZeroLine.SetDefaultColor(GlobalColor("ZeroLineColor"));
#Plot1(DiffVar,"Cycle",CycleLineColor);
#Plot2(DiffVar,"CycleHist",CycleHistColor);
#Plot3(0    ,"Zero",ZeroLineColor);

1. Commented out 'declare lower' so that this study can be used in either the upper or lower panel as is.
2. Created input showplots to hide plots. It is not needed in this study with declare lower commented out. However, it is a useful when trying to move a lower indicator to the upper panel when leaving the declare lower in the sudy.
3. Added assignprice color with conditions with an offset choice. The offset is defaulted to zero, You can try changing it to 1 or -1, for example to have the price colors painted how you wanted.

Screenshot 2024-02-19 085855.png
Code:
#declare lower;
input showplots = yes;
input paintbar  = yes;
input offset    = 0;
input   FastCycleLength = 5;
input   SlowCycleLength = 8;
#def   CycleLineColor=DefineGlobalColor(Color.RED);
#input   CycleHistColor=Color.BLUE;
#input   ZeroLineColor1 = GetColor(1);
DefineGlobalColor("CycleLineColor", Color.RED);
DefineGlobalColor("CyclehistColor", Color.BLUE);
DefineGlobalColor("ZeroLineColor", Color.YELLOW);
def H = high;
def L = low;
#def FastVar(0),SlowVar(0),DiffVar(0);

def FastVar = ExpAverage((H + L) / 2, FastCycleLength);
def SlowVar = Average((H + L) / 2, SlowCycleLength);
def DiffVar = FastVar - SlowVar;

plot pDiffVar = DiffVar;
pDiffVar.SetDefaultColor(GlobalColor("CycleLineColor"));
pDiffVar.sethiding(!showplots);
plot pDiffVar2 = DiffVar;
pDiffVar2.SetDefaultColor(GlobalColor("CycleHistColor"));
pDiffVar2.sethiding(!showplots);
plot pZeroLine = 0;
pZeroLine.SetDefaultColor(GlobalColor("ZeroLineColor"));
pZeroLine.sethiding(!showplots);
#Plot1(DiffVar,"Cycle",CycleLineColor);
#Plot2(DiffVar,"CycleHist",CycleHistColor);
#Plot3(0    ,"Zero",ZeroLineColor);

AssignPriceColor(if pDiffVar[offset] > pDiffVar[offset + 1] then Color.GREEN else if pDiffVar[offset] < pDiffVar[offset + 1] then Color.RED else Color.WHITE);

#
 
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
303 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