NexusFi: Find Your Edge


Home Menu

 





Turning an indicator into a strategy


Discussion in EasyLanguage Programming

Updated
    1. trending_up 2,018 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7

Hi forumer,
i've found this linear regression indicator and would turn it into a strategy

 
Code
inputs:
	Price( Close),
	Length( 20),
	Displace( 0),
	UpColor( green),
	UpDotColor (green),
	DnColor (red),
	DnDotColor (red),
	BarOffset (.02),
	DotInLine("No"),
	PaintInBarLRCLine ("Yes");

variables:
	LinReg( 0 ), Trend (0), Transition (0) ;

if Displace >= 0 or CurrentBar > AbsValue( Displace ) then 
	begin
	LinReg = LinearRegValue( Price, Length, 0 ) ; 
	If LinReg > LinReg [1] then
	  Begin
	  If Trend = -1 then Transition = 1;
	  If PaintInBarLRCLine = "Yes" then Plot1[Displace]( LinReg, "LinReg", UpColor );
	  If DotInline <> "Yes" then Plot3[Displace] (High + BarOffset,"Up",UpColor);
	  Trend = 1;
	  End
	Else
	  Begin
	  If Trend = 1 then Transition = 1;
	  If PaintInBarLRCLine = "Yes" then Plot1 [Displace] ( LinReg, "LinReg",DnColor ) ;
	  If DotInLine <> "Yes" then Plot4 [Displace] (Low - BarOffset,"Dn",DnColor);
	  Trend = -1;
	  End;
	  
If Transition = 1 then
Begin
  If Trend = 1 then 
  Begin 
    If DotInLine = "Yes" then
      Plot5[Displace]( LinReg, "UpDotColor", UpDotColor )
    else
      Plot5(High +  BarOffset, "UpDotColor", UpDotColor);
    Alert; 
  End;
  If Trend = -1 then 
  Begin
    If DotInLine = "Yes" then
      Plot6 [Displace] ( LinReg, "DnDotColor", DnDotColor ) 
    else
      Plot6(Low - BarOffset, "DnDotColor", DnDotColor);
    Alert;
  End;
  Transition = Transition + 1;
End;	  
	
	{ Alert criteria }
	if Displace <= 0 then 
		begin
		if Price > LinReg and LinReg > LinReg[1] and LinReg[1] <= LinReg[2] then
			Alert( "LRC turning up" )
		else if Price < LinReg and LinReg < LinReg[1] and LinReg[1] >= LinReg[2] then
			Alert( "LRC turning down" );	
		end ;
	end ;
anyone can help me?
thanks


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The June 15 Resolution Trap: Irans Agreed Text Still Pri …
Prediction Markets & Event Contracts
MyForexFunds Begins Returning Frozen Funds After CFTC Ca …
Funded Trading Evaluation Firms
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642


w4rri0r,

the first thing you would need to clarify is what exactly should trigger an entry and exits. Posting a couple of screenshots with the indicator and where you would want to see entries and exits might enable others to help you.

Regards,

ABCTG


Follow me on X Reply With Quote
  #4 (permalink)
w4rri0r
world's citizen
 
Posts: 45 since Oct 2015
Thanks Given: 10
Thanks Received: 7


ABCTG View Post
w4rri0r,

the first thing you would need to clarify is what exactly should trigger an entry and exits. Posting a couple of screenshots with the indicator and where you would want to see entries and exits might enable others to help you.

Regards,

ABCTG

Hi ABCTG,
for testing purpose i simply need to buy/sell when the indicator turns up or down
it would be nice to insert a sort of delay bars to trigger the order or something like angle conditions



thanks


Reply With Quote




Last Updated on November 24, 2017


© 2026 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 - Downloads - Top
no new posts