Mobius Volume Profile Plus

Chuck

Moderator
Staff member
f0zfhdY.png

Volume Profile with Fibonachi Levels and Directional Day Filter. Aggregation for Volume Profile must be set at a higher level than chart aggregation. The Directional Day Filter calculates an average of the first 5Min bar and the extreme values above and below that line for the defined period. If the periods closing above the line are grater than those below the day will finish above that line approximately 65% of the time. Below the opposite holds true. On even distribution days it indicates the likelihood of a flat day. At a turn from either extreme of the range the trend will likely be to the opposite side of the range after 1 ATR. Target should be the closest Fibonacci. If the volume is rising move stop to that level, take 1/2 off and let the trade run to the next Fibonacci, take another 1/2 off and continue to the other extreme end of the range. If the extreme of either end of the range is breached it is likely to continue past the breech for 1 ATR. If the volume spikes above the norm for the day it is likely to trend further and moving stops each additional ATR would be prudent.

Code:
# Begin Code --------------------------------------------------------------------
# Mobius
# Mobius.rts@gmail.com
# Study Name:  Mobius_Volume_Profile_Plus
# Copy and paste the above name to the Study name before saving the new study.
# V02102011.14
# Study Number 112
# Notes: This is not a recommendation or endorsement to trade any equity.
# Trading has extreme risk and you should not trade equities without fully understanding all risks associated with trading.
# Day trading or Intraday trading could and often does cause extreme financial loss.
 
