Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

aaa

Stochastic Divergence TrendLine

Recommended Posts

// Sto Divergence TrendLine

// Author: MARKPLEX

// version: 1.0

 

// Author: aaa

// version: 2.0

// Date: 20091129

// added:

// divergence on top +

// Line.Color.Top + Line.Color.Bot + Line.Size + Plot.Sto in inputs

 

From

 

http://markplex.com/tutorial4.php

 

--------------------------------------------------------

 

attachment.php?attachmentid=16297&stc=1&d=1260006509

Snap1.jpg.0587c4123cb5defef4ed242367a7e6ef.jpg

Sto Divergence TrendLine.txt

Sto Divergence TrendLine.pla

Sto Divergence TrendLine.ELD

Share this post


Link to post
Share on other sites

Hello,

 

I give you my version. I use it with various indicators. I think the author is Marplex.

Sorry for my bad english.

 

inputs: periodlen(1),colorH(white), colorL(yellow),period(30),smooth(1),type(1),length(20),leftstrength(3),RightStrength(1),Bartol(3);
vars: Pivotprice1(0), pivotbar1(0),Pivotprice2(0), pivotbar2(0),Pivotprice3(0), pivotbar3(0),Pivotprice4(0), pivotbar4(0),
Pivotprice5(0), pivotbar5(0),Pivotprice6(0), pivotbar6(0),Pivotprice7(0), pivotbar7(0),Pivotprice8(0), pivotbar8(0);

value1=[color="Red"]yourindicator[/color](periodlen);

//market pivot:

// pivot low
condition3 = pivot(low,length,leftstrength,RightStrength,1,-1,pivotprice3,pivotbar3)<>-1;
condition4 = pivot(low,length,leftstrength,RightStrength,2,-1,pivotprice4,pivotbar4)<>-1;

//pivot high
condition5 = pivot(high,length,leftstrength,RightStrength,1,1,pivotprice5,pivotbar5)<>-1;
condition6 = pivot(high,length,leftstrength,RightStrength,2,1,pivotprice6,pivotbar6)<>-1;


//indicator pivot:


//pivot low
condition1 = pivot(value1,length,leftstrength,RightStrength,1,-1,pivotprice1,pivotbar1)<>-1;
condition2 = pivot(value1,length,leftstrength,RightStrength,2,-1,pivotprice2,pivotbar2)<>-1;


//pivot high
condition7 = pivot(value1,length,leftstrength,RightStrength,1,1,pivotprice7,pivotbar7)<>-1;
condition8 = pivot(value1,length,leftstrength,RightStrength,2,1,pivotprice8,pivotbar8)<>-1;

//last low

if condition3 and condition4 and condition2 and condition1 
and (absvalue(pivotbar1-pivotbar3)<bartol)
and (absvalue(pivotbar2-pivotbar4)<bartol)
and(pivotbar3=RightStrength or pivotbar1 = RightStrength)
and (Pivotprice3<=Pivotprice4 and pivotprice1>Pivotprice2)
and barstatus(1)=2 then begin

value2 = tl_new_s(D[pivotbar4],time_s[pivotbar4],l[pivotbar4],D[pivotbar3],time_s[pivotbar3],l[pivotbar3]);
tl_setcolor(value2,colorL);
tl_setsize(value2,3);
end;

//last high

if condition5 and condition6 and condition7 and condition8 
and (absvalue(pivotbar7-pivotbar5)<bartol)
and (absvalue(pivotbar8-pivotbar6)<bartol)
and(pivotbar5=RightStrength or pivotbar7 = RightStrength)
and (Pivotprice5>=Pivotprice6 and pivotprice7<Pivotprice8)
and barstatus(1)=2 then begin

value3 = tl_new_s(D[pivotbar6],time_s[pivotbar6],h[pivotbar6],D[pivotbar5],time_s[pivotbar5],h[pivotbar5]);
tl_setcolor(value3,colorh);
tl_setsize(value3,3);
end;

 

Sincerely,

Franck

Share this post


Link to post
Share on other sites

Hi Xavi7

This indicator is written for an Easy Language platform

I guess that it is possible to make a translation for any other platform.

rgds

Edited by aaa

Share this post


Link to post
Share on other sites

I was able to apply divergence to both the price and indicator. Thank you AAA for putting the original together. The below modification applies to the stochrsi:

 

 

// StochRSI Divergence TrendLine
// Author: MARKPLEX
// http://markplex.com/tutorial4.php
// version: 1.0

// Author: aaa
// version: 2.0
// Date: 20091129
// added: 
// divergence on top +
// Line.Color.Top + Line.Color.Bot + Line.Size + Plot.Sto in inputs

//----------------------------------------------------
inputs:
//----------------------------------------------------


RSILength(9),
StochLength(18),
KLength(6),
DLength(3),
OverSold(20),
OverBought(80),
Length(20),
LeftStrength(3),
RightStrength(3),
Line.Color.Top(red),
Line.Color.Bot(blue),
Line.Size(2),
Plot.stochrsi(1);

//---------------------------------------------------- 
variables:
//----------------------------------------------------

DToscK(0), 
DToscD(0),

oPivotPrice1(0),
oPivotBar1(0),
oPivotPrice2(0),
oPivotBar2(0),

oPivotPrice11(0),
oPivotBar11(0),
oPivotPrice12(0),
oPivotBar12(0);

value1 = FastKCustomEasy(RSI(C, RSILength),StochLength);
DToscK =  average(value1,KLength);
DToscD = average(DToscK,DLength);

Condition1 = Pivot( DToscK, Length, LeftStrength, RightStrength, 1, -1, oPivotPrice1, oPivotBar1 ) <> -1 
	AND ( oPivotBar1 - RightStrength ) = 0 ;

Condition11 = Pivot( DToscK, Length, LeftStrength, RightStrength, 1, 1, oPivotPrice11, oPivotBar11 ) <> -1 
	AND ( oPivotBar11 - RightStrength ) = 0 ;

Condition2 = Pivot( DToscK, Length, LeftStrength, RightStrength, 2, -1, oPivotPrice2, oPivotBar2 ) <> -1;

Condition12 = Pivot( DToscK, Length, LeftStrength, RightStrength, 2, 1, oPivotPrice12, oPivotBar12 ) <> -1;

If 
	Condition1 and Condition2 // added condition2 = referecne future data
	AND L[oPivotBar2] >= L[oPivotBar1] 
	AND DToscK[oPivotBar2] < DToscK[oPivotBar1] then 
Begin
	Value2 = TL_New(D[oPivotBar2], T[oPivotBar2], L[oPivotBar2], D[oPivotBar1], T[oPivotBar1], L[oPivotBar1]); 
	TL_SetColor( Value2, Line.Color.Bot );
	TL_SetSize(  Value2, Line.Size  );
End;

If 
	Condition11 and Condition12 // added condition12  referecne future data
	AND H[oPivotBar12] <= H[oPivotBar11] 
	AND DToscK[oPivotBar12] > DToscK[oPivotBar11] then 
Begin
	Value12 = TL_New(D[oPivotBar12], T[oPivotBar12], H[oPivotBar12], D[oPivotBar11], T[oPivotBar11], H[oPivotBar11]); 
	TL_SetColor( Value12, Line.Color.Top );
	TL_SetSize(  Value12, Line.Size  );
End;

if Plot.stochrsi <> 0 then	
Plot1( DToscK );


condition3 = Pivot( DToscK, Length, LeftStrength, RightStrength, 1, -1, oPivotPrice1, oPivotBar1 ) <> -1 
	AND ( oPivotBar1 - RightStrength ) = 0 ;

condition32 = Pivot( DToscK, Length, LeftStrength, RightStrength, 1, 1, oPivotPrice11, oPivotBar11 ) <> -1 
	AND ( oPivotBar11 - RightStrength ) = 0 ;

condition4 = Pivot( DToscK, Length, LeftStrength, RightStrength, 2, -1, oPivotPrice2, oPivotBar2 ) <> -1;

condition42 = Pivot( DToscK, Length, LeftStrength, RightStrength, 2, 1, oPivotPrice12, oPivotBar12 ) <> -1;

If 
	Condition3 and condition4 
	AND L[oPivotBar2] >= L[oPivotBar1] 
	AND DToscK[oPivotBar2] < DToscK[oPivotBar1] then 
Begin
	Value2 = TL_New_SELF(D[oPivotBar2], T[oPivotBar2], DToscK[oPivotBar2], D[oPivotBar1], T[oPivotBar1], DToscK[oPivotBar1]); 
	TL_SetColor( Value2, Line.Color.Bot );
	TL_SetSize(  Value2, Line.Size  );
End;

If 
	Condition32 and Condition42
	AND H[oPivotBar12] <= H[oPivotBar11] 
	AND DToscK[oPivotBar12] > DToscK[oPivotBar11] then 
Begin
	Value12 = TL_New_SELF(D[oPivotBar12], T[oPivotBar12], DToscK[oPivotBar12], D[oPivotBar11], T[oPivotBar11], DToscK[oPivotBar11]); 
	TL_SetColor( Value12, Line.Color.Top );
	TL_SetSize(  Value12, Line.Size  );
End;

Plot1( DToscK, "stochrsi",      white );
plot2( 20,    "oversold", white);
plot3(80, "overbought", white);

StochRSI Divergence.pla

Share this post


Link to post
Share on other sites

AAA thank you for sharing valuable information i just only have a quick questions in regards of code divergences . how can i use it on radar screen tradesation Platform.... like cell background color as soon trend line is set ? currently i have something but alert comes too late like 3 candles after..regards

Share this post


Link to post
Share on other sites

currently i have something but alert comes too late like 3 candles after..regards

 

Hi JaimSierra

 

Bad news ;

Pivot function needs x Bars back 2 detect a signal

2 bad :(

 

Good news

It's possible, with array or a different logical approch, 2 detect a pivot in RealTime showing a divergence, or a ZigZag, or whatever indicator.

2 good :)

 

regards

 

PS others divergences indicators here based on the same MARKPLEX code

http://www.traderslaboratory.com/forums/10979-aaa/

 

Markplex very nice site here

http://markplex.com/free-tutorials/

 

 
//----------------------------------------------------
inputs:
//----------------------------------------------------
StochLength(  14 ), 
Length(  20 ),
[color=blue][u][b]LeftStrength( [size=7]3[/size]  ), [/b][/u][/color]
RightStrength( 1  ),



[center][size=3][b]Pivot (Function)[/b][/size][/center]


The Pivot function returns the value of a pivot point and the number of bars ago the pivot occurred.

Syntax
Pivot(Price, Length, LeftStrength, RightStrength, Instance, HiLo, oPivotPrice, oPivotBar)

Returns (Integer)
The oPivotPrice and oPivotBar output parameters return the price value of the pivot point and the number of bars ago it occurred.  The Pivot function itself returns a value of 1 if a pivot is found, and -1 if not found.

Parameters

Price
Specifies which bar value (price, function, or formula) to be considered.

Length
Sets the number of bars to consider for the pivot.

[b][color=blue][u]LeftStrength[/u][/color][/b]
[b][color=blue][u]Sets the required number of bars on the left side of the pivot bar.[/u][/color][/b]

RightStrength
Sets the required number of bars on the right side of the pivot bar.

Instance
Sets which occurrence (that is, 1 = most recent, 2 = 2nd most recent, and so on) to return.

HiLo
Sets which pivot values to return, 1 = High, -1 = Low.

oPivotPrice
Outputs the specified bar value at the pivot point.

oPivotBar
Outputs the number of bars ago the pivot point occurred.

Remarks
This function is used to find pivot or swing points.  This function allows you to specify variable strength sides, as well as whether the pivot point should be a high or low pivot.

Example
Assigns to Value2 the most recent pivot low price over the last 21 bars and to Value3 the number of bars ago the pivot low occurred using a left strength of 4 and a right strength of 2.
Vars: oPivotPrice(0), oPivotBar(0);
Value1 = Pivot(Low,21,4,2,1,-1,oPivotPrice,oPivotBar);
Value2 = oPivotPrice;
Value3 = oPivotbar;

Edited by aaa

Share this post


Link to post
Share on other sites

Gm all I' ve found out that if you combine multiple frames you can use the indicator in lower time frames with signals from higher time frames. Result. Signal shows up sooner. Combine 2 time frames in a chart and set indicator on the higher time frame ; 5m & 15m Set indicator on 15m on a 5 m chart. You "ll see sooner and precise alerts in 5m regarding 15m divergences. Hope help. Regards

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.