Hello friends,
I am back today with a bit of a different take on overnight trading levels. This study is intended for daytrading futures and tracks the highs/lows of the globex session and auto-plots fibs (and extensions) based on those levels.
There is another study that is a bit more precise in the plotting of the highs and lows from the exact high and low candle but it recursively scans the entire chart, making it taxing on your system. This one is a bit lighter weight and has 3 options for when the levels print - at RTH open, at a timed start or always. I find the 'always' setting gets a bit messy and prefer to usually start at RTH. The fib levels are customizable and default to .618 and .236.
As with most indicators, context is king. Where are we opening - near the globex highs, right in the middle? These are clues to where price might go next. Add this to your chart and watch typical behaviour. The number of times we revisit the highs and lows each day might surprise you.
I am back today with a bit of a different take on overnight trading levels. This study is intended for daytrading futures and tracks the highs/lows of the globex session and auto-plots fibs (and extensions) based on those levels.
There is another study that is a bit more precise in the plotting of the highs and lows from the exact high and low candle but it recursively scans the entire chart, making it taxing on your system. This one is a bit lighter weight and has 3 options for when the levels print - at RTH open, at a timed start or always. I find the 'always' setting gets a bit messy and prefer to usually start at RTH. The fib levels are customizable and default to .618 and .236.
As with most indicators, context is king. Where are we opening - near the globex highs, right in the middle? These are clues to where price might go next. Add this to your chart and watch typical behaviour. The number of times we revisit the highs and lows each day might surprise you.
Ruby:
# Overnight trading range with Fibs
# Created by @tony_futures
#
input displayType = { "At timed start", default "From RTH Start", "Always"};
input Start_Time = 0800;
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());
def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD());
def Today = if GetLastDay() == GetDay() then 1 else 0;
def ONhigh = if GlobeX and !Globex[1] then high else if Globex and high > ONhigh[1] then high else ONhigh[1];
def ONlow = if GlobeX and !GlobeX[1] then low else if GlobeX and low < ONlow[1] then low else ONlow[1];
def showBubbleNow = !IsNaN(close) and IsNaN(close[-1]);
input showBubbles = yes;
AddChartBubble(showBubbles and showBubbleNow[1], ONHigh[1], "Globex High", Color.GRAY, yes);
AddChartBubble(showBubbles and showBubbleNow[1], ONLow[1], "Globex Low", Color.GRAY, no);
# setup Colors
DefineGlobalColor("openColor", CreateColor(169, 169, 169));
DefineGlobalColor("midColor", CreateColor(94, 110, 59));
DefineGlobalColor("fibColor", CreateColor(28, 96, 109));
DefineGlobalColor("fibColor2", CreateColor(109, 84, 44));
input GlobexFibs = yes;
def NAN = Double.NaN;
input RoundLevel = 0;
input globexFibAmt = 0.618;
input showglobexFib1 = yes;
input showglobexMid = yes;
input showglobexFib1Extensions = no;
def globexFib1 = Round(ONLow + ((ONHigh - ONLow) * globexFibAmt),RoundLevel);
def globexFib2 = Round(ONHigh - ((ONHigh - ONLow) * globexFibAmt),RoundLevel);
plot globexFib1Line = if GlobexFibs and showglobexFib1 and Today and RTH then globexFib1 else NAN;
globexFib1Line.setDefaultColor(GlobalColor("fibColor"));
globexFib1Line.hideBubble();
plot globexFib2Line = if GlobexFibs and showglobexFib1 and Today and RTH then globexFib2 else NAN;
globexFib2Line.setDefaultColor(GlobalColor("fibColor"));
globexFib2Line.hideBubble();
def globexMid = Round(ONHigh - ((ONHigh - ONLow) /2),RoundLevel);
plot globexMidLine = if GlobexFibs and showglobexMid and Today and RTH then globexMid else NAN;
globexMidLine.setDefaultColor(GlobalColor("midColor"));
globexMidLine.hideBubble();
def globexFib3 = Round(ONHigh + ((ONHigh - ONLow) * globexFibAmt),RoundLevel);
plot globexFib3Line = if GlobexFibs and showglobexFib1Extensions and Today and RTH then globexFib3 else NAN;
globexFib3Line.setDefaultColor(GlobalColor("fibColor"));
globexFib3Line.hideBubble();
def globexFib4 = Round(ONLow - ((ONHigh - ONLow) * globexFibAmt),RoundLevel);
plot globexFib4Line = if GlobexFibs and showglobexFib1Extensions and Today and RTH then globexFib4 else NAN;
globexFib4Line.setDefaultColor(GlobalColor("fibColor"));
globexFib4Line.hideBubble();
input globexFibAmt2 = 0.236;
input showglobexFib2 = yes;
def globexFib5 = Round(ONHigh - ((ONHigh - ONLow) * globexFibAmt2),RoundLevel);
plot globexFib5Line = if GlobexFibs and showglobexFib2 and Today and RTH then globexFib5 else NAN;
globexFib5Line.setDefaultColor(GlobalColor("fibColor2"));
globexFib5Line.hideBubble();
def globexFib6 = Round(ONLow + ((ONHigh - ONLow) * globexFibAmt2),RoundLevel);
plot globexFib6Line = if GlobexFibs and showglobexFib2 and Today and RTH then globexFib6 else NAN;
globexFib6Line.setDefaultColor(GlobalColor("fibColor2"));
globexFib6Line.hideBubble();
plot ONL;
ONL.SetDefaultColor(Color.WHITE);
ONL.HideBubble();
plot ONH;
ONH.SetDefaultColor(Color.WHITE);
ONH.HideBubble();
switch (displayType)
{
case "At Timed Start":
ONL = if secondsFromTime(Start_Time) >= 0 and Today then ONLow else nan;
ONH = if secondsFromTime(Start_Time) >= 0 and Today then ONHigh else nan;
case "From RTH Start":
ONL = if today and RTH then ONLow else nan;
ONH = if today and RTH then ONHigh else nan;
case "Always":
ONL = if today then ONLow else nan;
ONH = if today then ONHigh else nan;
}