God Candles For ThinkOrSwim

@samer800 please take a look to this very interesting indicator. Thank You in advance!
check below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// © Vanitati
#indicator('God Candles', overlay=true)
# converted by Sam4Cok@Samer800 - 09/2023
input lookbackPeriod = 30;#, title="Dilution"
input lineLength = 6;#, "Line Length",
input showDiamonds = yes;    # "Show Diamonds",
input useSessionFilter = no; # "Use Session Time Filter"
input sessionStartTime = 1000;
input sessionEndTime = 1500;


def na = Double.NaN;
def secondsPassed = SecondsFromTime(sessionStartTime) >= 0;
def secondsRemained = SecondsTillTime(sessionEndTime) >= 0;

def rth = secondsPassed and secondsRemained;
#// ----------- God Candle Conditions ------------

def bodyBarPrevious = AbsValue(close[1] - open[1]);
def bodyBarCurrent = AbsValue(close - open);
def bullishEngulfing = (low <= low[1]) and (close >= high[1]);
def bearishEngulfing = (high >= high[1]) and (close <= low[1]);

#//god candle volume calculations
def sumVolume = Sum(volume, 10);
def av = sumVolume / 10;
def valueVolume = volume * (high - low);
def hivalueVolume = Highest(valueVolume, 10);
def va = if volume >= av * 2 or valueVolume >= hivalueVolume then 1 else
        (if volume >= av * 1.5 then 2 else 0);
def isBull = close > open;

#//engulfing calculations
def lowestLow = Lowest(low[1], lookbackPeriod);
def highestHigh = Highest(high[1], lookbackPeriod);
def bullishEngulfingClimax = bullishEngulfing and
                            (va == 1) and isBull and (low < lowestLow);
def bearishEngulfingClimax = bearishEngulfing and
                            (va == 1) and !isBull and (high > highestHigh);
def bullishEngulfingDiamond = bullishEngulfing and bodyBarCurrent >= bodyBarPrevious * 2 and low[1] < open and low < open and low[1] < close and low < close;
def bearishEngulfingDiamond = bearishEngulfing and bodyBarCurrent >= bodyBarPrevious * 2 and high[1] > open and high > open and high[1] > close and high > close;
def isInSession = if useSessionFilter then RTH else yes;
def y1 = low + (open - low) / 2;
def y2 = high - (high - open) / 2;

def BullLine = if isInSession and bullishEngulfingClimax then y1 else BullLine[1];
def bearLine = if isInSession and bearishEngulfingClimax then y2 else bearLine[1];

def bullCnt =  if BullLine - BullLine[1] then 0 else bullCnt[1] + 1;
def bearCnt =  if bearLine - bearLine[1] then 0 else bearCnt[1] + 1;

plot GCup = if BullLine and bullCnt <= lineLength then BullLine else na;
plot GCdn = if bearLine and bearCnt <= lineLength then bearLine else na;

GCup.SetDefaultColor(Color.CYAN);
GCdn.SetDefaultColor(Color.MAGENTA);
#//Dots plotting
def bull = isInSession and bullishEngulfing and showDiamonds and
           bullishEngulfingDiamond and !bullishEngulfingClimax;
def bear = isInSession and bearishEngulfing and showDiamonds and
           bearishEngulfingDiamond and !bearishEngulfingClimax;
plot PressureUp = if bull then low else na;# title='Pressure up'
plot PressureDn = if bear then high else na;#='Pressure down'

PressureUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
PressureDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
PressureUp.SetDefaultColor(Color.CYAN);
PressureDn.SetDefaultColor(Color.MAGENTA);

#-- END of CODE
 
check below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// © Vanitati
#indicator('God Candles', overlay=true)
# converted by Sam4Cok@Samer800 - 09/2023
input lookbackPeriod = 30;#, title="Dilution"
input lineLength = 6;#, "Line Length",
input showDiamonds = yes;    # "Show Diamonds",
input useSessionFilter = no; # "Use Session Time Filter"
input sessionStartTime = 1000;
input sessionEndTime = 1500;


def na = Double.NaN;
def secondsPassed = SecondsFromTime(sessionStartTime) >= 0;
def secondsRemained = SecondsTillTime(sessionEndTime) >= 0;

def rth = secondsPassed and secondsRemained;
#// ----------- God Candle Conditions ------------

def bodyBarPrevious = AbsValue(close[1] - open[1]);
def bodyBarCurrent = AbsValue(close - open);
def bullishEngulfing = (low <= low[1]) and (close >= high[1]);
def bearishEngulfing = (high >= high[1]) and (close <= low[1]);

#//god candle volume calculations
def sumVolume = Sum(volume, 10);
def av = sumVolume / 10;
def valueVolume = volume * (high - low);
def hivalueVolume = Highest(valueVolume, 10);
def va = if volume >= av * 2 or valueVolume >= hivalueVolume then 1 else
        (if volume >= av * 1.5 then 2 else 0);
def isBull = close > open;

#//engulfing calculations
def lowestLow = Lowest(low[1], lookbackPeriod);
def highestHigh = Highest(high[1], lookbackPeriod);
def bullishEngulfingClimax = bullishEngulfing and
                            (va == 1) and isBull and (low < lowestLow);
def bearishEngulfingClimax = bearishEngulfing and
                            (va == 1) and !isBull and (high > highestHigh);
def bullishEngulfingDiamond = bullishEngulfing and bodyBarCurrent >= bodyBarPrevious * 2 and low[1] < open and low < open and low[1] < close and low < close;
def bearishEngulfingDiamond = bearishEngulfing and bodyBarCurrent >= bodyBarPrevious * 2 and high[1] > open and high > open and high[1] > close and high > close;
def isInSession = if useSessionFilter then RTH else yes;
def y1 = low + (open - low) / 2;
def y2 = high - (high - open) / 2;

def BullLine = if isInSession and bullishEngulfingClimax then y1 else BullLine[1];
def bearLine = if isInSession and bearishEngulfingClimax then y2 else bearLine[1];

def bullCnt =  if BullLine - BullLine[1] then 0 else bullCnt[1] + 1;
def bearCnt =  if bearLine - bearLine[1] then 0 else bearCnt[1] + 1;

plot GCup = if BullLine and bullCnt <= lineLength then BullLine else na;
plot GCdn = if bearLine and bearCnt <= lineLength then bearLine else na;

GCup.SetDefaultColor(Color.CYAN);
GCdn.SetDefaultColor(Color.MAGENTA);
#//Dots plotting
def bull = isInSession and bullishEngulfing and showDiamonds and
           bullishEngulfingDiamond and !bullishEngulfingClimax;
def bear = isInSession and bearishEngulfing and showDiamonds and
           bearishEngulfingDiamond and !bearishEngulfingClimax;
plot PressureUp = if bull then low else na;# title='Pressure up'
plot PressureDn = if bear then high else na;#='Pressure down'

PressureUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
PressureDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
PressureUp.SetDefaultColor(Color.CYAN);
PressureDn.SetDefaultColor(Color.MAGENTA);

#-- END of CODE
@samer800 thank you some much!
 

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