divergence idea needs a help April 29, 2014 01:38PM |
Registered: 10 years ago Posts: 75 |
Re: divergence idea needs a help April 29, 2014 06:36PM |
Registered: 10 years ago Posts: 615 |
input length = 5; input capSpikesAt = 10; def VarP = Round(length / 5); def VarA = Highest(high, VarP) - Lowest(low, VarP); def VarR1 = if VarA == 0 and VarP == 1 then AbsValue(close - close[VarP]) else VarA; def VarB = Highest(high, VarP)[VarP + 1] - Lowest(low, VarP)[VarP]; def VarR2 = if VarB == 0 and VarP == 1 then AbsValue(close[VarP] - close[VarP * 2]) else VarB; def VarC = Highest(high, VarP)[VarP * 2] - Lowest(low, VarP)[VarP * 2]; def VarR3 = if VarC == 0 and VarP == 1 then AbsValue(close[VarP * 2] - close[VarP * 3]) else VarC; def VarD = Highest(high, VarP)[VarP * 3] - Lowest(low, VarP)[VarP * 3]; def VarR4 = if VarD == 0 and VarP == 1 then AbsValue(close[VarP * 3] - close[VarP * 4]) else VarD; def VarE = Highest(high, VarP)[VarP * 4] - Lowest(low, VarP)[VarP * 4]; def VarR5 = if VarE == 0 and VarP == 1 then AbsValue(close[VarP * 4] - close[VarP * 5]) else VarE; def LRange = ((VarR1 + VarR2 + VarR3 + VarR4 + VarR5) / 5) * 0.2; def Var0 = if AbsValue(close - close[1]) > (high - low) then AbsValue(close - close[1]) else (high - low); def LRange2 = if high == low then Average(AbsValue(close - close[1]), 5) * 0.2 else Average(Var0, 5) * 0.2; def range = high + low; def delta = high - low; def median = range / 2; def floatingAxis = Average(median, length); def dynamicVolatilityUnit = if length <= 7 then LRange2 else LRange; def relativeHigh = (high - floatingAxis) / dynamicVolatilityUnit; def relativeLow = (low - floatingAxis) / dynamicVolatilityUnit; def relativeOpen = (open - floatingAxis) / dynamicVolatilityUnit; def relativeClose = (close - floatingAxis) / dynamicVolatilityUnit; def "High" = Min(relativeHigh, capSpikesAt); def "Low" = Max(relativeLow, -capSpikesAt); def bullDiv = (low < low[1]) and (low < low[-1]) and ("Low" > "Low"[1]); def bearDiv = (high > high[1]) and (high > high[-1]) and ("High" < "High"[1]); plot upArrow = if bullDiv and !bullDiv[1] then low * 0.997 else Double.NaN; upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); upArrow.SetLineWeight(4); upArrow.SetDefaultColor(Color.GREEN); plot dnArrow = if bearDiv and !bearDiv[1] then high * 1.003 else Double.NaN; dnArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); dnArrow.SetLineWeight(4); dnArrow.SetDefaultColor(Color.RED);
Re: divergence idea needs a help April 29, 2014 09:25PM |
Registered: 10 years ago Posts: 75 |
Re: divergence idea needs a help April 30, 2014 12:01AM |
Registered: 10 years ago Posts: 615 |
Quote
optiontrader101
WOW Robert , thank you very much , that's really a great job i appreciate it ,
Quote
optiontrader101
it is really working perfectly but I don't know why it missed some divergence in the daily candles
input length = 5; input capSpikesAt = 10; def VarP = Round(length / 5); def VarA = Highest(high, VarP) - Lowest(low, VarP); def VarR1 = if VarA == 0 and VarP == 1 then AbsValue(close - close[VarP]) else VarA; def VarB = Highest(high, VarP)[VarP + 1] - Lowest(low, VarP)[VarP]; def VarR2 = if VarB == 0 and VarP == 1 then AbsValue(close[VarP] - close[VarP * 2]) else VarB; def VarC = Highest(high, VarP)[VarP * 2] - Lowest(low, VarP)[VarP * 2]; def VarR3 = if VarC == 0 and VarP == 1 then AbsValue(close[VarP * 2] - close[VarP * 3]) else VarC; def VarD = Highest(high, VarP)[VarP * 3] - Lowest(low, VarP)[VarP * 3]; def VarR4 = if VarD == 0 and VarP == 1 then AbsValue(close[VarP * 3] - close[VarP * 4]) else VarD; def VarE = Highest(high, VarP)[VarP * 4] - Lowest(low, VarP)[VarP * 4]; def VarR5 = if VarE == 0 and VarP == 1 then AbsValue(close[VarP * 4] - close[VarP * 5]) else VarE; def LRange = ((VarR1 + VarR2 + VarR3 + VarR4 + VarR5) / 5) * 0.2; def Var0 = if AbsValue(close - close[1]) > (high - low) then AbsValue(close - close[1]) else (high - low); def LRange2 = if high == low then Average(AbsValue(close - close[1]), 5) * 0.2 else Average(Var0, 5) * 0.2; def range = high + low; def delta = high - low; def median = range / 2; def floatingAxis = Average(median, length); def dynamicVolatilityUnit = if length <= 7 then LRange2 else LRange; def relativeHigh = (high - floatingAxis) / dynamicVolatilityUnit; def relativeLow = (low - floatingAxis) / dynamicVolatilityUnit; def relativeOpen = (open - floatingAxis) / dynamicVolatilityUnit; def relativeClose = (close - floatingAxis) / dynamicVolatilityUnit; def "High" = Min(relativeHigh, capSpikesAt); def "Low" = Max(relativeLow, -capSpikesAt); def bullDiv = (low <= low[1]) and ("Low" > "Low"[1]); def bearDiv = (high >= high[1]) and ("High" < "High"[1]); plot upArrow = if bullDiv then low * 0.997 else Double.NaN; upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); upArrow.SetLineWeight(4); upArrow.SetDefaultColor(Color.GREEN); plot dnArrow = if bearDiv then high * 1.003 else Double.NaN; dnArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); dnArrow.SetLineWeight(4); dnArrow.SetDefaultColor(Color.RED);
Re: divergence idea needs a help April 30, 2014 08:35AM |
Registered: 10 years ago Posts: 75 |
Re: divergence idea needs a help May 06, 2014 05:20PM |
Registered: 12 years ago Posts: 321 |
Re: divergence idea needs a help May 06, 2014 05:39PM |
Registered: 10 years ago Posts: 615 |
Quote
mtut
Can't seem to get this working as a column signal.
def length = 5; def capSpikesAt = 10; def VarP = Round(length / 5); def VarA = Highest(high, VarP) - Lowest(low, VarP); def VarR1 = if VarA == 0 and VarP == 1 then AbsValue(close - close[VarP]) else VarA; def VarB = Highest(high, VarP)[VarP + 1] - Lowest(low, VarP)[VarP]; def VarR2 = if VarB == 0 and VarP == 1 then AbsValue(close[VarP] - close[VarP * 2]) else VarB; def VarC = Highest(high, VarP)[VarP * 2] - Lowest(low, VarP)[VarP * 2]; def VarR3 = if VarC == 0 and VarP == 1 then AbsValue(close[VarP * 2] - close[VarP * 3]) else VarC; def VarD = Highest(high, VarP)[VarP * 3] - Lowest(low, VarP)[VarP * 3]; def VarR4 = if VarD == 0 and VarP == 1 then AbsValue(close[VarP * 3] - close[VarP * 4]) else VarD; def VarE = Highest(high, VarP)[VarP * 4] - Lowest(low, VarP)[VarP * 4]; def VarR5 = if VarE == 0 and VarP == 1 then AbsValue(close[VarP * 4] - close[VarP * 5]) else VarE; def LRange = ((VarR1 + VarR2 + VarR3 + VarR4 + VarR5) / 5) * 0.2; def Var0 = if AbsValue(close - close[1]) > (high - low) then AbsValue(close - close[1]) else (high - low); def LRange2 = if high == low then Average(AbsValue(close - close[1]), 5) * 0.2 else Average(Var0, 5) * 0.2; def range = high + low; def delta = high - low; def median = range / 2; def floatingAxis = Average(median, length); def dynamicVolatilityUnit = if length <= 7 then LRange2 else LRange; def relativeHigh = (high - floatingAxis) / dynamicVolatilityUnit; def relativeLow = (low - floatingAxis) / dynamicVolatilityUnit; def relativeOpen = (open - floatingAxis) / dynamicVolatilityUnit; def relativeClose = (close - floatingAxis) / dynamicVolatilityUnit; def "High" = Min(relativeHigh, capSpikesAt); def "Low" = Max(relativeLow, -capSpikesAt); def bullDiv = (low <= low[1]) and ("Low" > "Low"[1]); def bearDiv = (high >= high[1]) and ("High" < "High"[1]); def null = !bullDiv and !bearDiv; AddLabel(bullDiv, "Bull Div" ); AddLabel(bearDiv, "Bear Div" ); AddLabel(null, " " ); AssignBackgroundColor(if bullDiv then Color.DARK_GREEN else if bearDiv then Color.DARK_RED else Color.CURRENT);
Re: divergence idea needs a help May 06, 2014 06:34PM |
Registered: 12 years ago Posts: 321 |
Re: divergence idea needs a help May 06, 2014 08:05PM |
Registered: 10 years ago Posts: 615 |
Quote
mtut
I am using your first version that shows fewer signals and I exchanged this code
def bullDiv = (low < low[1]) and (low < low[-1]) and ("Low" > "Low"[1]);
def bearDiv = (high > high[1]) and (high > high[-1]) and ("High" < "High"[1]);
and now the column never finishes loading. been waiting 30 minutes. Your new code loads right in.
def bullDiv = (low < low[1]) and (low < low[-1]) and ("Low" > "Low"[1]);
def bullDiv = (low[1] < low[2]) and (low[1] < low) and ("Low"[1] > "Low"[2]); def bearDiv = (high[1] > high[2]) and (high[1] > high) and ("High"[1] < "High"[2]);
Re: divergence idea needs a help May 07, 2014 09:21PM |
Registered: 11 years ago Posts: 92 |
Re: divergence idea needs a help May 08, 2014 01:03AM |
Registered: 10 years ago Posts: 615 |
Quote
RaleighTrader
I checked the May 6 Daily charts for CSCO, FNMA and YHOO, and didn't see any divergence (at least the way it was taught in RTP class). Is there another time frame or underlying indicator being used to indicate divergence for these stocks? Just curious, thanks much!
RaleighTrader