Script Indicateur
Script Indicateur
0 at
https://mozilla.org/MPL/2.0/
// © Jager1703
//@version=5
indicator("RedPillFX",shorttitle="RedPillFX",overlay=true, max_bars_back=1000,
max_labels_count=500, max_lines_count=500, max_boxes_count=500)
///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
var GRP40="Notes"
/////////////////////////////////////////////////////////
sessionOpen
SessionClose(sessionTime, sessionTimeZone=syminfo.timezone) =>
insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
var float sessionClose = na
sessionClose
///////////////////////////////////////////////////////////
sessionClose1
////////////////////////////////////////////////////////////
//Midnight Open
midOpen
///////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//London Session
/////////////////////////////////////////////////////////////////////
//////////////////////////////////////////
startTime = 0
startTime := inSession and not inSession[1] ? time : startTime[1]
//Box lines
var line lowHLine = na
var line topHLine = na
var line leftVLine = na
var line rightVLine = na
var line middleHLine = na
var box bgBox = na
// Plot lines
if inSession and timeframe.isintraday
if inSession[1]
line.delete(lowHLine)
line.delete(topHLine)
line.delete(leftVLine)
line.delete(rightVLine)
line.delete(middleHLine)
box.delete(bgBox)
//Create Box
//x1, y1, x2, y2
if showBackground
bgBox := box.new(startTime, high_val, time, low_val, xloc=xloc.bar_time,
bgcolor=backgroundColor, border_width=0)
if showLines
lowHLine := line.new(startTime, low_val, time, low_val, xloc=xloc.bar_time,
color=lineColor0, style=line.style_solid, width=linesWidth)
topHLine := line.new(startTime, high_val, time, high_val,
xloc=xloc.bar_time, color=lineColor0, style=line.style_solid, width=linesWidth)
leftVLine := line.new(startTime, high_val, startTime, low_val,
xloc=xloc.bar_time, color=lineColor0, style=line.style_solid, width=linesWidth)
rightVLine := line.new(time, high_val, time, low_val, xloc=xloc.bar_time,
color=lineColor0, style=line.style_solid, width=linesWidth)
else
if inExtend and showLines and not inSession and timeframe.isintraday
time1 = line.get_x1(lowHLine)
time2 = line.get_x2(lowHLine)
price = line.get_y1(lowHLine)
line.delete(lowHLine)
lowHLine := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=lineColor0, style=line.style_solid, width=linesWidth)
time1 := line.get_x1(topHLine)
time2 := line.get_x2(topHLine)
price := line.get_y1(topHLine)
line.delete(topHLine)
topHLine := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=lineColor0, style=line.style_solid, width=linesWidth)
if inExtend and showMiddleLine and not inSession and timeframe.isintraday
time1 = line.get_x1(middleHLine)
time2 = line.get_x2(middleHLine)
price = line.get_y1(middleHLine)
line.delete(middleHLine)
middleHLine := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=lineColor0, style=line.style_solid, width=linesWidth)
middleHLine
////////////////////////////////////////////
////////////////////////////////////////
startTime1 = 0
startTime1 := inSession1 and not inSession1[1] ? time : startTime1[1]
//Box lines
var line lowHLine1 = na
var line topHLine1 = na
var line leftVLine1 = na
var line rightVLine1 = na
var line middleHLine1 = na
var box bgBox1 = na
// Plot lines
if inSession1 and timeframe.isintraday
if inSession1[1]
line.delete(lowHLine1)
line.delete(topHLine1)
line.delete(leftVLine1)
line.delete(rightVLine1)
line.delete(middleHLine1)
box.delete(bgBox1)
//Create Box
//x1, y1, x2, y2
if showBackground1
bgBox1 := box.new(startTime1, high_val1, time, low_val1,
xloc=xloc.bar_time, bgcolor=backgroundColor1, border_width=0)
if showLines1
lowHLine1 := line.new(startTime1, low_val1, time, low_val1,
xloc=xloc.bar_time, color=lineColor1, style=line.style_solid, width=linesWidth1)
topHLine1 := line.new(startTime1, high_val1, time, high_val1,
xloc=xloc.bar_time, color=lineColor1, style=line.style_solid, width=linesWidth1)
leftVLine1 := line.new(startTime1, high_val1, startTime1, low_val1,
xloc=xloc.bar_time, color=lineColor1, style=line.style_solid, width=linesWidth1)
rightVLine1 := line.new(time, high_val1, time, low_val1,
xloc=xloc.bar_time, color=lineColor1, style=line.style_solid, width=linesWidth1)
else
if inExtend1 and showLines1 and not inSession1 and timeframe.isintraday
time1 = line.get_x1(lowHLine1)
time2 = line.get_x2(lowHLine1)
price = line.get_y1(lowHLine1)
line.delete(lowHLine1)
lowHLine1 := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=lineColor1, style=line.style_solid, width=linesWidth1)
time1 := line.get_x1(topHLine1)
time2 := line.get_x2(topHLine1)
price := line.get_y1(topHLine1)
line.delete(topHLine1)
topHLine1 := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=lineColor1, style=line.style_solid, width=linesWidth1)
if inExtend1 and showMiddleLine1 and not inSession1 and timeframe.isintraday
time1 = line.get_x1(middleHLine1)
time2 = line.get_x2(middleHLine1)
price = line.get_y1(middleHLine1)
line.delete(middleHLine1)
middleHLine1 := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=lineColor1, style=line.style_solid, width=linesWidth1)
middleHLine1
//////////////////////////////////////////////////////////////////
startTime2 = 0
startTime2 := inSession2 and not inSession2[1] ? time : startTime2[1]
//Box lines
// Plot lines
//Create Box
//x1, y1, x2, y2
if showBackground2
bgBox2 := box.new(startTime2, high_val2, time, low_val2,
xloc=xloc.bar_time, bgcolor=backgroundColor2, border_width=0)
////////////////////////////////////////////
startTime6 = 0
startTime6 := inSession6 and not inSession6[1] ? time : startTime6[1]
//Box lines
// Plot lines
//Create Box
//x1, y1, x2, y2
if showBackground6
bgBox6 := box.new(startTime6, high_val6, time, low_val6,
xloc=xloc.bar_time, bgcolor=backgroundColor6, border_width=0)
///////////////////////////////////////////////////////////////////////
startTime3 = 0
startTime3 := inSession3 and not inSession3[1] ? time : startTime3[1]
//Box lines
// Plot lines
//Create Box
//x1, y1, x2, y2
if showBackground3
bgBox3 := box.new(startTime3, high_val3, time, low_val3,
xloc=xloc.bar_time, bgcolor=backgroundColor3, border_width=0)
///////////////////////////////////////////////
startTime4 = 0
startTime4 := inSession4 and not inSession4[1] ? time : startTime4[1]
// Plot lines
else
if inExtend4 and showLines4 and not inSession4 and timeframe.isintraday
time1 = line.get_x1(lowHLine4)
time2 = line.get_x2(lowHLine4)
price = line.get_y1(lowHLine4)
line.delete(lowHLine4)
lowHLine4 := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=LineColor4, style=line.style_solid,width=linesWidth4)
///////////////////////////////////////////
//Frankurt Open
frOpen
startTime5 = 0
startTime5 := inSession5 and not inSession5[1] ? time : startTime5[1]
// Plot lines
else
if inExtend5 and showLines5 and not inSession5 and timeframe.isintraday
time1 = line.get_x1(lowHLine5)
time2 = line.get_x2(lowHLine5)
price = line.get_y1(lowHLine5)
line.delete(lowHLine5)
lowHLine5 := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=LineColor5, style=line.style_solid,width=linesWidth5)
///////////////////////////////////////////////////////
startTime7 = 0
startTime7 := inSession7 and not inSession7[1] ? time : startTime7[1]
//Box lines
// Plot lines
//Create Box
//x1, y1, x2, y2
if showBackground7
bgBox7 := box.new(startTime7, high_val7, time, low_val7,
xloc=xloc.bar_time, bgcolor=backgroundColor7, border_width=0)
//////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//London Open
lnOpen
startTime8 = 0
startTime8 := inSession8 and not inSession8[1] ? time : startTime8[1]
// Plot lines
else
if inExtend8 and showLines8 and not inSession8 and timeframe.isintraday
time1 = line.get_x1(lowHLine8)
time2 = line.get_x2(lowHLine8)
price = line.get_y1(lowHLine8)
line.delete(lowHLine8)
lowHLine8 := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=LineColor8, style=line.style_solid,width=linesWidth8)
///////////////////////////////////////////////////////////////
//NY Open
nyOpen
startTime9 = 0
startTime9 := inSession9 and not inSession9[1] ? time : startTime9[1]
// Plot lines
else
if inExtend9 and showLines9 and not inSession9 and timeframe.isintraday
time1 = line.get_x1(lowHLine9)
time2 = line.get_x2(lowHLine9)
price = line.get_y1(lowHLine9)
line.delete(lowHLine9)
lowHLine9 := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=LineColor9, style=line.style_solid,width=linesWidth9)
//////////////////////////////////////////////////////////////////////
st = true
londonkz = input.session(title='KillZone London Open', defval='0330-
0545',group=GRP9)
newyorkkz = input.session(title='KillZone NY Open', defval='0830-1045',group=GRP9)
londonckz = input.session(title='KillZone London Close', defval='1100-
1400',group=GRP9)
boxheight = input(title='Box Height', defval=3.0,group=GRP9)
ShowBoxes = input(title="Show Boxes",defval= true,group=GRP9)
dayrange = h - l
high2 = h + dayrange * 0.01 * boxheight
low2 = l - dayrange * 0.01 * boxheight
BarInSession(sess) =>
time(timeframe.period, sess) != 0
//LONDON
varhigh2 = plot(st and h and BarInSession(londonkz) and ShowBoxes ? high2 : na,
title='Box 1 High', style=plot.style_linebr, linewidth=2, color=na) // change
color=na to color to make these lines visible/editable
varhigh = plot(st and h and BarInSession(londonkz) and ShowBoxes ? h : na,
title='Box 1 Low', style=plot.style_linebr, linewidth=2, color=na) // change
color=na to color to make these lines visible/editable
varlow = plot(st and l and BarInSession(londonkz) and ShowBoxes ? l : na,
title='Box 2 High', style=plot.style_linebr, linewidth=2, color=na) // change
color=na to color to make these lines visible/editable
varlow2 = plot(st and l and BarInSession(londonkz) and ShowBoxes ? low2 : na,
title='Box 2 Low', style=plot.style_linebr, linewidth=2, color=na) // change
color=na to color to make these lines visible/editable
//NEW YORK
v1 = plot(st and h and BarInSession(newyorkkz) and ShowBoxes ? high2 : na,
title='Box 3 High', style=plot.style_linebr, linewidth=2, color=na)
v2 = plot(st and h and BarInSession(newyorkkz) and ShowBoxes ? h : na, title='Box 3
Low', style=plot.style_linebr, linewidth=2, color=na)
v3 = plot(st and l and BarInSession(newyorkkz) and ShowBoxes ? l : na, title='Box 4
High', style=plot.style_linebr, linewidth=2, color=na)
v4 = plot(st and l and BarInSession(newyorkkz) and ShowBoxes ? low2 : na,
title='Box 4 Low', style=plot.style_linebr, linewidth=2, color=na)
//LONDON close
///////////////////////////////////////////////
//ALGO SESSIONS
//Algos Sessions
var GRP30="Algos"
startTime30 = 0
startTime30 := inSession30 and not inSession30[1] ? time : startTime30[1]
//Box Lines
var line leftVLine30 = na
var line rightVLine30 = na
// Plot lines
if inSession30 and timeframe.isintraday
if inSession30[1]
line.delete(leftVLine30)
line.delete(rightVLine30)
//Create Algo
if showLines30
leftVLine30 := line.new(startTime30, high3, startTime30, low3,
xloc=xloc.bar_time, color=colorAlgo, style=line.style_solid, width=linesWidth7)
rightVLine30 := line.new(time, high3, time, low3, xloc=xloc.bar_time,
color=colorAlgo, style=line.style_solid, width=linesWidth7)
//Algo2
startTime31 = 0
startTime31 := inSession31 and not inSession31[1] ? time : startTime31[1]
//Create Algo
if showLines30
leftVLine31 := line.new(startTime31, high3, startTime31, low3,
xloc=xloc.bar_time, color=colorAlgo, style=line.style_solid, width=linesWidth7)
rightVLine31 := line.new(time, high3, time, low3, xloc=xloc.bar_time,
color=colorAlgo, style=line.style_solid, width=linesWidth7)
//Algo3
startTime32 = 0
startTime32 := inSession32 and not inSession32[1] ? time : startTime32[1]
// Plot lines
if inSession32 and timeframe.isintraday
if inSession32[1]
line.delete(leftVLine32)
line.delete(rightVLine32)
//Create Algo
if showLines30
leftVLine32 := line.new(startTime32, high3, startTime32, low3,
xloc=xloc.bar_time, color=colorAlgo, style=line.style_solid, width=linesWidth7)
rightVLine32 := line.new(time, high3, time, low3, xloc=xloc.bar_time,
color=colorAlgo, style=line.style_solid, width=linesWidth7)
//Algo4
startTime33 = 0
startTime33 := inSession33 and not inSession33[1] ? time : startTime33[1]
// Plot lines
if inSession33 and timeframe.isintraday
if inSession33[1]
line.delete(leftVLine33)
line.delete(rightVLine33)
//Create Algo
if showLines30
leftVLine33 := line.new(startTime33, high3, startTime33, low3,
xloc=xloc.bar_time, color=colorAlgo, style=line.style_solid, width=linesWidth7)
rightVLine33 := line.new(time, high3, time, low3, xloc=xloc.bar_time,
color=colorAlgo, style=line.style_solid, width=linesWidth7)
//Algo5
startTime34 = 0
startTime34 := inSession34 and not inSession34[1] ? time : startTime34[1]
// Plot lines
if inSession34 and timeframe.isintraday
if inSession34[1]
line.delete(leftVLine34)
line.delete(rightVLine34)
//Create Algo
if showLines30
leftVLine34 := line.new(startTime34, high3, startTime34, low3,
xloc=xloc.bar_time, color=colorAlgo, style=line.style_solid, width=linesWidth7)
rightVLine34 := line.new(time, high3, time, low3, xloc=xloc.bar_time,
color=colorAlgo, style=line.style_solid, width=linesWidth7)
//Algo6
startTime35 = 0
startTime35 := inSession35 and not inSession35[1] ? time : startTime35[1]
// Plot lines
if inSession35 and timeframe.isintraday
if inSession35[1]
line.delete(leftVLine35)
line.delete(rightVLine35)
//Create Algo
if showLines30
leftVLine35 := line.new(startTime35, high3, startTime35, low3,
xloc=xloc.bar_time, color=colorAlgo, style=line.style_solid, width=linesWidth7)
rightVLine35 := line.new(time, high3, time, low3, xloc=xloc.bar_time,
color=colorAlgo, style=line.style_solid, width=linesWidth7)
///////////////////////////////////////////////////////////////////////////////////
/////
//Jours de La Semaine
var GRP10="Day of the Week"
int new_day_start_time = 00
//////////////////////////////////////////////
//PDH/L
var GRP8="PDL/H"
//--------------------------------------------------------------------
// Constants
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Inputs
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Functions
//--------------------------------------------------------------------
f_draw(bool _isNew, float _h, float _l, int _lookback, color _color, string _style,
int _width) =>
var line _high = na
var line _low = na
var _highs = array.new_line()
var _lows = array.new_line()
_end = i_areHeadsEnabled ? f_getRightBarIndex() : bar_index
if _isNew
line.set_x2(_high, _end)
line.set_x2(_low, _end)
//--------------------------------------------------------------------
// Logic
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Plotting & styling
//--------------------------------------------------------------------
if canShowMonthly
f_draw(hasMonthlyTimeChanged, monthlyHigh, monthlyLow, i_monthlyLookback,
i_monthlyColor, MONTHLY_LINE_STYLE, MONTHLY_LINE_WIDTH)
if canShowWeekly
f_draw(hasWeekklyTimeChanged, weeklyHigh, weeklyLow, i_weeklyLookback,
i_weeklyColor, WEEKLY_LINE_STYLE, WEEKLY_LINE_WIDTH)
if canShowDaily
f_draw(hasDailyTimeChanged, dailyHigh, dailyLow, i_dailyLookback, i_dailyColor,
DAILY_LINE_STYLE, DAILY_LINE_WITDH)
// Plot invisible highs and lows for displaying their last values in `status line`,
`scale`, `data window` as well for providing defaults alert conditions
////////////////////////////////////////////
//Imbalance
showImbalance = input(true,title="Show Imbalances",group="Imbalance")
imbRestClr = input.color(#ffeb3b, title="Color Imbalance",group="Imbalance")
var float topValue = na, var float bottomValue = na
//IMBALANCE
//Data
L1 = low
H3 = high[2]
H1 = high
L3 = low[2]
FVGUp = H3 < L1 ? 1 : 0
plotFVGU = FVGUp ? H3 : na
plotFVGUL = FVGUp ? L1 : na
FVGDown = L3 > H1 ? 1 : 0
plotFVGD = FVGDown ? L3 : na
plotFVGH = FVGDown ? H1 : na
/////////////////////////////////////////////////////////////
//CLS Zones
startTime11 = 0
startTime11 := inSession11 and not inSession11[1] ? time : startTime11[1]
//Box Lines
var line leftVLine11 = na
var line rightVLine11 = na
// Plot lines
if inSession11 and timeframe.isintraday
if inSession11[1]
line.delete(leftVLine11)
line.delete(rightVLine11)
//Create CLS
if showLines11
leftVLine11 := line.new(startTime11, high4, startTime11, low4,
xloc=xloc.bar_time, color=colorClsLines, style=line.style_solid,
width=linesWidth11)
rightVLine11 := line.new(time, high4, time, low4, xloc=xloc.bar_time,
color=colorClsLines, style=line.style_solid, width=linesWidth11)
//CLS London
startTime12 = 0
startTime12 := inSession12 and not inSession12[1] ? time : startTime12[1]
// Plot lines
if inSession12 and timeframe.isintraday
if inSession12[1]
line.delete(leftVLine12)
line.delete(rightVLine12)
//Create CLS
if showLines11
leftVLine12 := line.new(startTime12, high4, startTime12, low4,
xloc=xloc.bar_time, color=colorClsLines, style=line.style_solid,
width=linesWidth11)
rightVLine12 := line.new(time, high4, time, low4, xloc=xloc.bar_time,
color=colorClsLines, style=line.style_solid, width=linesWidth11)
// CLS NY
startTime13 = 0
startTime13 := inSession13 and not inSession13[1] ? time : startTime13[1]
// Plot lines
if inSession13 and timeframe.isintraday
if inSession13[1]
line.delete(leftVLine13)
line.delete(rightVLine13)
//Create CLS
if showLines11
leftVLine13 := line.new(startTime13, high4, startTime13, low4,
xloc=xloc.bar_time, color=colorClsLines, style=line.style_solid,
width=linesWidth11)
rightVLine13 := line.new(time, high4, time, low4, xloc=xloc.bar_time,
color=colorClsLines, style=line.style_solid, width=linesWidth11)
// CLS Last
startTime14 = 0
startTime14 := inSession14 and not inSession14[1] ? time : startTime14[1]
// Plot lines
if inSession14 and timeframe.isintraday
if inSession14[1]
line.delete(leftVLine14)
line.delete(rightVLine14)
//Create CLS
if showLines11
leftVLine14 := line.new(startTime14, high4, startTime14, low4,
xloc=xloc.bar_time, color=colorClsLines, style=line.style_solid,
width=linesWidth11)
rightVLine14 := line.new(time, high4, time, low4, xloc=xloc.bar_time,
color=colorClsLines, style=line.style_solid, width=linesWidth11)
//////////////////////////////////////////////
// Fractals
var GRP0="Fractal"
fractalShow = input(title="Show Fractal",defval=true,group=GRP0)
fractalPeriods = input.int(title='Fractal Periods', defval=2, minval=1,group=GRP0)
colorBullFractal = input(color.new(color.red,0),title="Color Bear
Fractal",group=GRP0)
colorBearFractal = input(color.new(color.green,0),title="Color Bull
Fractal",group=GRP0)
bullFractal = ta.pivothigh(fractalPeriods, fractalPeriods)
bearFractal = ta.pivotlow(fractalPeriods, fractalPeriods)
plotshape(bullFractal and fractalShow ? true : na, title='Bull
Fractal',style=shape.triangledown, location=location.abovebar, offset=-
fractalPeriods, color=colorBullFractal)
plotshape(bearFractal and fractalShow? true : na, title='Bear
Fractal',style=shape.triangleup, location=location.belowbar, offset=-
fractalPeriods, color=colorBearFractal)
////////////////////////////////////////////////////////
//Notes