0% found this document useful (0 votes)
146 views6 pages

FU Candle Trading Strategy Guide

This document contains a Pine Script code for a trading indicator named 'Casino' that identifies bullish and bearish follow-up (FU) candles based on various conditions, including the presence of Doji candles and the use of a Simple Moving Average (SMA). The script allows customization of inputs to filter and color specific candle types, and it includes functionality for identifying fair value gaps and imbalances. Alerts can be created when a FU is formed, enhancing trading decision-making.

Uploaded by

iislomnur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views6 pages

FU Candle Trading Strategy Guide

This document contains a Pine Script code for a trading indicator named 'Casino' that identifies bullish and bearish follow-up (FU) candles based on various conditions, including the presence of Doji candles and the use of a Simple Moving Average (SMA). The script allows customization of inputs to filter and color specific candle types, and it includes functionality for identifying fair value gaps and imbalances. Alerts can be created when a FU is formed, enhancing trading decision-making.

Uploaded by

iislomnur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
[Link]
// © sincereStork12718

//@version=5
indicator("Casino", overlay=true, max_boxes_count=500)
//---------------------------------------
//Define inputs
//---------------------------------------
useDojiFU = [Link](title="Print only FU where leading candle is a Doji",
defval=false, tooltip="Set the sensitivity by using the BodyRatio for Doji 0-1
below. This value will also affect FU to print (FU cannot be Doji!)")
useMA = [Link](title="Use SMA for confluence in finding FU's?", defval=false,
tooltip="Allow only bullish FU to print when above MA and vice versa. Not part of
Casino strategy)")
useInside = [Link](title="Colour Inside bars?", defval=false, tooltip="Not part
of Casino strategy")
useBearBull = [Link](title="Filter candles that by definition can be BOTH Bear
and Bull FU", defval=true, tooltip="By definition this can happen and will prevent
that by using the direction of the candle")

//---------------------------------------
// Variable declaration
//---------------------------------------
bool isFUBullv6 = false
bool isAttFUBullv6 = false

bool isFUBearv6 = false


bool isAttFUBearv6 = false

//---------------------------------------
//Calculate Smooth Moving Average
//---------------------------------------
length = [Link](9, minval=1, maxval=200, step=1, title="SMA length",
tooltip="Average price action of the 'x' number of candles")
out = [Link](close, length)
plot(out, color=[Link], title="SMA")

//---------------------------------------
//Identify doji candles
//---------------------------------------

//Top/bottom wick is almost equal (Body ratio >30%)


//BodyRatio is small <30%
//Body is offset, e.g. a hammer, dragonfly, spinning top, gravestone, hanging man
AND the BodyRatio <30%
//Is not FU or Att FU or Marubuzo
//Doji
//Doji star
//Dragonfly
//Gravestone
//Hanging man
//Hammer
//Inverted hammer
//Long lower shadow
//Long upper shadod
//Morning doji star
//Morning star
//Spinning top white
//Spinning top black
//Shooting star

BodyRatio = [Link](0.3, title="Doji's Max Body size (0-1)", minval=0,


maxval=1, step=0.01, tooltip="This value also affect the FU definition to be higher
than the ratio set")
isDoji=([Link](open - close) <= (high - low) * BodyRatio ? 1:0)

barcolor(isDoji ? [Link] : na, title="Doji bar color")


plotshape(isDoji, title="Doji bar text", style=[Link],
location=[Link], color=[Link], text="Doji", size=[Link],
display=[Link])
//bgcolor(isDoji ? [Link]([Link], 95) : na)

//---------------------------------------
//Bullish FU definition
//---------------------------------------
//Continuation FU
if close>open and low<low[1] and close>close[1] and high>high[1] and close>high[1]
isFUBullv6:=true
else if close>open and low<low[1] and close>close[1] and high>high[1] and
close<high[1]
isAttFUBullv6:=true
else if close>open and low<low[1] and close>close[1] and high>high[1] and
close<high[1]
isFUBullv6:=true
//Pull back FU
else if close<open and low<low[1] and close<close[1] and high<high[1] and
close>open[1] //No FU definition of value
isFUBullv6:=false
isAttFUBullv6:=false
else if close<open and low<low[1] and close<close[1] and high>high[1] and
close>open[1]
isAttFUBullv6:=true
else if close<open and low<low[1] and close<close[1] and high<high[1] and
close<open[1] //No FU definition of value
isFUBullv6:=false
isAttFUBullv6:=false
else if close<open and low<low[1] and close<close[1] and high>high[1] and
close<open[1] //Definition of Bearish FU
isFUBullv6:=false
isAttFUBullv6:=false
//Reversal FU
else if close>open and low<low[1] and close>close[1] and close<open[1] and
high<high[1]
isAttFUBullv6:=true
else if close>open and low<low[1] and close>close[1] and close<open[1] and
high<high[1]
isAttFUBullv6:=true
else if close>open and low<low[1] and close>close[1] and close>open[1] and
high>high[1]
isAttFUBullv6:=true
else if close>open and low<low[1] and close>close[1] and close>open[1] and
high>high[1]
isAttFUBullv6:=true
else if close>open and low<low[1] and close>close[1] and close>open[1] and
high>high[1] and close>high[1]
isFUBullv6:=true
//---------------------------------------
//Bearish FU definition
//---------------------------------------
//Continuation FU
if close<open and high>high[1] and close<close[1] and low<low[1] and close<low[1]
isFUBearv6:=true
else if close<open and high>high[1] and close<close[1] and low>low[1] and
close>low[1]
isAttFUBearv6:=true
else if close<open and high>high[1] and close<close[1] and low<low[1] and
close>low[1]
isFUBearv6:=true
//Pull back FU
else if close>open and high>high[1] and open<open[1] and low>low[1] and
close<open[1] //No FU definition of value
isFUBearv6:=false
isAttFUBearv6:=false
else if close>open and high>high[1] and open<open[1] and low<low[1] and
close<open[1]
isAttFUBearv6:=true
else if close>open and high>high[1] and open<open[1] and low>low[1] and
close>open[1] //No FU definition of value
isFUBearv6:=false
isAttFUBearv6:=false
else if close>open and high>high[1] and open<open[1] and low<low[1] and
close>open[1] //Definition of Bullish FU
isFUBearv6:=false
isAttFUBearv6:=true
//Reversal FU
else if close<open and high>high[1] and close<close[1] and close>open[1] and
low>low[1]
isAttFUBearv6:=true
else if close<open and high>high[1] and close<close[1] and close>open[1] and
low<low[1]
isAttFUBearv6:=true
else if close<open and high>high[1] and close<close[1] and close<open[1] and
low>low[1]
isAttFUBearv6:=true
else if close<open and high>high[1] and close<close[1] and close<open[1] and
low<low[1]
isAttFUBearv6:=true
else if close<open and high>high[1] and close<close[1] and close<open[1] and
low<low[1] and close<low[1]
isFUBearv6:=true

//---------------------------------------
//Option of MA, useMA
//---------------------------------------
//Only print Bullish FU, Attempted FU when above MA
if useMA==true and close<out and (isFUBullv6==true or isAttFUBullv6==true)
//Bullish FU should close above MA
isFUBullv6:=false
isAttFUBullv6:=false

//Only print Bearish FU, Attempted FU when below MA


if useMA==true and close>out and (isFUBearv6==true or isAttFUBearv6==true)
//Bearish FU should close below MA
isFUBearv6:=false
isAttFUBearv6:=false
//---------------------------------------
//Option of leading doji, isDoji[1]
//---------------------------------------
if useDojiFU==true and (isFUBullv6==true or isAttFUBullv6==true or isFUBearv6==true
or isAttFUBearv6==true) and isDoji[1]==false //Leading candle MUST be doji
isFUBullv6:=false
isAttFUBullv6:=false
isFUBearv6:=false
isAttFUBearv6:=false

//---------------------------------------
//Option of filter out Bear AND Bull attempted FU on the same candle
//---------------------------------------
if useBearBull==true and open<close and isAttFUBearv6==true //Candle is Bullish
cannot be bearish attempted FU
isAttFUBearv6:=false
else if useBearBull==true and open>close and isAttFUBullv6==true //Candle is
Bearish cannot be bullish attempted FU
isAttFUBullv6:=false

//---------------------------------------
//Option of combining two latest candles with the third to see if it forms an FU
//Experimental!!!!
//---------------------------------------
float o=0
float c=0

if open[1]<close[1] and open<close //Previous candle bullish and present bullish


o:=[Link](open[1], open)
c:=[Link](close[1], close)
else if open[1]<close[1] and open>close // Previous candle bullish and present
bearish
o:=[Link](open[1], close)
c:=[Link](close[1], open)
else if open[1]>close[1] and open<close //Previous candle bearish and present
bullish
o:=[Link](close[1], open)
c:=[Link](open[1], close)
else if open[1]>close[1] and open>close //Previous candle bearish and present
bearish
o:=[Link](open[1], open)
c:=[Link](close[1], close)
h=[Link](high[1], high)
l=[Link](low[1], low)

//plotcandle(o,h,l,c, color=[Link]([Link], 95), wickcolor=[Link],


bordercolor=[Link])

//---------------------------------------
// Check if current candle is a Doji => FU cannot be a Doji
//---------------------------------------
if (isFUBullv6==true or isFUBearv6==true) and isDoji==true
isFUBullv6:=false
isFUBearv6:=false

var lastBullFUType = ""


var lastBearFUType = ""
var lastBullFUIndex = 0
var lastBearFUIndex = 0
isBullHCS = ((isFUBullv6 and lastBullFUType == "Bull A") or (isAttFUBullv6 and
lastBullFUType == "Bull F")) and
low > low[bar_index-lastBullFUIndex] and low < high[bar_index-lastBullFUIndex]
isBearHCS = ((isFUBearv6 and lastBearFUType == "Bear A") or (isAttFUBearv6 and
lastBearFUType == "Bear F")) and
high < high[bar_index-lastBearFUIndex] and high > low[bar_index-lastBullFUIndex]

if isFUBullv6
lastBullFUType := "Bull F"
lastBullFUIndex := bar_index
if isAttFUBullv6
lastBullFUType := "Bull A"
lastBullFUIndex := bar_index
if isFUBearv6
lastBearFUType := "Bear F"
lastBearFUIndex := bar_index
if isAttFUBearv6
lastBearFUType := "Bear A"
lastBearFUIndex := bar_index

//---------------------------------------
// Bar plotting
//---------------------------------------
barcolor(isFUBullv6 ? [Link] : na, title="FU bull color")
plotshape(isFUBullv6 and not isBullHCS, title="New FU bull",
style=[Link], location=[Link], color=[Link], text="F",
size=[Link])

barcolor(isAttFUBullv6? [Link] : na, title="Attempted FU bear color")


plotshape(isAttFUBullv6 and not isBullHCS, title="New Attempted FU bull",
style=[Link], location=[Link], color=[Link], text="A",
size=[Link])

plotshape(isBullHCS, title="New HCS bull", style=[Link],


location=[Link], color=[Link], text="HCS", size=[Link])

barcolor(isFUBearv6 ? [Link] : na, title="FU bear color")


plotshape(isFUBearv6 and not isBearHCS, title="New FU bear",
style=[Link], location=[Link], color=[Link], text="F",
size=[Link])

barcolor(isAttFUBearv6? [Link] : na, title="Attempted FU bear color")


plotshape(isAttFUBearv6 and not isBearHCS, title="New Attempted FU bear",
style=[Link], location=[Link], color=[Link], text="A",
size=[Link])

plotshape(isBearHCS, title="New HCS bear", style=[Link],


location=[Link], color=[Link], text="HCS", size=[Link])
//---------------------------------------
//Identify inside bars
//---------------------------------------
isInside=high<high[1] and low>low[1]

barcolor(isInside and useInside ? [Link]([Link], 95) : na, title="Inside


bar")

//---------------------------------------
//Identify Fair value gap
//---------------------------------------
color fvg_col = [Link]([Link],70)

fvgcol = [Link](fvg_col, 'Imbalance Colour', inline="1")

fvg_top = low[2] <= open[1] and high[0] >= close[1]


fvgsize_top = low[2] - high[0]
if fvg_top and fvgsize_top > 0
imbalance_top = [Link](left=bar_index[1], top=low[2], right=bar_index[0],
bottom=high[0])
box.set_bgcolor(imbalance_top, fvgcol )
box.set_border_color(imbalance_top, fvgcol )

fvg_bot = high[2] >= open[1] and low[0] <= close[1]


fvgsize_bot = low[0] - high[2]
if fvg_bot and fvgsize_bot > 0
imbalance_bot = [Link](left=bar_index[1], top=low[0], right=bar_index[0],
bottom=high[2])
box.set_bgcolor(imbalance_bot, fvgcol )
box.set_border_color(imbalance_bot, fvgcol)

//---------------------------------------
//Identify Imbalance
//---------------------------------------
imb_low = open==low
imb_high = open==high

plotshape(imb_low, title="Imbalance lower side", style=[Link],


location=[Link], color=[Link], text="Imb", size=[Link],
display=[Link])
plotshape(imb_high, title="Imbalance top side", style=[Link],
location=[Link], color=[Link], text="Imb", size=[Link],
display=[Link])

//---------------------------------------
//Create alert
//---------------------------------------
if isFUBullv6 or isFUBearv6
alert("FU formed", alert.freq_once_per_bar)

//if isAttFUBullv6 or isAttFUBearv6


// alert("Attempted FU formed", alert.freq_once_per_bar)

You might also like