Help With Price Action Study

METAL

Well-known member
Plus
I am trying to create an indicator that colors the buy/sell candles if these conditions are met.
I have been testing this on a 15m TF and it is extremely accurate.
Condition is as follows:
#Buy Signal-
1) Must have a red candle.
2) next (Green) candle must open lower than high of RED candle, It must also move lower than RED candle Low, It Must close Higher than the close of Red Candle, It must Close Lower than the open of the RED candle.
3) 8EMA - Green Candle Must Close Above the 8EMA
4) Color Candle White.

#Sell Signal-
1) Must have a Green candle.
2) next (RED) candle must open Higher than Low of Green candle, It must also move Higher than Green candle high, It Must close Lower than the close of Green Candle, It must Close Higher than the open of the Green candle.
3) 8EMA - Green Candle Must Close Below the 8EMA
4) Color Candle Yellow.

This is what I have done so far. Can someone add the EMA condition
Also, Any input appreciated.

Code:
# Define conditions for the red candle
def isRedCandle = close < open;
def isRedCandleWithinGreen = high > high[1] and close < close[1] and close > open[1] and open > low[1] and low > low[1];

# Define conditions for the green candle
def isGreenCandle = close > open;
def isGreenCandleWithinRed = low < low[1] and close > close[1] and close < open[1] and open < high[1] and high < high[1];

#EMA Condition
#def ema =
# Assign colors to candles based on conditions
#Sell Signal
AssignPriceColor(if isGreenCandle then color.current else if isRedCandleWithinGreen then color.yellow else color.current);

#Buy Signal
AssignPriceColor(if isRedCandle then color.current else if isGreenCandleWithinRed then color.white else color.current);
.
I would like it to be optional if possible. I would like to have a "Use EMA" Yes/No.
 
Solution
I am trying to create an indicator that colors the buy/sell candles if these conditions are met.
I have been testing this on a 15m TF and it is extremely accurate.
Condition is as follows:
#Buy Signal-
1) Must have a red candle.
2) next (Green) candle must open lower than high of RED candle, It must also move lower than RED candle Low, It Must close Higher than the close of Red Candle, It must Close Lower than the open of the RED candle.
3) 8EMA - Green Candle Must Close Above the 8EMA
4) Color Candle White.

#Sell Signal-
1) Must have a Green candle.
2) next (RED) candle must open Higher than Low of Green candle, It must also move Higher than Green candle high, It Must close Lower than the close of Green Candle, It must Close...
I am trying to create an indicator that colors the buy/sell candles if these conditions are met.
I have been testing this on a 15m TF and it is extremely accurate.
Condition is as follows:
#Buy Signal-
1) Must have a red candle.
2) next (Green) candle must open lower than high of RED candle, It must also move lower than RED candle Low, It Must close Higher than the close of Red Candle, It must Close Lower than the open of the RED candle.
3) 8EMA - Green Candle Must Close Above the 8EMA
4) Color Candle White.

#Sell Signal-
1) Must have a Green candle.
2) next (RED) candle must open Higher than Low of Green candle, It must also move Higher than Green candle high, It Must close Lower than the close of Green Candle, It must Close Higher than the open of the Green candle.
3) 8EMA - Green Candle Must Close Below the 8EMA
4) Color Candle Yellow.

This is what I have done so far. Can someone add the EMA condition
Also, Any input appreciated.

Code:
# Define conditions for the red candle
def isRedCandle = close < open;
def isRedCandleWithinGreen = high > high[1] and close < close[1] and close > open[1] and open > low[1] and low > low[1];

# Define conditions for the green candle
def isGreenCandle = close > open;
def isGreenCandleWithinRed = low < low[1] and close > close[1] and close < open[1] and open < high[1] and high < high[1];

#EMA Condition
#def ema =
# Assign colors to candles based on conditions
#Sell Signal
AssignPriceColor(if isGreenCandle then color.current else if isRedCandleWithinGreen then color.yellow else color.current);

#Buy Signal
AssignPriceColor(if isRedCandle then color.current else if isGreenCandleWithinRed then color.white else color.current);
.
I would like it to be optional if possible. I would like to have a "Use EMA" Yes/No.

see if this is correct...
i basically started over. copy each rule then make a formula for it.
i think the sell ema was wrong, so i changed it

can choose yes/no to use the EMA comparison

Code:
#price_action_add_ema

#https://usethinkscript.com/threads/help-with-price-action-study.17318/
#Help With Price Action Study
#METAL  Nov 30, 2023

#I am trying to create an indicator that colors the buy/sell candles if these conditions are met.
#I have been testing this on a 15m TF and it is extremely accurate.

#I would like it to be optional if possible. I would like to have a "Use EMA" Yes/No.

#Condition is as follows:
#Buy Signal-
#1) Must have a red candle.
#2) next (Green) candle must open lower than high of RED candle, It must also move lower than RED candle Low, It Must close Higher than the close of Red Candle, It must Close Lower than the open of the RED candle.
#3) 8EMA - Green Candle Must Close Above the 8EMA
#4) Color Candle White.


#Sell Signal-
#1) Must have a Green candle.
#2) next (RED) candle must open Higher than Low of Green candle, It must also move Higher than Green candle high, It Must close Lower than the close of Green Candle, It must Close Higher than the open of the Green candle.
#3) 8EMA - Green Candle Must Close Below the 8EMA
#4) Color Candle Yellow.

#This is what I have done so far. Can someone add the EMA condition


input Use_EMA = yes;

#----------------------------

def na = double.nan;
def bn = barnumber();

def data = close;
input avg1_type = AverageType.exponential;
input avg1_length = 8;
def avg1 = MovingAverage( avg1_type , data , avg1_length );

input show_average_line = yes;
plot zavg1 = if show_average_line then avg1 else na;



#------------------------------
# buy , red then green
# #1  conditions for the red candle
def isRed = close < open;

# 2) next candle is green and,
#   open lower than high of RED candle,
#   move lower than RED candle Low,
#   close Higher than the close of Red Candle,
#   Close Lower than the open of the RED candle.
def green_red = open < high[1] and low < low[1] and close > close[1] and close < open[1];

#3) 8EMA - Green Candle Must Close Below the 8EMA
def green_ema = close < avg1;

#4) Color Candle White.
def bar_white = (isred[1] and green_red and (if Use_EMA then green_ema else 1));

#------------------------------

# sell , green then red
#1) Must have a Green candle.
def isgreen = close > open;

# 2) next candle is red and,
#   open Higher than Low of Green candle,
#   move Higher than Green candle high,
#   close Lower than the close of Green Candle,
#   Close Higher than the open of the Green candle.
def red_green = open > low[1] and high > high[1] and close < close[1] and close > open[1];

#3) 8EMA - red Candle Must Close above the 8EMA
def red_ema = close > avg1;

#4) Color Candle Yellow.
 def bar_yellow = (isgreen[1] and red_green and (if Use_EMA then red_ema else 1));

#------------------------------

AssignPriceColor(if bar_white then color.white else if bar_yellow then color.yellow else color.current);
#
 
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
240 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