Shadowunder
New member
Hi, Can anyone please help create a script to automatically draw Boxes for Feigenbaum Fib levels for ES futures, SPY. I am looking to automate what I do manually
1) Grey Box - For the Range (Manual input of the high and low)
2) 3 boxes for the up and down Feigenbaum Fib levels (Fib levels show in graphic below)
3) Vertical line for the 12 am NY open price
There is an existing script I use for SPY for different fib levels, shown down below.
I am hoping someone can modify the above script to achieve the results for Feigenbaum Fib levels for ES futures.
If you are curious about the strategy, check out this person's twitter who came up with the strategy - https://x.com/GGxTrades
Many thanks!
Manual drawings
Feigenbaum Fib levels
Looking for something similar to this:
1) Grey Box - For the Range (Manual input of the high and low)
2) 3 boxes for the up and down Feigenbaum Fib levels (Fib levels show in graphic below)
3) Vertical line for the 12 am NY open price
There is an existing script I use for SPY for different fib levels, shown down below.
I am hoping someone can modify the above script to achieve the results for Feigenbaum Fib levels for ES futures.
If you are curious about the strategy, check out this person's twitter who came up with the strategy - https://x.com/GGxTrades
Many thanks!
Manual drawings
Feigenbaum Fib levels
Looking for something similar to this:
Code:
# © rodOfGod;
#"The ALGO by Timmy (coded by: RodOfGod)";
#INPUTS:;
input rangeType = {GC, PMHiLo, default Manual};
def usePremarketHiLo = rangeType == rangeType.PMHiLo;
def useManualHiLo = rangeType == rangeType.Manual;
input manHi = 571.05;
input manLo = 566.57;
input refSym = "SPY";
input scaleFromRefSym = yes;
input nFibs = 2;
input showRngLines = yes;
input fillRng = yes;
input showFibs = yes;
input showGps = yes;
input showTgts = yes;
input showUp = yes;
input showDn = yes;
input showOnlyToday = yes;
def isToday = if GetLastDay() == GetDay() then 1 else 0;
def showToday = !showOnlyToday or isToday;
def show1 = nFibs >= 1;
def show2 = nFibs >= 2;
def show3 = nFibs >= 3;
def show4 = nFibs >= 4;
def show5 = nFibs >= 5;
#SCALE LEVELS
def numSig = MovAvgExponential(hlc3, 12);
def denSig = MovAvgExponential(hlc3(refSym), 12);
def numerator = if (!IsNaN(numSig) and !IsNaN(denSig)) then numSig else numerator[1];
def denominator = if (!IsNaN(numSig) and !IsNaN(denSig)) then denSig else denominator[1];
def SPYratio = if scaleFromRefSym then MovAvgExponential(numerator / denominator, 15) else 1.0;
AddLabel(scaleFromRefSym, SPYratio, Color.YELLOW);
#DEFAULT STYLE:;
DefineGlobalColor("RangeColor", Color.GRAY);
DefineGlobalColor("GPColor", Color.YELLOW);
DefineGlobalColor("fibColor", Color.BLUE);
DefineGlobalColor("tgtColor", Color.RED);
DefineGlobalColor("fibLabelColor", CreateColor(51, 102, 255));
DefineGlobalColor("tgtLabelColor", CreateColor(255, 102, 51));
def gpWidth = 4;
def gpOpacity = 44;
def tgtWidth = 1;
def tgtOpacity = 100;
#PM Hi/Lo;
def isPremarket = SecondsTillTime(0930) > 0;
def dom = GetDay();
def preHi = if dom != dom[1] then high else if (high > preHi[1] and isPremarket) then high else preHi[1];
def preLo = if dom != dom[1] then low else if (low < preLo[1] and isPremarket) then low else preLo[1];
#GCandle;
def rightTime2 = SecondsTillTime(0800) == 0;
def gcHi = if rightTime2 then high else if dom != dom[1] then 0.0 else gcHi[1] ;
def gcLo = if rightTime2 then low else if dom != dom[1] then 0.0 else gcLo[1] ;
##def rightTime = no;
#WHICH RANGE?;
def locHigh = if useManualHiLo then manHi * SPYratio else if usePremarketHiLo then preHi else gcHi;
def locLow = if useManualHiLo then manLo * SPYratio else if usePremarketHiLo then preLo else gcLo;
#VISIBILITY SETTINGS;
#def showTimeOK = showToday and (if useManualHiLo then yes else if usePremarketHiLo then !isPremarket else gcHi > 0);
def showTimeOK = showToday and (if useManualHiLo then yes else if usePremarketHiLo then !isPremarket else gcHi > 0);
def showUpFibs = showFibs and showUp and showTimeOK;
def showDnFibs = showFibs and showDn and showTimeOK;
def showUpGP = showGps and showUp and showTimeOK;
def showDnGP = showGps and showDn and showTimeOK;
def showUpTgt = showTgts and showUp and showTimeOK;
def showDnTgt = showTgts and showDn and showTimeOK;
#PLOT RANGE;
plot pLocHi = if showToday and locHigh>0 then locHigh else Double.NaN;
pLocHi.SetDefaultColor(GlobalColor("RangeColor"));
pLocHi.SetHiding(!showRngLines);
plot plocLo = if showToday and locHigh>0 then locLow else Double.NaN;
plocLo.SetDefaultColor(GlobalColor("RangeColor"));
plocLo.SetHiding(!showRngLines);
AddCloud(if fillRng then pLocHi else Double.NaN, plocLo, GlobalColor("RangeColor"), GlobalColor("RangeColor"));
#CALCS;
def bodySize = locHigh - locLow;
def point236Size = 0.236 * bodySize;
def point382Size = 0.382 * bodySize;
def point618Size = 0.618 * bodySize;
def point382Size0 = 0.382 * point618Size;
def point618Size0 = 0.618 * point618Size;
#INSIDE FIB GPs;
#fibIn0500 = locLow + 0.5*bodySize;
def fibIn0618 = locLow + point618Size;
def fibIn0382 = locLow + point382Size ;
plot pFibIn0382 = if (showDnGP or showUpGP) then fibIn0382 else Double.NaN;
plot pFibIn0618 = if (showDnGP or showUpGP) then fibIn0618 else Double.NaN;
pFibIn0382.SetDefaultColor(GlobalColor("GPColor"));
pFibIn0618.SetDefaultColor(GlobalColor("GPColor"));
AddCloud(pFibIn0382, pFibIn0618, GlobalColor("GPColor"), GlobalColor("GPColor"));
pFibIn0382.SetHiding(yes);
pFibIn0618.SetHiding(yes);
#DOWN FIBS;
def fibDn1618 = locLow - point618Size;
def fibDn2618 = locLow - bodySize - point618Size;
def fibDn3618 = locLow - 2 * bodySize - point618Size;
def fibDn4618 = locLow - 3 * bodySize - point618Size;
def fibDn5618 = locLow - 4 * bodySize - point618Size;
plot pFibDn1618 = if (show1 and showDnFibs) then fibDn1618 else Double.NaN;
plot pFibDn2618 = if (show2 and showDnFibs) then fibDn2618 else Double.NaN;
plot pFibDn3618 = if (show3 and showDnFibs) then fibDn3618 else Double.NaN;
plot pFibDn4618 = if (show4 and showDnFibs) then fibDn4618 else Double.NaN;
plot pFibDn5618 = if (show5 and showDnFibs) then fibDn5618 else Double.NaN;
pFibDn1618.SetDefaultColor(GlobalColor("fibColor"));
pFibDn2618.SetDefaultColor(GlobalColor("fibColor"));
pFibDn3618.SetDefaultColor(GlobalColor("fibColor"));
pFibDn4618.SetDefaultColor(GlobalColor("fibColor"));
pFibDn5618.SetDefaultColor(GlobalColor("fibColor"));
#DOWN GPs;
def gpDn01Top = locLow - point382Size0;
def gpDn01Bot = locLow - point618Size0;
plot p0A = if (show1 and showDnGP) then gpDn01Top else Double.NaN;
plot p0B = if (show1 and showDnGP) then gpDn01Bot else Double.NaN;
AddCloud(p0A, p0B, GlobalColor("GPColor"), GlobalColor("GPColor"));
p0A.SetHiding(yes);
p0B.SetHiding(yes);
def gpDn12Top = fibDn1618 - point382Size;
def gpDn12Bot = fibDn1618 - point618Size;
plot p1A = if (show2 and showDnGP) then gpDn12Top else Double.NaN;
plot p1B = if (show2 and showDnGP) then gpDn12Bot else Double.NaN;
AddCloud(p1A, p1B, GlobalColor("GPColor"), GlobalColor("GPColor"));
p1A.SetHiding(yes);
p1B.SetHiding(yes);
def gpDn23Top = fibDn2618 - point382Size;
def gpDn23Bot = fibDn2618 - point618Size;
plot p2A = if (show3 and showDnGP) then gpDn23Top else Double.NaN;
plot p2B = if (show3 and showDnGP) then gpDn23Bot else Double.NaN;
AddCloud(p2A, p2B, GlobalColor("GPColor"), GlobalColor("GPColor"));
p2A.SetHiding(yes);
p2B.SetHiding(yes);
def gpDn34Top = fibDn3618 - point382Size;
def gpDn34Bot = fibDn3618 - point618Size;
plot p3A = if (show4 and showDnGP) then gpDn34Top else Double.NaN;
plot p3B = if (show4 and showDnGP) then gpDn34Bot else Double.NaN;
AddCloud(p3A, p3B, GlobalColor("GPColor"), GlobalColor("GPColor"));
p3A.SetHiding(yes);
p3B.SetHiding(yes);
def gpDn45Top = fibDn4618 - point382Size;
def gpDn45Bot = fibDn4618 - point618Size;
plot p4A = if (show5 and showDnGP) then gpDn45Top else Double.NaN;
plot p4B = if (show5 and showDnGP) then gpDn45Bot else Double.NaN;
AddCloud(p4A, p4B, GlobalColor("GPColor"), GlobalColor("GPColor"));
p4A.SetHiding(yes);
p4B.SetHiding(yes);
#UP FIBS;
def fibUp1618 = locHigh + point618Size;
def fibUp2618 = locHigh + bodySize + point618Size;
def fibUp3618 = locHigh + 2 * bodySize + point618Size;
def fibUp4618 = locHigh + 3 * bodySize + point618Size;
def fibUp5618 = locHigh + 4 * bodySize + point618Size;
plot pFibUp1618 = if (show1 and showUpFibs) then fibUp1618 else Double.NaN;
plot pFibUp2618 = if (show2 and showUpFibs) then fibUp2618 else Double.NaN;
plot pFibup3618 = if (show3 and showUpFibs) then fibUp3618 else Double.NaN;
plot pFibUp4618 = if (show4 and showUpFibs) then fibUp4618 else Double.NaN;
plot pFibUp5618 = if (show5 and showUpFibs) then fibUp5618 else Double.NaN;
pFibUp1618.SetDefaultColor(GlobalColor("fibColor"));
pFibUp2618.SetDefaultColor(GlobalColor("fibColor"));
pFibup3618.SetDefaultColor(GlobalColor("fibColor"));
pFibUp4618.SetDefaultColor(GlobalColor("fibColor"));
pFibUp5618.SetDefaultColor(GlobalColor("fibColor"));
#UP GPs;
def gpUp01Bot = locHigh + point382Size0;
def gpUp01Top = locHigh + point618Size0;
plot up0A = if (show1 and showUpGP) then gpUp01Top else Double.NaN;
plot up0B = if (show1 and showUpGP) then gpUp01Bot else Double.NaN;
AddCloud(up0A, up0B, GlobalColor("GPColor"), GlobalColor("GPColor"));
up0A.SetHiding(yes);
up0B.SetHiding(yes);
def gpUp12Bot = fibUp1618 + point382Size;
def gpUp12Top = fibUp1618 + point618Size;
plot up1A = if (show2 and showUpGP) then gpUp12Top else Double.NaN;
plot up1B = if (show2 and showUpGP) then gpUp12Bot else Double.NaN;
AddCloud(up1A, up1B, GlobalColor("GPColor"), GlobalColor("GPColor"));
up1A.SetHiding(yes);
up1B.SetHiding(yes);
def gpUp23Bot = fibUp2618 + point382Size;
def gpUp23Top = fibUp2618 + point618Size;
plot up2A = if (show3 and showUpGP) then gpUp23Top else Double.NaN;
plot up2B = if (show3 and showUpGP) then gpUp23Bot else Double.NaN;
AddCloud(up2A, up2B, GlobalColor("GPColor"), GlobalColor("GPColor"));
up2A.SetHiding(yes);
up2B.SetHiding(yes);
def gpUp34Bot = fibUp3618 + point382Size;
def gpUp34Top = fibUp3618 + point618Size;
plot up3A = if (show4 and showUpGP) then gpUp34Top else Double.NaN;
plot up3B = if (show4 and showUpGP) then gpUp34Bot else Double.NaN;
AddCloud(up3A, up3B, GlobalColor("GPColor"), GlobalColor("GPColor"));
up3A.SetHiding(yes);
up3B.SetHiding(yes);
def gpUp45Bot = fibUp4618 + point382Size;
def gpUp45Top = fibUp4618 + point618Size;
plot up4A = if (show5 and showUpGP) then gpUp45Top else Double.NaN;
plot up4B = if (show5 and showUpGP) then gpUp45Bot else Double.NaN;
AddCloud(up4A, up4B, GlobalColor("GPColor"), GlobalColor("GPColor"));
up4A.SetHiding(yes);
up4B.SetHiding(yes);
#TARGETS;
def fibUp4236 = locHigh + 3 * bodySize + point236Size;
def tgUp4236 = (fibUp4236 + locLow) / 2;
plot tgtUp1 = if (showUpTgt) then tgUp4236 else Double.NaN;
tgtUp1.SetDefaultColor(GlobalColor("tgtColor"));
def fibDn4236 = locLow - 3 * bodySize - point236Size;
def tgDn4236 = (fibDn4236 + locHigh) / 2;
plot tgtDn1 = if (showDnTgt) then tgDn4236 else Double.NaN;
tgtDn1.SetDefaultColor(GlobalColor("tgtColor"));
#BUBBLE LABELS
input showBubbleLabels = yes;
def hbn = BarNumber() == HighestAll(BarNumber());
def stb = showBubbleLabels and hbn;
AddChartBubble(stb and (showRngLines or fillRng), locHigh , "Rng Hi", GlobalColor("RangeColor"), yes);
AddChartBubble(stb and (showRngLines or fillRng), locLow, "Rng Lo", GlobalColor("RangeColor"), no);
AddChartBubble(stb and showDnTgt, tgDn4236, "Down Tgt", GlobalColor("tgtLabelColor"), no);
AddChartBubble(stb and showUpTgt, tgUp4236, "Up Tgt", GlobalColor("tgtLabelColor"), yes);
AddChartBubble(stb and show1 and showDnFibs , fibDn1618, "1.618", GlobalColor("fibLabelColor"), no);
AddChartBubble(stb and show2 and showDnFibs , fibDn2618, "2.618", GlobalColor("fibLabelColor"), no);
AddChartBubble(stb and show3 and showDnFibs , fibDn3618, "3.618", GlobalColor("fibLabelColor"), no);
AddChartBubble(stb and show4 and showDnFibs , fibDn4618, "4.618", GlobalColor("fibLabelColor"), no);
AddChartBubble(stb and show5 and showDnFibs , fibDn5618, "5.618", GlobalColor("fibLabelColor"), no);
AddChartBubble(stb and show1 and showUpFibs , fibUp1618, "1.618", GlobalColor("fibLabelColor"), yes);
AddChartBubble(stb and show2 and showUpFibs , fibUp2618, "2.618", GlobalColor("fibLabelColor"), yes);
AddChartBubble(stb and show3 and showUpFibs , fibUp3618, "3.618", GlobalColor("fibLabelColor"), yes);
AddChartBubble(stb and show4 and showUpFibs , fibUp4618, "4.618", GlobalColor("fibLabelColor"), yes);
AddChartBubble(stb and show5 and showUpFibs , fibUp5618, "5.618", GlobalColor("fibLabelColor"), yes);
Last edited by a moderator: