NexusFi: Find Your Edge


Home Menu

 





How to program a slope line breakout in EasyLanguage?


Discussion in EasyLanguage Programming

Updated
    1. trending_up 3,891 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 1 posts
    2. attach_file 1 attachments




 
Search this Thread

How to program a slope line breakout in EasyLanguage?

(login for full post details)
  #1 (permalink)
MasterYan
San Francisco, CA
 
Posts: 30 since Jul 2016
Thanks Given: 13
Thanks Received: 4

?

How to program a slope line breakout in EasyLanguage?

Is there a way to draw slope lines automatically similar how people do it manually?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Request for MACD with option to use different MAs for fa …
NinjaTrader
Trader Dale [email protected] or Scammer Dale
Trading Reviews and Vendors
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Tao te Trade: way of the WLD
30 thanks
GFIs1 1 DAX trade per day journal
28 thanks
Supertradersams Thread Journal on NQ/MNQ
25 thanks
Deaddogs Stock Trading
22 thanks
Leaving CFD trading and learning futures
11 thanks

(login for full post details)
  #2 (permalink)
 
ShadowFox's Avatar
 ShadowFox 
CO/USA
 
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
Posts: 128 since Jun 2020
Thanks Given: 70
Thanks Received: 157

Alright I will give this one away. I don't use this anymore. Lookback length is the period you want to look back for the trendline, leftstrength, rightstrength define the bars left and bars right that you want to define a Higher or lower high or higher/lower low. DownLineCurrentPrice and UpLineCurrentPrice are the current bars trendline values if you want to check for price crossing. Excuse the hack job as I have not cleaned this code up or looked at it in a few years.

If you want to run this on daily bars or not have the trendline reset after the day close, remove the reset code if date <> date[1] code. Remove the whole if statement until the next end;

 
Code
inputs:  
	LeftStrength( 10 ) ,  
	RightStrength( 10 ), 
	LookBackLength( 100 );
 
variable:  
	ID(-1), 
	Offset( 0 ) , 
	HighValue1(0),
	HighValue2(0),
	LowValue1(0),
	LowValue2(0),
	
	DownStartPrice(0),
	DownStartBar(0),
	DownSecondPrice(0),
	DownTrendConfirmBar(0),
	DownTrendConfirm(0),
	DownSecondStartBar(0),
	DownLineCurrentPrice(0),
	
	UpStartPrice(0),
	UpStartBar(0),
	UpSecondPrice(0),
	UpTrendConfirmBar(0),
	UpTrendConfirm(0),
	UpSecondStartBar(0),
	UpLineCurrentPrice(0);

if Date <> Date[1] then begin
	HighValue1 = 0;
	HighValue2 = 0;
	LowValue1 = 0;
	LowValue2 = 0;
	
	DownStartPrice = 0;
	DownStartBar = 0;
	DownSecondPrice = 0;
	DownTrendConfirmBar = 0;
	DownTrendConfirm = 0;
	DownSecondStartBar = 0;
	DownLineCurrentPrice = 0;
	
	UpStartPrice = 0;
	UpStartBar = 0;
	UpSecondPrice = 0;
	UpTrendConfirmBar = 0;
	UpTrendConfirm = 0;
	UpSecondStartBar = 0;
	UpLineCurrentPrice = 0;
	end;

 
Offset = .15 * Average( Range, 5 ) ; 
 
if PivotHighVSBar( 1, High, LeftStrength, RightStrength, RightStrength + 1 ) <> -1 then 
begin 
	HighValue1 = PivotHighVS(1, High, Leftstrength, RightStrength, LookBackLength );  
	HighValue2 = PivotHighVS(2, High, Leftstrength, RightStrength, LookBackLength );  
 
	if HighValue2 <> -1 and ( ( HighValue1 >= HighValue2 - Offset ) and ( HighValue1 <= HighValue2 + Offset ) ) then  
	begin 
		//ID = Text_New(Date[RightStrength], Time[RightStrength], High[RightStrength] + Offset, "DT");  
		//Text_SetStyle(ID, 2, 1 ) ; 
		//Text_SetColor(ID, yellow);
		if DownTrendConfirm = 0 then begin
			DownSecondPrice = High[RightStrength];
			DownTrendConfirmBar = DownStartBar;
			DownSecondStartBar = RightStrength - 1;
			end
		else if DownTrendConfirm = 1 and High[RightStrength] > DownLineCurrentPrice then begin
			DownSecondPrice = High[RightStrength];
			DownTrendConfirmBar = DownStartBar;
			DownSecondStartBar = RightStrength - 1;
		end;		
		Value1 = 1;
	end ;  

	if HighValue2 <> -1 and HighValue1 > HighValue2 and value1 = 0 then  
	begin 
		//ID = Text_New(Date[RightStrength], Time[RightStrength], High[RightStrength] + Offset, "HH");  
		//Text_SetStyle(ID, 2, 1 ) ; 
		//Text_SetColor(ID, darkgreen);
		DownStartPrice = High[RightStrength];
		DownStartBar = RightStrength - 1;
	end 
	else 
	if HighValue2 <> -1 and HighValue1 < HighValue2 and value1 = 0 then
	begin
		//ID = Text_New(Date[RightStrength], Time[Rightstrength], High[RightStrength] + Offset, "(LH)");
		//Text_SetStyle(ID, 2, 1 ) ;
		//Text_SetColor(ID, Red);
		if DownTrendConfirm = 0 then begin
			DownSecondPrice = High[RightStrength];
			DownTrendConfirmBar = DownStartBar;
			DownSecondStartBar = RightStrength - 1;
			end
		else if DownTrendConfirm = 1 and High[RightStrength] > DownLineCurrentPrice then begin
			DownSecondPrice = High[RightStrength];
			DownTrendConfirmBar = DownStartBar;
			DownSecondStartBar = RightStrength - 1;
		end;		
		Value1 = 1;
	end ;
	Value1 = 0;
