Error

 3 Pages123>
 Previous Topic Next Topic
 noumann #1 Posted : Monday, June 4, 2012 12:11:24 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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
 Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.
 Derek Worswick #2 Posted : Tuesday, June 5, 2012 1:26:38 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Subscribers, Unverified UsersJoined: 8/11/2005(UTC)Posts: 102 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) Rank: Advanced MemberGroups: Registered, Registered Users, Subscribers, Unverified UsersJoined: 8/11/2005(UTC)Posts: 102 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) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 10/29/2004(UTC)Posts: 1,394Location: Glastonbury, CTWas thanked: 1 time(s) in 1 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.
 noumann #5 Posted : Tuesday, June 5, 2012 11:09:30 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 10/29/2004(UTC)Posts: 1,394Location: Glastonbury, CTWas thanked: 1 time(s) in 1 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) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 10/16/2009(UTC)Posts: 34 Here they are: Prorealtime(atrperiod=3;factor=1.1) RoyVersion(atrperiod=3;factor=1.1)
 noumann #8 Posted : Thursday, June 7, 2012 5:18:33 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 10/29/2004(UTC)Posts: 1,394Location: Glastonbury, CTWas thanked: 1 time(s) in 1 post(s) here is the code in mql4 languageCode:`````` //+------------------------------------------------------------------+ //| 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]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]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) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LBO,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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB
 noumann #12 Posted : Thursday, July 5, 2012 10:28:24 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LBO,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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB
 noumann #13 Posted : Thursday, July 5, 2012 10:55:00 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LBO,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) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 10/16/2009(UTC)Posts: 34 i'm very sorry. Here the code: http://uploading.com/fil...a4/Bullcharts%2Bcode.doc
 wabbit #15 Posted : Thursday, July 5, 2012 6:12:39 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Subscribers, Unverified UsersJoined: 10/28/2004(UTC)Posts: 3,106Location: Perth, Western AustraliaWas thanked: 12 time(s) in 12 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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LBO,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) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=if(UB>ref(UB,-1),1,if(LB
 wabbit #17 Posted : Saturday, July 7, 2012 12:15:44 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Subscribers, Unverified UsersJoined: 10/28/2004(UTC)Posts: 3,106Location: Perth, Western AustraliaWas thanked: 12 time(s) in 12 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) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=If(UB>Ref(UB,-1),1,If(LB
 noumann #19 Posted : Saturday, July 7, 2012 10:42:18 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=If(UB>Ref(UB,-1),1,If(LB
 noumann #20 Posted : Saturday, July 7, 2012 10:45:18 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, Unverified UsersJoined: 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 HiLimitC,LoLimit,If(C>PREV,LoLimit+0.1,PREV)); Trend:=If(UB>Ref(UB,-1),1,If(LB
 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.