#Hint: Volume Profile with Fibonachi Levels and Directional Day Filter.\n \n Aggregation for Volume Profile must be set at a higher level than chart aggregation. \n The Directional Day Filter calculates an average of the first 5Min bar and the extreme values above and below that line for the defined period. \n If the periods closing above the line are grater than those below the day will finish above that line approximately 65% of the time. \n Below the opposite holds true. \n On even distribution days it indicates the likelihood of a flat day. \n At a turn from either extreme of the range the trend will likely be to the opposite side of the range after 1 ATR. \n Target should be the closest Fibonacci. \n If the volume is rising move stop to that level, take 1/2 off and let the trade run to the next Fibonacci, take another 1/2 off and continue to the other extreme end of the range. \n If the extreme of either end of the range is breached it is likely to continue past the breech for 1 ATR. \n If the volume spikes above the norm for the day it is likely to trend further and moving stops each additional ATR would be prudent.
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {default CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = yes;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 15;
input marketOpenTime = 0930;
input FilterTime = 0935;
input Begin = 0930;
input End = 0935;
input Begin2 = 0930;
input EnDFpoint2 = 1030;
input ShowTodayOnly = {"No", default "Yes"};
def period;
def yyyymmdd = getYyyyMmDd();
def seconds = secondsFromTime(0);
def month = getYear() * 12 + getMonth();
def day_number = daysFromDate(first(yyyymmdd)) + getDayOfWeek(first(yyyymmdd));
def dom = getDayOfMonth(yyyymmdd);
def dow = getDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
    period = floor(seconds / 3600 + day_number * 24);
case DAY:
    period = countTradingDays(min(first(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
    period = floor(day_number / 7);
case MONTH:
    period = floor(month - first(month));
case "OPT EXP":
    period = exp_opt - first(exp_opt);
case BAR:
    period = barNumber() - 1;
}
rec count = if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1];
def cond = count < count[1] + period - period[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}
profile vol = volumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
profile vol2 = volumeProfile("startNewProfile" = cond, "onExpansion" = No, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def con2 = compoundValue(1, close, volume);
rec pc = if IsNaN(vol.getPointOfControl()) and con then pc[1] else vol.getPointOfControl();
rec pc2 = if IsNaN(vol.getPointOfControl()) and con2 then pc2[1] else vol.getPointOfControl();
rec hVA = if IsNaN(vol.getHighestValueArea()) and con then hVA[1] else vol.getHighestValueArea();
rec hva2 = if IsNaN(vol.getHighestValueArea()) and con2 then hva2[1] else vol.getHighestValueArea();
rec lVA = if IsNaN(vol.getLowestValueArea()) and con then lVA[1] else vol.getLowestValueArea();
rec lva2 = if IsNaN(vol.getLowestValueArea()) and con2 then lva2[1] else vol.getLowestValueArea();
rec hProfile = if IsNaN(vol.getHighest()) and con then hProfile[1] else vol.getHighest();
rec hprofile2 = if IsNaN(vol.getHighest()) and con2 then hProfile2[1] else vol.getHighest();
rec lProfile = if IsNaN(vol.getLowest()) and con then lProfile[1] else vol.getLowest();
rec lProfile2 = If IsNaN(vol.getLowest()) and con2 then lProfile2[1] else vol.getLowest();
def plotsDomain = IsNaN(close) == onExpansion;
def plotsDomain2 = IsNaN(close) == close;
plot POC = if plotsDomain then pc else Double.NaN;
plot POC2 = if plotsDomain2 then pc2 else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileHigh2 = if plotsDomain2 then hProfile2 else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot ProfileLow2 = if plotsDomain2 then lProfile2 else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VAHigh2 = if plotsDomain2 then hva2 else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;
plot VALow2 = if plotsDomain2 then lVA else Double.NaN;
DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));
vol.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity);
vol2.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity);
POC.SetDefaultColor(globalColor("Point Of Control"));
POC2.SetDefaultColor(globalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
POC2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(globalColor("Value Area"));
VALow.SetDefaultColor(globalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.hide();
VALow2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh2.SetDefaultColor(globalColor("Value Area"));
VALow2.SetDefaultColor(globalColor("Value Area"));
ProfileHigh2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh2.SetDefaultColor(GetColor(3));
ProfileLow2.SetDefaultColor(GetColor(3));
ProfileHigh2.hide();
ProfileLow2.hide();
plot fib382 = if plotsDomain then round(((hVA - lVA) * .382) + lVA, .25) else Double.NaN;
fib382.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fib382.SetLineWeight(1);
fib382.AssignValueColor(Color.Green);
plot fib50 = if plotsDomain then round(((hVA - lVA) * .5) + lVA, .25) else Double.NaN;
fib50.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fib50.SetLineWeight(1);
fib50.AssignValueColor(Color.Green);
plot fib618 = if plotsDomain then round(((hVA - lVA) * .618) + lVA, .25) else Double.NaN;
fib618.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fib618.SetLineWeight(1);
fib618.AssignValueColor(Color.Green);
plot fibext382 = if plotsDomain then round(((hVA - lVA) * .382) + hVA, .25) else Double.NaN;
fibext382.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fibext382.SetLineWeight(1);
fibext382.AssignValueColor(Color.Red);
plot fibext50 = if plotsDomain then round(((hVA - lVA) * .5) + hVA, .25) else Double.NaN;
fibext50.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fibext50.SetLineWeight(1);
fibext50.AssignValueColor(Color.Red);
plot fibext618 = if plotsDomain then round(((hVA - lVA) * .618) + hVA, .25) else Double.NaN;
fibext618.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fibext618.SetLineWeight(1);
fibext618.AssignValueColor(Color.Red);
plot fibret382 = if plotsDomain then (lVA - round((hVA - lVA) * .382, .25)) else Double.NaN;
fibret382.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fibret382.SetLineWeight(1);
fibret382.AssignValueColor(Color.Blue);
plot fibret50 = if plotsDomain then (lVA - round((hVA - lVA) * .5, .25)) else Double.NaN;
fibret50.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fibret50.SetLineWeight(1);
fibret50.AssignValueColor(Color.Blue);
plot fibret618 = if plotsDomain then (lVA - round((hVA - lVA) * .618, .25)) else Double.NaN;
fibret618.SetPaintingStrategy(PaintingStrategy.Line_VS_Points);
fibret618.SetLineWeight(1);
fibret618.AssignValueColor(Color.Blue);
def secondsFromOpen = secondsFromTime(marketOpenTime);
def s = ShowTodayOnly;
def FilterActive = if secondsTillTime(End) > 0 AND secondsFromTime(Begin) >= 0 then 1 else 0;
def today = if s == 0 OR getDay() == getLastDay() AND secondsFromTime(Begin) >= 0 then 1 else 0;
Rec FilterHigh = if FilterHigh[1] == 0 or FilterActive[1] == 0 AND FilterActive == 1     
                   then high
                   else if FilterActive AND high > FilterHigh[1]
                   then high
                   else FilterHigh[1];
rec FilterLow =  if FilterLow[1] == 0 or FilterActive[1] == 0 AND FilterActive == 1
                   then low
                   else if FilterActive AND low < FilterLow[1]
                   then low else FilterLow[1];
def FilterWidth = FilterHigh - FilterLow;
def na = double.nan;
def FILTERHA = if FilterActive OR today < 1 then na else FilterHigh;
def FILTERLA = if FilterActive OR today < 1 then na else FilterLow;
def O = FILTERHA - (FILTERHA - FILTERLA) / 2;
def FilterActive2 = if secondsTillTime(EnDFpoint2) > 0 AND secondsFromTime(Begin2) >= 0 then 1
      else 0;
rec FilterHigh2 = if FilterHigh2[1] == 0 or FilterActive2[1] == 0 AND FilterActive2 == 1
                    then high
                    else if FilterActive2 AND high > FilterHigh2[1]
                    then high else FilterHigh2[1];
rec FilterLow2 = if FilterLow2[1] == 0 or FilterActive2[1] == 0 AND FilterActive2 == 1 then low
  else if FilterActive2 AND low < FilterLow2[1] then low else FilterLow2[1];
def FilterWidth2 = FilterHigh2 - FilterLow2;
def TimeLine = if secondsTillTime(EnDFpoint2) == 0  then 1 else 0;
AddVerticalLine(secondsFromOpen == 3600, "1st_Hour", color.CYAN);
plot YesterdayClose = close(period = "Day")[1];
YesterdayClose.SetPaintingStrategy(PaintingStrategy.Line);
YesterdayClose.SetLineWeight(1);
YesterdayClose.SetDefaultColor(color.white);
plot FILTERL = if (O == 0 , na, O);
FILTERL.SetDefaultColor(color.Yellow);
FILTERL.SetStyle(curve.Long_DASH);
FILTERL.SetLineWeight(3);
plot FILTERH2 = if FilterActive2 OR today < 1 then na else FilterHigh2;
plot FILTERL2 = if FilterActive2 OR today < 1 then na else FilterLow2;
FILTERH2.SetDefaultColor(color.green);
FILTERH2.SetStyle(curve.Long_DASH);
FILTERH2.SetLineWeight(3);
FILTERL2.SetDefaultColor(color.red);
FILTERL2.SetStyle(curve.Long_DASH);
FILTERL2.SetLineWeight(3);
def DFpoint = (FILTERH2 - FILTERL2) / 10;
plot DFpoint1 = if (TimeLine , FILTERH2, na);
plot DFpoint2 = if (TimeLine , FILTERH2 - ( DFpoint * 2), na);
plot DFpoint3 = if (TimeLine , FILTERH2 - ( DFpoint * 3), na);
plot DFpoint4 = if (TimeLine , FILTERH2 - ( DFpoint * 4), na);
plot DFpoint5 = if (TimeLine , FILTERH2 - ( DFpoint * 5), na);
plot DFpoint6 = if (TimeLine , FILTERH2 - ( DFpoint * 6), na);
plot DFpoint7 = if (TimeLine , FILTERH2 - ( DFpoint * 7), na);
plot DFpoint8 = if (TimeLine , FILTERH2 - ( DFpoint * 8), na);
plot DFpoint9 = if (TimeLine , FILTERH2 - ( DFpoint * 9), na);
plot DFpoint10 = if (TimeLine , (FILTERL2), na);
DFpoint1.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint2.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint3.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint4.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint5.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint6.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint7.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint8.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint9.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint10.SetPaintingStrategy(PaintingStrategy.POINTS);
DFpoint1.SetDefaultColor(Color.YELLOW);
DFpoint2.SetDefaultColor(Color.YELLOW);
DFpoint3.SetDefaultColor(Color.YELLOW);
DFpoint4.SetDefaultColor(Color.YELLOW);
DFpoint5.SetDefaultColor(Color.YELLOW);
DFpoint6.SetDefaultColor(Color.YELLOW);
DFpoint7.SetDefaultColor(Color.YELLOW);
DFpoint8.SetDefaultColor(Color.YELLOW);
DFpoint9.SetDefaultColor(Color.YELLOW);
DFpoint10.SetDefaultColor(Color.YELLOW);
# End Code----------------------------
 
Last edited:
Top