ana SuperTrend....... - futures io
futures io futures trading



ana SuperTrend.......


Discussion in EasyLanguage Programming

Updated by ABCTG
      Top Posters
    1. looks_one Fat Tails with 12 posts (11 thanks)
    2. looks_two cbritton with 9 posts (13 thanks)
    3. looks_3 Serger with 5 posts (0 thanks)
    4. looks_4 tst1 with 5 posts (0 thanks)
      Best Posters
    1. looks_one cbritton with 1.4 thanks per post
    2. looks_two sharky with 1.0 thanks per post
    3. looks_3 Fat Tails with 0.9 thanks per post
    4. looks_4 ABCTG with 0.8 thanks per post
    1. trending_up 25,601 views
    2. thumb_up 32 thanks given
    3. group 17 followers
    1. forum 48 replies
    2. attach_file 14 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

ana SuperTrend.......

(login for full post details)
  #1 (permalink)
Quebec
 
Experience: Intermediate
Platform: Multicharts 64 +VolProfile
Broker: AMP Trading / CQG
Trading: Ym, Es
 
Serger's Avatar
 
Posts: 72 since Oct 2010
Thanks: 64 given, 24 received

are what anyone would be able to turn this fantastic
anaSuperTrend vertion in MC??
it is absolutely genial this indicator ....
thank you for your help in advance!

Reply With Quote

Can you help answer these questions
from other members on futures io?
Chart on TV, what platform is best for swing order entries?
Traders Hideout
Convert H Data TS to NT
NinjaTrader
Order Data Export Plugin-- Is it possible?
NinjaTrader
Display Total Delta in Numeric form
MultiCharts
SPY, QQQ Weekly Closing Range Probabilities
Traders Hideout
 
 
(login for full post details)
  #2 (permalink)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 249 received

I looked at the NT code for this and started to port the MovingMedian indicator to easy language first since anaSuperTrend depends on that. Can someone post a screenshot of the NT version on some daily chart so I can compare it?

Here's the function for moving median:

 
Code
inputs:
    Price(NumericSeries),
    length(NumericSimple);

variables: 
    int period(0),
    int idx(0),
    int meanIdx(0),
    int priorIdx(0),
    float MA(0.0);
    
Array: float mArray[](0);
    
if period < 1 then period = 1 else period = length; //throw some exception

Array_SetMaxIndex(mArray, period);

if currentbar < period then begin
    value1 = currentbar + 1;
    for idx = 0 to value1 - 1 begin  // inclusive?
        mArray[idx] = price[idx];
    end;
    value2 = SortArray(mArray,period,1);  //ascending?? should not matter since we're getting the median
    
    if mod(period, 2) = 0 then MA = 0.5 * (mArray[value1/2] + mArray[value1/2-1])
    else MA = mArray[(value1-1)/2];

end else begin

    for idx = 0 to period - 1 begin
        mArray[idx] = price[idx];
    end;
    value2 = SortArray(mArray,period,1);
    if mod(period, 2) = 0 then 
        MA = 0.5 * (mArray[period/2] + mArray[period/2-1])
    else
        MA = mArray[(period-1)/2];

end;

_MovingMedian = MA;
and the indicator. Nothing fancy like rising/falling colors.

 
Code
input: price(close),
        period(17);

Plot1(_MovingMedian(price, period), "MovMed");
This works in TradeStation.

I will try to make sense of the anaSuperTrend indicator next.

Regards,
-C

“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
Reply With Quote
The following user says Thank You to cbritton for this post:
 
(login for full post details)
  #3 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,846 since Mar 2010
Thanks: 4,238 given, 26,674 received



cbritton View Post
I looked at the NT code for this and started to port the MovingMedian indicator to easy language first since anaSuperTrend depends on that. Can someone post a screenshot of the NT version on some daily chart so I can compare it?

Here is a daily chart of the S&P 500 index with the anaSuperTrend applied. Let me know, if you need any help in understanding the code.

Attached Thumbnails
Click image for larger version

Name:	^SP500 (Daily)  11_11_2010 - 25_05_2011.jpg
Views:	1074
Size:	75.0 KB
ID:	39386  
Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
(login for full post details)
  #4 (permalink)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 249 received


Fat Tails View Post
Here is a daily chart of the S&P 500 index with the anaSuperTrend applied. Let me know, if you need any help in understanding the code.

Thanks! I'll try to have something to post later today or tomorrow.

-C

“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
Reply With Quote
The following user says Thank You to cbritton for this post:
 
(login for full post details)
  #5 (permalink)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 249 received

Here's my first stab at it. I'm sure there are some things I did not do right, so pick it apart and make it better!

I coded this as a show me in TradeStation instead of an indicator. No real reason for that. I included the commentary block if you feel like you need to debug it for whatever reason. Just set debug to true (the default). The NT code logic did not translate well to EL, so I did some minor tweaking to make this work.

Attached is a screen shot of the show me applied to the daily SPY. The yellow "+" indicates the up/down arrows on the NT version.

 
Code
inputs:
    price(close),
    medianPeriod(5),
    atrPeriod(21),
    atrMultiplier(3),
    showStopLine(true),
    showArrows(true);

vars: 
      stopLine(0),
      upTrend(true), 
      currentUpTrend(true),
      color(0),
      newstop(0),
      priorStop(0), 
      priorcolor(0),
      MM(0),
      MAE(0),
      debug(true);

MM = _MovingMedian(price, medianPeriod);
MAE = _AvgTrueRange(atrPeriod);

