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.


  • Topics

  • Posts

    • Date: 22nd November 2024.   BTC flirts with $100K, Stocks higher, Eurozone PMI signals recession risk.   Asia & European Sessions:   Geopolitical risks are back in the spotlight on fears of escalation in the Ukraine-Russia after Russia reportedly used a new ICBM to retaliate against Ukraine’s use of US and UK made missiles to attack inside Russia. The markets continue to assess the election results as President-elect Trump fills in his cabinet choices, with the key Treasury Secretary spot still open. The Fed’s rate path continues to be debated with a -25 bp December cut seen as 50-50. Earnings season is coming to an end after mixed reports, though AI remains a major driver. Profit taking and rebalancing into year-end are adding to gyrations too. Wall Street rallied, led by the Dow’s 1.06% broadbased pop. The S&P500 advanced 0.53% and the NASDAQ inched up 0.03%. Asian stocks rose after  Nvidia’s rally. Nikkei added 1% to 38,415.32 after the Tokyo inflation data slowed to 2.3% in October from 2.5% in the prior month, reaching its lowest level since January. The rally was also supported by chip-related stocks tracked Nvidia. Overnight-indexed swaps indicate that it’s certain the Reserve Bank of New Zealand will cut its policy rate by 50 basis points on Nov. 27, with a 22% chance of a 75 basis points reduction. European stocks futures climbed even though German Q3 GDP growth revised down to 0.1% q/q from the 0.2% q/q reported initially. Cryptocurrency market has gained approximately $1 trillion since Trump’s victory in the Nov. 5 election. Recent announcement for the SEC boosted cryptos. Chair Gary Gensler will step down on January 20, the day Trump is set to be inaugurated. Gensler has pushed for more protections for crypto investors. MicroStrategy Inc.’s plans to accelerate purchases of the token, and the debut of options on US Bitcoin ETFs also support this rally. Trump’s transition team has begun discussions on the possibility of creating a new White House position focused on digital asset policy.     Financial Markets Performance: The US Dollar recovered overnight and closed at 107.00. Bitcoin currently at 99,300,  flirting with a run toward the 100,000 level. The EURUSD drifts below 1.05, the GBPUSD dips to June’s bottom at 1.2570, while USDJPY rebounded to 154.94. The AUDNZD spiked to 2-year highs amid speculation the RBNZ will cut the official cash rate by more than 50 bps next week. Oil surged 2.12% to $70.46. Gold spiked to 2,697 after escalation alerts between Russia and Ukraine. Heightened geopolitical tensions drove investors toward safe-haven assets. Gold has surged by 30% this year. Haven demand balanced out the pressure from a strong USD following mixed US labor data. Silver rose 0.9% to 31.38, while palladium increased by 0.9% to 1,040.85 per ounce. Platinum remained unchanged. Always trade with strict risk management. Your capital is the single most important aspect of your trading business.   Please note that times displayed based on local time zone and are from time of writing this report.   Click HERE to access the full HFM Economic calendar.   Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding of how markets work. Click HERE to register for FREE!   Click HERE to READ more Market news. Andria Pichidi HFMarkets Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in FX and CFDs products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • A few trending stocks at support BAM MNKD RBBN at https://stockconsultant.com/?MNKD
    • BMBL Bumble stock watch, pull back to 7.94 support area with high trade quality at https://stockconsultant.com/?BMBL
    • LUMN Lumen Technologies stock watch, pull back to 7.43 support area with bullish indicators at https://stockconsultant.com/?LUMN
×
×
  • Create New...

Important Information

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