NexusFi: Find Your Edge


Home Menu

 





EasyLanguage SuperTrend indicator


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Big Mike with 11 posts (59 thanks)
    2. looks_two ABCTG with 9 posts (6 thanks)
    3. looks_3 chtangwin with 6 posts (26 thanks)
    4. looks_4 Eiji with 5 posts (1 thanks)
      Best Posters
    1. looks_one Big Mike with 5.4 thanks per post
    2. looks_two chtangwin with 4.3 thanks per post
    3. looks_3 cedar with 1.3 thanks per post
    4. looks_4 ABCTG with 0.7 thanks per post
    1. trending_up 98,444 views
    2. thumb_up 103 thanks given
    3. group 42 followers
    1. forum 86 posts
    2. attach_file 9 attachments




 
 

EasyLanguage SuperTrend indicator

 
 Lamboo 
Stockholm
 
Experience: Intermediate
Platform: Nanotrader/ tradestaion
Broker: WHS / TS
Trading: EC / SI / ES / BP
Posts: 19 since Mar 2011
Thanks Given: 8
Thanks Received: 5

Hello, is this the EL for the indicator or the strategy?
I see 2 diffrent, do they belong together or are they 2 separate indicators or strategy's?

Lamboo


Can you help answer these questions
from other members on NexusFi?
Cheap historycal L1 data for stocks
Stocks and ETFs
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
About a successful futures trader who didnt know anythin …
Psychology and Money Management
 
 
 chtangwin 
NJ
 
Experience: Beginner
Platform: NinjaTrader
Posts: 7 since May 2010
Thanks Given: 2
Thanks Received: 26

Hi Lamboo,

1st one is indicator code, 2nd one is for _anaMovingMedian function used by the indicator.
All you need is copy and paste the code in EasyLanguage Editor (File -> New).

Hope this helps.

 
 
Serger's Avatar
 Serger 
Quebec
 
Experience: Intermediate
Platform: Multicharts 64 +VolProfile
Broker: Interactive Brokers
Trading: Ym, Es
Posts: 74 since Oct 2010
Thanks Given: 64
Thanks Received: 25


Changwin,
I import, compile code and indic .. but one problem ..
I have make :subgraph1 ...same as instrument but just one red line at 0.001
Have you one idea why?
Thank you

Attached Thumbnails
Click image for larger version

Name:	anaSuperTrendM1.png
Views:	527
Size:	41.3 KB
ID:	53745  
 
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,463 since Jun 2009
Thanks Given: 33,242
Thanks Received: 101,662


chtangwin View Post
Thanks Mike. nexusfi.com (formerly BMT) is the greatest forum I ever know. Certainly glad I can contribute. I am new to EL and trading. Having programming background, writing code is easy, but learning trading is hard.

Feel free to let me know if there is any programming need, could be a good exercise for me.

Please check here for requests:


Mike



Join the free Markets Chat beta: one platform, all the trade rooms!

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread
 
cedar
New York
 
Posts: 44 since May 2011
Thanks Given: 12
Thanks Received: 30


chtangwin View Post
I converted the anaSuperTrendM1 indicator (also from futures.io (formerly BMT)) to Easy Language.

Please let me know if any issues.

Function: _anaMovingMedian

 
Code
Inputs:
    PriceValue( numericseries ), 
    Period(NumericSimple);
 
variables:
    medianIndex(0),
    priorIndex(0),
    even(false),
    sPeriod(0),
    idx(0),
    val(0),
    initialized(false);
 
array:
    mArray[](0);
 
{ OnStartUp }    
if initialized = false then begin
    initialized = true;
    array_setmaxindex(mArray, Period);
    fill_array(mArray, 0.0);
    if mod(Period, 2) = 0 then begin
        even = true;
        medianIndex = floor(Period/2);
        priorIndex = medianIndex - 1;
    end
    else begin
        even = false;
        medianIndex = floor((Period - 1)/2);
    end;
end;
 
{ OnUpdate }
if currentbar < Period then begin
    sPeriod = currentbar;
    for idx = 1 to sPeriod begin
        mArray[idx] = PriceValue[idx-1];
    end;
    array_sort(mArray, 1, sPeriod, true);
    if mod(sPeriod, 2) = 0 then begin
        idx = floor(sPeriod/2);
        val = 0.5 * (mArray[Period - idx] + mArray[Period - idx + 1]);
    end
    else begin
        idx = floor((1 + sPeriod)/2);
        val = mArray[Period - idx + 1];
    end;
end
else begin
    for idx = 1 to Period begin
        mArray[idx] = PriceValue[idx-1];
    end;
    array_sort(mArray, 1, Period, true);
    if even then
        val = 0.5 * (mArray[medianIndex] + mArray[priorIndex])
    else
        val = mArray[medianIndex];
end;
 
_anaMovingMedian = val;

hello, getting an error that fill_array is not defined in the function. Thanks

{ OnStartUp }
if initialized = false then begin
initialized = true;
array_setmaxindex(mArray, Period);
fill_array(mArray, 0.0);
if mod(Period, 2) = 0 then begin
even = true;

Thanked by:
 
 
Serger's Avatar
 Serger 
Quebec
 
Experience: Intermediate
Platform: Multicharts 64 +VolProfile
Broker: Interactive Brokers
Trading: Ym, Es
Posts: 74 since Oct 2010
Thanks Given: 64
Thanks Received: 25

and Work fine ,,
Thank you so much !!

 
 chtangwin 
NJ
 
Experience: Beginner
Platform: NinjaTrader
Posts: 7 since May 2010
Thanks Given: 2
Thanks Received: 26

TS file attached. Some minor changes to MC code below.

 
Code
inputs:
	PriceValue(NumericSeries), 
	Period(NumericSimple);

variables:
	medianIndex(0),
	priorIndex(0),
	even(true),
	sPeriod(0),
	idx(0),
	val(0),
	initialized(false);
	
array:
	mArray[](0);

{ OnStartUp }	
if initialized = false then begin
	initialized = true;
	array_setmaxindex(mArray, Period);
	fill_array(mArray, 0.0);
	if mod(Period, 2) = 0 then begin
		even = true;
		medianIndex = floor(Period/2);
		priorIndex = medianIndex - 1;
	end
	else begin
		even = false;
		medianIndex = floor((Period - 1)/2);
	end;
end;

{ OnUpdate }
if currentbar <= Period then begin
	sPeriod = currentbar;
	for idx = 1 to sPeriod begin
		mArray[idx] = PriceValue[idx-1];
	end;
	array_sort(mArray, 1, sPeriod, true);
	if mod(sPeriod, 2) <> 0 then begin
		idx = floor(sPeriod/2);
		val = 0.5 * (mArray[Period - idx] + mArray[Period - idx + 1]);
	end
	else begin
		idx = sPeriod/2;
		val = mArray[Period - idx];
	end;
end
else begin
	for idx = 1 to Period begin
		mArray[idx] = PriceValue[idx-1];
	end;
	array_sort(mArray, 1, Period, true);
	if even then
		val = 0.5 * (mArray[medianIndex] + mArray[priorIndex])
	else
		val = mArray[medianIndex];
end;

_anaMovingMedian = val;

Attached Files
Elite Membership required to download: ANASUPERTREND.ELD
 
 Lamboo 
Stockholm
 
Experience: Intermediate
Platform: Nanotrader/ tradestaion
Broker: WHS / TS
Trading: EC / SI / ES / BP
Posts: 19 since Mar 2011
Thanks Given: 8
Thanks Received: 5

Thank you so much!!!!

 
cedar
New York
 
Posts: 44 since May 2011
Thanks Given: 12
Thanks Received: 30


chtangwin View Post
TS file attached.

thank you chtangwin, I appreciate you taking the time to do this.

 
cedar
New York
 
Posts: 44 since May 2011
Thanks Given: 12
Thanks Received: 30


While one will go broke taking every signal, I find the various forms of superTrend are great as a trend 'filter'. Can be easily used in strategies.

So once Trend is identified, take signals(some other method) in the direction of SuperTrend.

A slight modification to the anaSuperTrend code. The following will generate just one line and switch colors.

 
Code
 
{if currentUpTrend = true  then begin
 plot1(stopDot, "UpStopDot");
end;
if currentUpTrend = false then begin
 plot2(stopDot, "DnStopDot");
end;}
 
Plot1(stopDot);
 
If close > stopDot Then 
SetPlotColor(1,Green)else 
  SetPlotColor(1,magenta);

Attached Thumbnails
Click image for larger version

Name:	Nov 4.bmp
Views:	895
Size:	2.06 MB
ID:	54137  
Thanked by:

 



Last Updated on October 31, 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