// Define the rising/falling colors
if 1 = 0 then begin
    Plot1(close, "rising");
    Plot2(close, "falling");
end;

if CurrentBar = 0 then begin
    stopLine = close;
    upTrend = true;
end;

if close > stopLine[1] then begin
    upTrend = true;
    newStop = MM - atrMultiplier * MAE;
    currentUpTrend = true;

    if upTrend[1] = false then stopline = newStop
    else stopline = maxlist(newStop, stopline[1]);
    
end else if close < stopLine[1] then begin

    upTrend = false;
    newStop = MM + atrmultiplier * MAE;
    currentUpTrend = false;
    
    if UpTrend[1] = true then stopLine = newStop 
    else stopLine = minlist(newStop, StopLine[1]); 

end else begin

    upTrend = upTrend[1];
    currentUpTrend = upTrend;
    stopline = stopline[1];

end;


if debug = true then begin
    #beginCmtry
        CommentaryCL("*************************************************");
        CommentaryCL("MM: ", MM);
        CommentaryCL("MAE: ", MAE);
        CommentaryCL("close: " ,c);
        CommentaryCL("upTrend: ", upTrend);
        CommentaryCL("upTrend[1]: ", upTrend[1]);
        CommentaryCL("currentUpTrend: ", currentUpTrend);
        CommentaryCL("stopLine: ", stopLine);
        CommentaryCL("priorStop: ", priorStop);
        CommentaryCL("*************************************************");
    #End;
end;

if showArrows then begin
    value3 = MinMove/PriceScale;
    if currentUpTrend = true and upTrend[1]<> true then begin
    
        value2 = newStop - 2 * value3;
        Plot3(newStop - 2* value3, "Arrow down");
        
    end else if currentUpTrend <> true and upTrend[1]=true  then begin

        value2 = newStop + 2 * value3;
        Plot4(newStop + 2* value3, "Arrow up");
    end;

end;


if showStopLine then begin

    if UpTrend = true and upTrend[1] <> true then begin
        color = GetPlotColor(1); // up color
    end else if UpTrend = true then begin
        color = GetPlotcolor(1); // up Color
    end else if UpTrend <> true and upTrend[1]=true then begin
        color = GetPlotColor(2); // down color
    end else begin
        color = GetPlotColor(2); // down color
    end;
    
    Plot5(stopLine, "Stop Line", color);

end;
Regards,
-C

“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
Attached Thumbnails
Click image for larger version

Name:	2011-05-27_13-27-31.png
Views:	495
Size:	49.0 KB
ID:	39434   Click image for larger version

Name:	2011-05-27_13-27-58.png
Views:	240
Size:	35.7 KB
ID:	39435  
Reply With Quote
The following 2 users say Thank You to cbritton for this post:
 
(login for full post details)
  #6 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,846 since Mar 2010
Thanks: 4,238 given, 26,674 received

The result looks near correct. The Easy Language version seems to track price closer than the origianl version. However, when I checked the code, it looks correct. The only difference I found:

The anaSuperTrend uses the statistical Median of the Median[0], the latter being (High[0]+Low[0])/2. This means that the median is not calculated from the closes. I am not sure about the Easy Language version.

With the same parameters that you used, the NinjaTrader chart looks like this:

Attached Thumbnails
Click image for larger version

Name:	^SP500 (Daily)  18_10_2010 - 26_05_2011.jpg
Views:	413
Size:	83.6 KB
ID:	39447  
Reply With Quote
 
(login for full post details)
  #7 (permalink)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 249 received

There's nothing interesting about ATR, so it's probably a difference in how the moving median is computed as far as these differences are concerned. Here's a screenshot of the indicator I posted earlier with a 10 period moving median on the daily close of SPY. Seems anyone can just pick a decent moving average indicator to base the ATR off of. A "pick your own" type of indicator like what we have around this site would allow people to adjust the super trend to their style.

Just my 0.02
-C

“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
Attached Thumbnails
Click image for larger version

Name:	2011-05-27_16-55-08.png
Views:	231
Size:	40.7 KB
ID:	39458  
Reply With Quote
The following user says Thank You to cbritton for this post:
 
(login for full post details)
  #8 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,846 since Mar 2010
Thanks: 4,238 given, 26,674 received


cbritton View Post
There's nothing interesting about ATR, so it's probably a difference in how the moving median is computed as far as these differences are concerned. Here's a screenshot of the indicator I posted earlier with a 10 period moving median on the daily close of SPY. Seems anyone can just pick a decent moving average indicator to base the ATR off of. A "pick your own" type of indicator like what we have around this site would allow people to adjust the super trend to their style.

Just my 0.02
-C

But did you see that my indicator does not use Median(Close,n) but Median((High+Low)/2,n) ?

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
(login for full post details)
  #9 (permalink)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 249 received


Fat Tails View Post
But did you see that my indicator does not use Median(Close,n) but Median((High+Low)/2,n) ?

Well I feel stupid now.

Here's my updated chart.

“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
Attached Thumbnails
Click image for larger version

Name:	2011-05-27_17-44-38.png
Views:	424
Size:	44.0 KB
ID:	39462  
Reply With Quote
The following user says Thank You to cbritton for this post:
 
(login for full post details)
  #10 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,846 since Mar 2010
Thanks: 4,238 given, 26,674 received



cbritton View Post
Well I feel stupid now.

Here's my updated chart.

Looks good now. If it is not identical, it comes very close at least. I think you made it.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > ana SuperTrend.......


April 10, 2018


Upcoming Webinars and Events
 

Bookmap

Nov TBD
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts