logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

3 Pages123>
Options
Go to last post Go to first unread
noumann  
#1 Posted : Monday, June 4, 2012 12:11:24 PM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

Hello everyone.I'm strying tu build a strategy based on the Supertrend indicator,but i have only the prorealtime version: a = AverageTrueRange[3](close) b = 1.1 if barindex < 3 then T = 1 L1 = low H1 = high else if T[1] = 1 then if close > L1[1] then L1 = MAX(L1[1],medianprice - a*b) ST = L1 else H1 = medianprice + a*b ST = H1 T = -1 endif else if close <H1[1] then H1 = MIN(H1[1],medianprice + a*b) ST = H1 else L1 = medianprice - a* b ST = L1 T = 1 endif endif endif return st I'm not so expert in metastock language.Could anyone help me to translate in metastock language the formula above? Thanks a lot in advance
Derek Worswick  
#2 Posted : Tuesday, June 5, 2012 1:26:38 AM(UTC)
Derek Worswick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 8/11/2005(UTC)
Posts: 104

Code:
 

Factor:= Input("Factor", 1.00,10.00,3.00); 
Pd:= Input("ATR Periods", 1,200,10);
Up:= MP() + (factor * ATR(Pd)); 
Dn:= MP() - (factor * ATR(Pd));
Td:= If(Cross(C, LLV(Up, 13)), 1, If(Cross(HHV(Dn, 13), C), -1, PREV));

DNX:= If(Dn = HighestSince(1, Cross(Td, 0), Dn), Dn, PREV);
Upx:= If(Up = LowestSince(1, Cross(0, Td), Up), Up, PREV);
ST:= If(Td = 1, DNX, If(Td =- 1, UPX, PREV));
ST

 
Derek Worswick  
#3 Posted : Tuesday, June 5, 2012 1:29:40 AM(UTC)
Derek Worswick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 8/11/2005(UTC)
Posts: 104

This secon version is with thanks to Roy Larson of MSTT
Code:
 

Factor:=Input("Factor",1,10,3); 
Pd:=Input("ATR Periods",1,200,10);
Up:=MP()+(factor*ATR(Pd)); 
Dn:=MP()-(factor*ATR(Pd));
Cu:=Cross(C,LLV(Up,13));
Cd:=Cross(HHV(Dn,13),C);
I:=Cum(IsDefined(Cd+Cu))=1;
Td:=ValueWhen(1,Cu+Cd+I,Cu-Cd);
I:=Cum(IsDefined(Cd+Cu))=2;
Hs:=Dn=HighestSince(1,I+Cross(Td,0),Dn);
Ls:=Up=LowestSince(1,I+Cross(0,Td),Up);
Dnx:=ValueWhen(1,Hs,Dn);
Upx:=ValueWhen(1,Ls,Up);
SuperTrend:=If(Td=1,Dnx,Upx);
SuperTrend;

 
henry1224  
#4 Posted : Tuesday, June 5, 2012 7:57:30 AM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Here is a chart of UTX using the SuperTrend indicator provided by Roy Larsen with the MTF filter on only long trades.

It needs a trend filter to only trade long when the trend is your friend.

UserPostedImage
noumann  
#5 Posted : Tuesday, June 5, 2012 11:09:30 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

Thank you for your reply,but there are some difference between roy version and prorealtime version,both with an atr period 3 and factor 1.1. http://uploading.com/files/ae4c4b97/Roy.doc/ http://uploading.com/fil...orealtime%2BVersion.doc/ Prorealtime seems to be more effective
henry1224  
#6 Posted : Tuesday, June 5, 2012 2:58:28 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Noumann, please upload your charts to imgur.com, then post the link here.

I hate to have to download images from the web.
noumann  
#7 Posted : Tuesday, June 5, 2012 3:43:16 PM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

Here they are: Prorealtime(atrperiod=3;factor=1.1) UserPostedImage RoyVersion(atrperiod=3;factor=1.1) UserPostedImage
noumann  
#8 Posted : Thursday, June 7, 2012 5:18:33 PM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

henry,if it can be useful i have the easylanguage code of a great version of the supertrend indicator. Is it possible to translate it in metastock? Thank you
noumann  
#9 Posted : Thursday, June 7, 2012 5:19:30 PM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

opps..i miss the code: inputs: ATRLength(NumericSimple), ATRMult(NumericSimple), Strength(NumericSimple), STrend(NumericRef); vars: ATR(0), avg(0), dn(0), up(0), trend(1), flag(0), flagh(0), ST(0), hl(0); hl = Highest(High, ATRLength) - Lowest(Low, ATRLength); ATR = XAverage(hl, ATRLength); avg = (XAverage(high, Strength) + XAverage(low, Strength))/2; up = avg + ATR; dn = avg - ATR; if c > up[1] and c > Highest(High, Strength)[1] then trend = 1 else if c < dn[1] and c < Lowest(Low, Strength)[1] then trend = -1; if trend < 0 and trend[1] > 0 then flag=1 else flag=0; if trend > 0 and trend[1] < 0 then flagh = 1 else flagh = 0; if trend > 0 and dn < dn[1] then dn=dn[1]; if trend < 0 and up > up[1] then up=up[1]; if flag = 1 then up = avg + ATR; if flagh = 1 then dn = avg - ATR; if trend = 1 then ST = dn else ST = up; SuperTrend = ST; STrend = trend;
henry1224  
#10 Posted : Saturday, June 9, 2012 8:14:10 AM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
here is the code in mql4 language

Code:

//+------------------------------------------------------------------+
//| SuperTrend.mq4 v1.2 |
//| Copyright © 2008, Jason Robinson (jnrtrading). |
//| http://www.spreadtrade2win.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Jason Robinson."
#property link "http://www.spreadtrade2win.com"
 
#property indicator_chart_window
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_buffers 2
double TrendUp[], TrendDown[];
int changeOfTrend;
extern int Nbr_Periods = 10;
extern double Multiplier = 3.0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
 {
//---- indicators
 SetIndexBuffer(0, TrendUp);
 SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
 SetIndexLabel(0, "Trend Up");
 SetIndexBuffer(1, TrendDown);
 SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
 SetIndexLabel(1, "Trend Down");
//----
 return(0);
 }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
 {
//----
 
//----
 return(0);
 }
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
 {
 int limit, i, flag, flagh, trend[5000];
 double up[5000], dn[5000], medianPrice, atr;
 int counted_bars = IndicatorCounted();
//---- check for possible errors
 if(counted_bars < 0) return(-1);
//---- last counted bar will be recounted
 if(counted_bars > 0) counted_bars--;
 limit=Bars-counted_bars;
 //Print(limit);
 
//----
 for (i = Bars; i >= 0; i--) {
 TrendUp[i] = EMPTY_VALUE;
 TrendDown[i] = EMPTY_VALUE;
 atr = iATR(NULL, 0, Nbr_Periods, i);
 //Print("atr: "+atr);
 medianPrice = (High[i]+Low[i])/2;
 //Print("medianPrice: "+medianPrice);
 up[i]=medianPrice+(Multiplier*atr);
 //Print("up: "+up);
 dn[i]=medianPrice-(Multiplier*atr);
 //Print("dn: "+dn);
 trend[i]=1;
 
 
 if (Close[i]>up[i+1]) {
 trend[i]=1;
 if (trend[i+1] == -1) changeOfTrend = 1;
 //Print("trend: "+trend);
 
 }
 else if (Close[i]<dn[i+1]) {
 trend[i]=-1;
 if (trend[i+1] == 1) changeOfTrend = 1;
 //Print("trend: "+trend);
 }
 else if (trend[i+1]==1) {
 trend[i]=1;
 changeOfTrend = 0; 
 }
 else if (trend[i+1]==-1) {
 trend[i]=-1;
 changeOfTrend = 0;
 }
 
 if (trend[i]<0 && trend[i+1]>0) {
 flag=1;
 //Print("flag: "+flag);
 }
 else {
 flag=0;
 //Print("flagh: "+flag);
 }
 
 if (trend[i]>0 && trend[i+1]<0) {
 flagh=1;
 //Print("flagh: "+flagh);
 }
 else {
 flagh=0;
 //Print("flagh: "+flagh);
 }
 
 if (trend[i]>0 && dn[i]<dn[i+1])
 dn[i]=dn[i+1];
 
 if (trend[i]<0 && up[i]>up[i+1])
 up[i]=up[i+1];
 
 if (flag==1)
 up[i]=medianPrice+(Multiplier*atr);
 
 if (flagh==1)
 dn[i]=medianPrice-(Multiplier*atr);
 
 //-- Draw the indicator
 if (trend[i]==1) {
 TrendUp[i]=dn[i];
 if (changeOfTrend == 1) {
 TrendUp[i+1] = TrendDown[i+1];
 changeOfTrend = 0;
 }
 }
 else if (trend[i]==-1) {
 TrendDown[i]=up[i];
 if (changeOfTrend == 1) {
 TrendDown[i+1] = TrendUp[i+1];
 changeOfTrend = 0;
 }
 }
 }
 WindowRedraw();
 
//----
 return(0);
 }
noumann  
#11 Posted : Thursday, July 5, 2012 10:24:00 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

henry, i can't translate in ms language your mql4 code.But i've found this version on bullcharts forum: [Description="SuperTrend - Max] [target=price] Mult:=Input("ATR Multiplier",3,1); Nb:=Input("Nb Periods",8,1); method:=inputma("Method",Wilders); price:=Input("1=Median, 2=Close",1,1); TruRan:=ma(ATR(1),Nb,method)*Mult; HiLimit:=if(price=1,(H+L)/2-TruRan,C-TruRan); LoLimit:=if(price=1,(H+L)/2+TruRan,C+TruRan); LB:=If(HiLimit>=PREV and HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV)); UB:=If(LoLimit<prev and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev)); [drawundefined=gap] [Color=lime green] if(Trend=1 and hist(Trend,1)=-1,LB,if(Trend=-1,UB,undefined)); [Color=red] if(Trend=-1 ,UB,if(hist(Trend,1)=1 ,LB,undefined)); [Color=lime green] if(Trend=1 or Trend=0,LB,undefined); { Paint bars} Flag:=input("PaintBars On=1, Off=0",0,0,1); [linestyle=pricecolor; color=rgb(98,217,98)] If(Trend=1 and Flag=1,1,if(Flag=0 and C>O,1,undefined)); [color=rgb(226,118,118)] {red} If(Trend=-1 and Flag=1,1,if(Flag=0 and C<=O,1,undefined)); I'm trying to translate it in ms language as follows: Mult:=Input("ATR Multiplier",0.1,10,3); Nb:=Input("Nb Periods",1,30,8); TruRan:=Mov(ATR(1),Nb,w)*Mult; HiLimit:= (H+L)/2-TruRan; LoLimit:= (H+L)/2-TruRan; LB:=If(HiLimit>=PREV and HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV)); UB:=If(LoLimit<prev and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev)); if(Trend=1 and Ref(Trend,1)=-1,LB,if(Trend=-1,UB,undefined)); if(Trend=-1 ,UB,if(Ref(Trend,1)=1 ,LB,undefined)); if(Trend=1 or Trend=0,LB,undefined); But "undefined" is not a ms function. Any suggestions? Thank you
noumann  
#12 Posted : Thursday, July 5, 2012 10:28:24 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

henry, i can't translate in ms language your mql4 code.But i've found this version on bullcharts forum: [Description="SuperTrend - Max] [target=price] Mult:=Input("ATR Multiplier",3,1); Nb:=Input("Nb Periods",8,1); method:=inputma("Method",Wilders); price:=Input("1=Median, 2=Close",1,1); TruRan:=ma(ATR(1),Nb,method)*Mult; HiLimit:=if(price=1,(H+L)/2-TruRan,C-TruRan); LoLimit:=if(price=1,(H+L)/2+TruRan,C+TruRan); LB:=If(HiLimit>=PREV and HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV)); UB:=If(LoLimit<prev and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev)); [drawundefined=gap] [Color=lime green] if(Trend=1 and hist(Trend,1)=-1,LB,if(Trend=-1,UB,undefined)); [Color=red] if(Trend=-1 ,UB,if(hist(Trend,1)=1 ,LB,undefined)); [Color=lime green] if(Trend=1 or Trend=0,LB,undefined); { Paint bars} Flag:=input("PaintBars On=1, Off=0",0,0,1); [linestyle=pricecolor; color=rgb(98,217,98)] If(Trend=1 and Flag=1,1,if(Flag=0 and C>O,1,undefined)); [color=rgb(226,118,118)] {red} If(Trend=-1 and Flag=1,1,if(Flag=0 and C<=O,1,undefined)); I'm trying to translate it in ms language as follows: Mult:=Input("ATR Multiplier",0.1,10,3); Nb:=Input("Nb Periods",1,30,8); TruRan:=mOV(ATR(1),Nb,w)*Mult; HiLimit:= (H+L)/2-TruRan; LoLimit:= (H+L)/2-TruRan; LB:=If(HiLimit>=PREV and HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV)); UB:=If(LoLimit<prev and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev)); if(Trend=1 and Ref(Trend,1)=-1,LB,if(Trend=-1,UB,undefined)); if(Trend=-1 ,UB,if(Ref(Trend,1)=1 ,LB,undefined)); if(Trend=1 or Trend=0,LB,undefined); but ms doesn't recognize "undefined". Any suggestions? Thank you
noumann  
#13 Posted : Thursday, July 5, 2012 10:55:00 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

Something went wrong in my last post.Here the complete bullcharts code: [Description="SuperTrend - Max] [target=price] Mult:=Input("ATR Multiplier",3,1); Nb:=Input("Nb Periods",8,1); method:=inputma("Method",Wilders); price:=Input("1=Median, 2=Close",1,1); TruRan:=ma(ATR(1),Nb,method)*Mult; HiLimit:=if(price=1,(H+L)/2-TruRan,C-TruRan); LoLimit:=if(price=1,(H+L)/2+TruRan,C+TruRan); LB:=If(HiLimit>=PREV and HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV)); UB:=If(LoLimit<prev and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev)); [drawundefined=gap] [Color=lime green] if(Trend=1 and hist(Trend,1)=-1,LB,if(Trend=-1,UB,undefined)); [Color=red] if(Trend=-1 ,UB,if(hist(Trend,1)=1 ,LB,undefined)); [Color=lime green] if(Trend=1 or Trend=0,LB,undefined); { Paint bars} Flag:=input("PaintBars On=1, Off=0",0,0,1); [linestyle=pricecolor; color=rgb(98,217,98)] If(Trend=1 and Flag=1,1,if(Flag=0 and C>O,1,undefined)); [color=rgb(226,118,118)] {red} If(Trend=-1 and Flag=1,1,if(Flag=0 and C<=O,1,undefined));
noumann  
#14 Posted : Thursday, July 5, 2012 11:01:35 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

wabbit  
#15 Posted : Thursday, July 5, 2012 6:12:39 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
So that others don't have to go through the pain of the download process:

Code:

{==== BullScript ====}

[Description="SuperTrend - Max]
[target=price]
Mult:=Input("ATR Multiplier",3,1);
Nb:=Input("Nb Periods",8,1);
method:=inputma("Method",Wilders);
price:=Input("1=Median, 2=Close",1,1);
TruRan:=ma(ATR(1),Nb,method)*Mult;
HiLimit:=if(price=1,(H+L)/2-TruRan,C-TruRan);
LoLimit:=if(price=1,(H+L)/2+TruRan,C+TruRan);
LB:=If(HiLimit>=PREV and HiLimit<C,HiLimit,If(C<PREV,HiLimit-0.1,PREV));
UB:=If(LoLimit<PREV and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV));
Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev));
[drawundefined=gap]
[Color=lime green]
if(Trend=1 and hist(Trend,1)=-1,LB,if(Trend=-1,UB,undefined));
[Color=red]
if(Trend=-1 ,UB,if(hist(Trend,1)=1 ,LB,undefined));
[Color=lime green]
if(Trend=1 or Trend=0,LB,undefined);
{ Paint bars}
Flag:=input("PaintBars On=1, Off=0",0,0,1);
[linestyle=pricecolor; color=rgb(98,217,98)]
If(Trend=1 and Flag=1,1,if(Flag=0 and C>O,1,undefined));
[color=rgb(226,118,118)] {red}
If(Trend=-1 and Flag=1,1,if(Flag=0 and C<=O,1,undefined));



BullScript is very similar to MS script, but it's more powerful and has some really nice features not available in MS, however, the essence of the code should be immediately evident to anyone who has taken the time to learn the basics of MS coding by reading and understanding the MS User Manual and doing the basic exercises in the free Equis Formula Primer.


wabbit [:D]

noumann  
#16 Posted : Friday, July 6, 2012 4:53:06 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

wabbit, the first part is quite simple: Mult:= Input("ATR Multiplier",0.1,3,1); Nb:= Input(“NbPeriods”,1,8,8); x:= Input(“Price:[1](H+L)/2 [2]Close”,1,2,1); TruRan:= Wilders(ATR(1),Nb)*Mult; HiLimit:=if(price=1,(H+L)/2-TruRan,C-TruRan); LoLimit:=if(price=1,(H+L)/2+TruRan,C+TruRan); LB:=If(HiLimit>=PREV and HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV)); UB:=If(LoLimit<prev and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev)); but i can't translate the second part. Can you help me? Thanks
wabbit  
#17 Posted : Saturday, July 7, 2012 12:15:44 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
The forum is still borking the codes, but then again you're not using the proper code tags either....


