[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Divergence conversion



PureBytes Links

Trading Reference Links

Can anyone help with this, please...?

Ian

> Hi All,
>       I copy below in text form a Divergence ShowMe, and it works 
> pretty well.
> 
> What I'd like to do is to place Buy and Sell signals at the 
> divergence points so I can experiment with some system testing. I 
> have tried entering Buy & Sell signals after the "TL_New" lines but 
> this causes an error which says you can't put signals in a loop. So I 
> tried setting a flag there and putting the signals a few lines later.
> 
> Bottom line is I can't get it to work. It works a bit on Daily bars 
> using "Date[oSw1Bar]+1"  but I've been unable to do a similar thing 
> with Time and hence been totally unable to get any result with 
> intraday bars. I'm not terribly familiar with trendline drawing so 
> perhaps the loops in those statements are causing problems.
> 
> Anyway, I'd be everso grateful if someone with a little more 
> knowledge of EL would be kind enough to take a look and possibly 
> suggest a solution.
> 
> Thanks.
> 
> Ian
> 
> 
> { SHOWME: PlotDivergence v1.1
> Last modified 2003/03/27
> Shows divergence between price and a user specified indicator.
> 
> Please email me any improvements you make! Thanx! }
> 
> {Copyright (C) 2003 John Price <jp_easylanguage@xxxxxxxx>
> 
> This software is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version.
> 
> This software is distributed in the hope that it will be useful, but
> WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> General Public License for more details.
> 
> You can receive a copy of the GNU General Public License by going to
> http://www.gnu.org/licenses/gpl.txt or writing to the Free Software
> Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
> 02111-1307, USA. }
> 
> Inputs:
> PriceHigh(High), { This should be price (high or close)}
> PriceLow(Low), { This should be price (low or close)}
> Indicator(RSI(Close,5)),{ This is the indicator you want to find 
> divergence in}
> Strength(1), { How many bars on left/right to check to determine a 
> high
> /low}
> Length(30), { How many bars back to look for highs and lows}
> HistoryBars(3), { Number of highs and lows to look at for divergence (
> max is 9)}
> LineColor(magenta), { Color of lines drawn}
> LineSize(0), { Size of lines (0=smallest, 7=largest)}
> LineOffset(0), { How much (in price) above or below bars to draw 
> lines}
> Debug(False); { Plots debug dots}
> 
> Vars:
> HiLo(0),
> oSw1Price1(0),
> oSw1Price2(0),
> oSw1Bar1(0),
> oSw1Bar2(0),
> id(0),
> numBars(0),
> NumOfHistoryBars(0);
> 
> Arrays:
> SwHiVal1[9](0),
> SwHiVal2[9](0),
> SwHiDate[9](0),
> SwHiTime[9](0),
> SwHiBar[9](0),
> SwLoVal1[9](0),
> SwLoVal2[9](0),
> SwLoDate[9](0),
> SwLoTime[9](0),
> SwLoBar[9](0);
> 
> IF HistoryBars < 1 then
> NumOfHistoryBars = 1
> else if HistoryBars > 9 THEN
> NumOfHistoryBars = 9
> else
> NumOfHistoryBars = HistoryBars;
> 
> if barnumber > Length then begin
> HiLo = 1; {look for high pivots }
> Value2 = Pivot(Indicator, Length, Strength, Strength, 1, HiLo, oSw1
> Price2, oSw1Bar2);
> 
> if Value2 = 1 and oSw1Bar2 = Strength then begin
> oSw1Bar1 = HighestBar(PriceHigh, Strength*2); { maybe use 
> SwingHighBar instead }
> IF oSw1Bar1 <> Strength and High[oSw1Bar1] = High[Strength] THEN
> oSw1Bar1 = Strength;
> oSw1Price1 = PriceHigh[oSw1Bar1];
> if Debug then begin
> plot1[Strength](high[Strength]+0.25, "DebugHigh1"); {indicator high}
> plot2[oSw1Bar1](high[oSw1Bar1]+0.75, "DebugHigh2"); {coresponding 
> price high}
> end;
> 
> { push arrays back }
> for Value1 = NumOfHistoryBars-1 downto 0 begin
> SwHiDate[Value1+1] = SwHiDate[Value1];
> SwHiTime[Value1+1] = SwHiTime[Value1];
> SwHiVal1[Value1+1] = SwHiVal1[Value1];
> SwHiVal2[Value1+1] = SwHiVal2[Value1];
> SwHiBar[Value1+1] = SwHiBar[Value1];
> end;
> 
> { store parameters of new SwHi into 0-elements of arrays }
> SwHiDate[0] = Date[oSw1Bar1];
> SwHiTime[0] = Time[oSw1Bar1];
> SwHiVal1[0] = PriceHigh[oSw1Bar1];
> SwHiVal2[0] = oSw1Price2; { value of indiactor at high point }
> SwHiBar[0] = BarNumber;
> 
> for numBars = 1 to NumOfHistoryBars begin
> if SwHiVal1[numBars] <> 0 and
> SwHiBar[numBars] + Length >= BarNumber and
> oSw1Price1 > SwHiVal1[numBars] and
> oSw1Price2 < SwHiVal2[numBars] then begin
> id = TL_New(SwHiDate[numBars], SwHiTime[numBars], SwHiVal1[numBars] + 
> LineOffset,
> Date[oSw1Bar1], Time[oSw1Bar1], oSw1Price1 + LineOffset);
> TL_SetExtLeft(id, false);
> TL_SetExtRight(id, false);
> TL_SetColor(id, LineColor);
> TL_SetSize(id, LineSize);
> end;
> end;
> end;
> 
> HiLo = -1; {look for low pivots }
> Value2 = Pivot(Indicator, Length, Strength, Strength, 1, HiLo, oSw1
> Price2, oSw1Bar2);
> 
> if Value2 = 1 and oSw1Bar2 = Strength then begin
> oSw1Bar1 = LowestBar(PriceLow, Strength*2); { maybe use SwingLowBar 
> instead }
> IF oSw1Bar1 <> Strength and Low[oSw1Bar1] = Low[Strength] THEN
> oSw1Bar1 = Strength;
> oSw1Price1 = PriceLow[oSw1Bar1];
> if Debug then begin
> plot3[Strength](low[Strength]-0.25, "DebugLow1"); {indicator low}
> plot4[oSw1Bar1](low[oSw1Bar1]-0.75, "DebugLow2"); {coresponding price 
> low}
> end;
> 
> { push arrays back }
> for Value1 = NumOfHistoryBars-1 downto 0 begin
> SwLoDate[Value1+1] = SwLoDate[Value1];
> SwLoTime[Value1+1] = SwLoTime[Value1];
> SwLoVal1[Value1+1] = SwLoVal1[Value1];
> SwLoVal2[Value1+1] = SwLoVal2[Value1];
> SwLoBar[Value1+1] = SwLoBar[Value1];
> end;
> 
> { store parameters of new SwHi into 0-elements of arrays }
> SwLoDate[0] = Date[oSw1Bar1];
> SwLoTime[0] = Time[oSw1Bar1];
> SwLoVal1[0] = PriceLow[oSw1Bar1];
> SwLoVal2[0] = oSw1Price2; { value of indiactor at high point }
> SwLoBar[0] = BarNumber;
> 
> for numBars = 1 to NumOfHistoryBars begin
> if SwLoVal1[numBars] <> 0 and
> SwLoBar[numBars] + Length >= BarNumber and
> oSw1Price1 < SwLoVal1[numBars] and
> oSw1Price2 > SwLoVal2[numBars] then begin
> id = TL_New(SwLoDate[numBars], SwLoTime[numBars], SwLoVal1[numBars] - 
> LineOffset,
> Date[oSw1Bar1], Time[oSw1Bar1], oSw1Price1 - LineOffset);
> TL_SetExtLeft(id, false);
> TL_SetExtRight(id, false);
> TL_SetColor(id, LineColor);
> TL_SetSize(id, LineSize);
> end;
> end;
> end;
> end;
> 
>