ApeX Predator
Well-known member
Rally based Rally Label with timeframes
Based on @tradeimbalances criteria below post.
Based on @tradeimbalances criteria below post.
Ruby:
#Modified by SuryaKiranC
#Requested at https://usethinkscript.com/threads/rally-based-rally-label-with-timeframes.7126/
declare once_per_bar;
input ShowArrows = Yes;
input ShowBubbles = No;
def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def isBasingDemandRBR = IsAscending(close, 2)[1] and (IsDown[0] or IsDoji) and IsUp[-1] and open[0] < close[-1] and high[0] < high[-1];
def isBasingDemandDBR = IsDescending(close, 2)[1] and (IsDown[0] or IsDoji) and IsUp[-1] and open[0] < close[-1] and low[0] < low[-1];
def isBasingSupplyDBD = IsDescending(close, 2)[1] and (IsUp[0] or IsDoji) and IsDown[-1] and high[0] > high[-1] and open[0] > close[-1] and low[0] > low[-1];
def isBasingSupplyRBD = IsAscending(close, 2)[1] and (IsUp[0] or IsDoji) and IsDown[-1] and high[0] > high[-1] and open[0] > close[-1];
plot BasingDemandRBR = if isBasingDemandRBR then low else Double.NaN;
plot BasingDemandDBR = if isBasingDemandDBR then high else Double.NaN;
plot BasingSupplyRBD = if isBasingSupplyRBD then low else Double.NaN;
plot BasingSupplyDBD = if isBasingSupplyDBD then high else Double.NaN;
BasingDemandRBR.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BasingDemandRBR.SetDefaultColor(GetColor(1));
BasingDemandRBR.SetHiding(!ShowArrows);
AddChartBubble(ShowBubbles and BasingDemandRBR, low, "RBR",GetColor(1), no);
BasingDemandDBR.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BasingDemandDBR.SetDefaultColor(GetColor(1));
BasingDemandDBR.SetHiding(!ShowArrows);
AddChartBubble(ShowBubbles and BasingDemandDBR, low, "DBR",GetColor(1), no);
BasingSupplyRBD.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BasingSupplyRBD.SetDefaultColor(GetColor(0));
BasingSupplyRBD.SetHiding(!ShowArrows);
AddChartBubble(ShowBubbles and BasingSupplyRBD, high, "RBD",GetColor(0), yes);
BasingSupplyDBD.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BasingSupplyDBD.SetDefaultColor(GetColor(0));
BasingSupplyDBD.SetHiding(!ShowArrows);
AddChartBubble(ShowBubbles and BasingSupplyDBD, high, "DBD",GetColor(0), yes);
Last edited by a moderator: