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 Sam7768 with 5 posts (2 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,351 views
    2. thumb_up 103 thanks given
    3. group 42 followers
    1. forum 86 posts
    2. attach_file 9 attachments




 
Search this Thread

EasyLanguage SuperTrend indicator

  #31 (permalink)
 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

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - May 2024
Feedback and Announcements
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
Quant vue
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
72 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
27 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
16 thanks
  #32 (permalink)
 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.

Reply With Quote
  #33 (permalink)
 
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  
Reply With Quote
  #34 (permalink)
 
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,460 since Jun 2009
Thanks Given: 33,234
Thanks Received: 101,655


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

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 Reply With Quote
  #35 (permalink)
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;

Reply With Quote
Thanked by:
  #36 (permalink)
 
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 !!

Reply With Quote
  #37 (permalink)
 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
Reply With Quote
  #38 (permalink)
 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!!!!

Reply With Quote
  #39 (permalink)
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.

Reply With Quote
  #40 (permalink)
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  
Reply With Quote
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