wabbit [:D]

noumann  
#18 Posted : Saturday, July 7, 2012 10:34:32 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

wabbit, maybe this can be a decent translation: Mult:= Input("ATR Multiplier",0.1,3,1); Nb:= Input("NbPeriods",1,8,8); x:= Input("Price:[1](H+L)/2 [2]Close",1,2,1); TruRan:= Wilders(ATR(1),Nb)*Mult; HiLimit:=If(x=1,(H+L)/2-TruRan,C-TruRan); LoLimit:=If(x=1,(H+L)/2+TruRan,C+TruRan); LB:=If(HiLimit>=PREV AND HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV)); UB:=If(LoLimit<prev AND LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=If(UB>Ref(UB,-1),1,If(LB<ref(LB,-1),-1,PREV)); Super:=If((Trend=1 AND Ref(Trend,-1)=-1) OR (Trend=1 OR Trend=0),LB,UB); Super; Whato do you thing about it?
noumann  
#19 Posted : Saturday, July 7, 2012 10:42:18 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

i don't know what happens. i can't write the complete code in the post.I try again: Mult:= Input("ATR Multiplier",0.1,3,1); Nb:= Input("NbPeriods",1,8,8); x:= Input("Price:[1](H+L)/2 [2]Close",1,2,1); TruRan:= Wilders(ATR(1),Nb)*Mult; HiLimit:=If(x=1,(H+L)/2-TruRan,C-TruRan); LoLimit:=If(x=1,(H+L)/2+TruRan,C+TruRan); LB:=If(HiLimit>=PREV AND HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV)); UB:=If(LoLimit<prev AND LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=If(UB>Ref(UB,-1),1,If(LB<ref(LB,-1),-1,PREV)); Super:=If((Trend=1 AND Ref(Trend,-1)=-1) OR (Trend=1 OR Trend=0),LB,UB); Super;
noumann  
#20 Posted : Saturday, July 7, 2012 10:45:18 AM(UTC)
noumann

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 10/16/2009(UTC)
Posts: 34

Code:

Mult:= Input("ATR Multiplier",0.1,3,1); 
Nb:= Input("NbPeriods",1,8,8); 
x:= Input("Price:[1](H+L)/2 [2]Close",1,2,1); 
TruRan:= Wilders(ATR(1),Nb)*Mult; 
HiLimit:=If(x=1,(H+L)/2-TruRan,C-TruRan); 
LoLimit:=If(x=1,(H+L)/2+TruRan,C+TruRan);
LB:=If(HiLimit>=PREV AND HiLimit<c,HiLimit,If(C<prev,HiLimit-0.1,PREV));
UB:=If(LoLimit<prev AND LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV));
Trend:=If(UB>Ref(UB,-1),1,If(LB<ref(LB,-1),-1,PREV));
Super:=If((Trend=1 AND Ref(Trend,-1)=-1) OR (Trend=1 OR Trend=0),LB,UB);
Super; 
Users browsing this topic
Similar Topics
Exploration with Supertrend Indicator (Formula Assistance)
by andbertini 10/9/2017 3:09:36 PM(UTC)
Supertrend Indicator (Formula Assistance)
by hitrader 2/1/2017 10:09:39 PM(UTC)
forex supertrend indicator from prorealtime (Formula Assistance)
by garrei 8/11/2005 10:54:24 PM(UTC)
3 Pages123>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.