end ; 
 
if PivotLowVSBar( 1, Low, LeftStrength, RightStrength, RightStrength + 1 ) <> -1 then 
begin 
	LowValue1 = PivotLowVS(1, Low, Leftstrength, RightStrength, LookBackLength );  
	LowValue2 = PivotLowVS(2, Low, Leftstrength, RightStrength, LookBackLength );  
 
	if LowValue2 <> -1 and ( ( LowValue1 >= LowValue2 - Offset ) and ( LowValue1 <= LowValue2 + Offset ) ) then  
	begin 
		//ID = Text_New(Date[RightStrength], Time[RightStrength], Low[RightStrength] - Offset, "DB");  
		//Text_SetStyle(ID, 2, 0 ) ; 
		//Text_SetColor(ID, yellow);
		if UpTrendConfirm = 0 then begin
			UpSecondPrice = Low[RightStrength];
			UpTrendConfirmBar = UpStartBar;
			UpSecondStartBar = RightStrength - 1;
			End
		else if UpTrendConfirm = 1 and Low[RightStrength] < UpLineCurrentPrice then Begin
			UpSecondPrice = Low[RightStrength];
			UpTrendConfirmBar = UpStartBar;
			UpSecondStartBar = RightStrength - 1;
		End;
		Value1 = 1;
	end;  

	if LowValue2 <> -1 and LowValue1 < LowValue2 and Value1 = 0 then  
	begin  
		//ID = Text_New(Date[RightStrength], Time[RightStrength], Low[RightStrength] - Offset, "LL");  
		//Text_SetStyle(ID, 2, 0 ) ; 
		//Text_SetColor(ID, Red);
		UpStartPrice = Low[RightStrength];
		UpStartBar = RightStrength - 1;
	end 
	else 
	
	if LowValue2 <> -1 and LowValue1 > LowValue2 and Value1 = 0 then
	begin
		//ID = Text_New(Date[RightStrength], Time[RightStrength], Low[RightStrength] - Offset, "(HL)");
		//Text_SetStyle(ID, 2, 0 ) ;
		//Text_SetColor(ID, darkgreen);
		if UpTrendConfirm = 0 then begin
			UpSecondPrice = Low[RightStrength];
			UpTrendConfirmBar = UpStartBar;
			UpSecondStartBar = RightStrength - 1;
			End
		else if UpTrendConfirm = 1 and Low[RightStrength] < UpLineCurrentPrice then Begin
			UpSecondPrice = Low[RightStrength];
			UpTrendConfirmBar = UpStartBar;
			UpSecondStartBar = RightStrength - 1;
		End;
	end;
	Value1 = 0;
end ; 

//Down Trend
If DownStartBar >= RightStrength - 1
Then DownStartBar = DownStartBar + 1;

If DownTrendConfirmBar >= RightStrength - 1
Then DownTrendConfirmBar = DownTrendConfirmBar + 1;

If DownSecondStartBar >= RightStrength - 1
Then DownSecondStartBar = DownSecondStartBar + 1;

If DownStartBar = DownTrendConfirmBar Then
DownTrendConfirm = 1
Else DownTrendConfirm = 0;

If DownTrendConfirm = 1 Then
DownLineCurrentPrice = DownSecondPrice - (DownStartPrice - DownSecondPrice) 
			/ (IFF(DownStartBar - DownSecondStartBar <> 0,DownStartBar - DownSecondStartBar, 1)) 
			* DownSecondStartBar
Else begin 
	DownLineCurrentPrice = 0;
	SetPlotColor[1]( 1, Transparent );
	end;

//UpTrend
If UpStartBar >= RightStrength - 1
Then UpStartBar = UpStartBar + 1;

If UpTrendConfirmBar >= RightStrength - 1
Then UpTrendConfirmBar = UpTrendConfirmBar + 1;

If UpSecondStartBar >= RightStrength - 1
Then UpSecondStartBar = UpSecondStartBar + 1;

If UpStartBar = UpTrendConfirmBar Then
UpTrendConfirm = 1
Else UpTrendConfirm = 0;

If UpTrendConfirm = 1 Then
UpLineCurrentPrice = UpSecondPrice - (UpStartPrice - UpSecondPrice) 
			/ (IFF(UpStartBar - UpSecondStartBar <> 0,UpStartBar - UpSecondStartBar, 1)) 
			* UpSecondStartBar
Else begin 
	UpLineCurrentPrice = 0;
	SetPlotColor[1]( 2, Transparent );
	end;


If DownTrendConfirm = 1 Then
Plot1(DownLineCurrentPrice, !("Down Trend Price") );

If UpTrendConfirm = 1 Then
Plot2(UpLineCurrentPrice, !("Up Trend Price") );

Visit my NexusFi Trade Journal Reply With Quote
The following 6 users say Thank You to ShadowFox for this post:





Last Updated on September 30, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts