Error

 Previous Topic Next Topic
 Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.
 wabbit #2 Posted : Monday, August 28, 2017 2:58:03 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) You need EVERY condition specified in your BarsSince() functions to have occurred at least once for "B" to have a value.
 gorachand #3 Posted : Monday, August 28, 2017 4:13:21 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 2/19/2012(UTC)Posts: 78Thanks: 1 times Hello Wabbit, Thank you for your reply. What is the solution then for "generalised" cases? Regards, Dr.Chatterjee
 wabbit #4 Posted : Tuesday, August 29, 2017 12:57:27 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) BarsSince(event)=0 is a long winded way of saying event Your comparative calculation in "A" can be better made using the Alert() function.
 gorachand #5 Posted : Friday, September 1, 2017 8:01:09 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 2/19/2012(UTC)Posts: 78Thanks: 1 times Hello Wabbit,                According to your advice---the only condition which has to occur once and has least probability of occuring is Z:=BarsSince(Cross( Fml( "TD REI"),-40)=0); Accordingly using the Alert function I tried Z:=Alert(BarsSince(Cross(-40,Fml( "TD REI"))),5); A:=BarsSince(Cross(Fml( "TD REI") ,-40)-Z);B:=Ref(C,-1)>Ref(C,-2) AND (O<=Ref(H,-1)) AND (H>(Ref( Fml( "True High"),-1)) AND A<=6)AND Z; {Plot} B; But it still does not plot---any suggestions? Regards, Dr.Chatterjee
 wabbit #6 Posted : Saturday, September 2, 2017 5:52:21 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) I'm assuming you've coded the "true high" and "TD REI" correctly, then I'd be thinking something along these lines (excluding BarsSince() ) Code:`````` {1. A mild oversold condition.(<=6)} Cross(Fml("TD REI"),-40) AND Alert(Cross(-40,Fml("TD REI")),6) AND {2. A closing price that is greater than the previous trading day's closing price.} Ref(C,-1)Ref(Fml("True High"),-1) ``````
 gorachand #7 Posted : Wednesday, September 6, 2017 5:58:24 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 2/19/2012(UTC)Posts: 78Thanks: 1 times Hello Wabbit,                      Thank you for your reply. I tried your code out but found that it never plots a 1 on any security. Also run as an exploration it never returns a single security. The REI code I used has been corroborated with the REI indicator found in the commercial Tradestation De Mark indicators package. The True High indicator has been coded as Max(H,Ref(C,-1)) You have coded  Alert(Cross(-40,Fml("TD REI")),6)   ---but the difference in bars between Cross(Fml("TD REI"),-40) and   Alert(Cross(-40,Fml("TD REI")),6) --- you have not fixed at 6.. The Alert function prolongs the signal for 6 more bars  but at any point during the prolongation  the difference in bars may be anything. I find that a bit strange. Could you clarify my doubts? Regards, Dr.Chatterjee
 wabbit #8 Posted : Thursday, September 7, 2017 1:31:58 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) Post ALL of your TD REI code Edited by user Thursday, September 7, 2017 1:35:25 AM(UTC)  | Reason: Not specified
 gorachand #9 Posted : Friday, September 8, 2017 5:01:42 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 2/19/2012(UTC)Posts: 78Thanks: 1 times Hello Wabbit,                 Thank you for your reply. Here is the TD Rei code. As I wrote before this has been tested against TD Rei indicator found in the DeMark suite of indicators marketed by Tradestation. The readings are authentic. TD1:= H-Ref(H,-2); TD2:= L-Ref(L,-2); TD3:= If((H>=Ref(L,-5) OR H>=Ref(L,-6)) AND (L<=Ref(H,-5) OR L<=Ref(H,-6)),1,0); TD4:= If((Ref(H,-2)>=Ref(C,-7) OR Ref(H,-2)>=Ref(C,-8)) AND (Ref(L,-2)<=Ref(C,-7) OR Ref(L,-2)<=Ref(C,-8)),1,0); TD6:= (TD1) + (TD2); TD5:= If((TD3) + (TD4)>=1, (TD6), 0); TD7:= Abs(TD1) + Abs(TD2); TDREI:=((TD5) + Ref(TD5,-1) + Ref(TD5,-2) + Ref(TD5,-3) + Ref(TD5,-4))/ (TD7 + Ref(TD7,-1) + Ref(TD7,-2) + Ref(TD7,-3) + Ref(TD7,-4))*100; TDREI; 45;-45; Regards, Dr.Chatterjee
 wabbit #10 Posted : Friday, September 8, 2017 5:09:23 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 reason your code fails (and later, my code) is because when you call the value of another MS function using Fml(); MS looks at the LAST returned value in that function.  In every case, calling Fml("TD REI") will ALWAYS return a value of -45 because that is the last value in your function, and -45 will NEVER cross -40! So, either reorder the values in your TD REI function, or, Use FmlVar() instead of Fml()
 gorachand #11 Posted : Saturday, September 9, 2017 4:06:29 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 2/19/2012(UTC)Posts: 78Thanks: 1 times Hello Wabbit,                 Thank you for your reply.According to your instructions I used Fmlvar for both your code and mine---The indicator plots but gives division by zero---maths error {1. A mild oversold condition.(<=6)} Cross( FmlVar("TD REI","TDREI"), -40) AND Alert(Cross(-40, FmlVar("TD REI","TDREI") ),6) AND {2. A closing price that is greater than the previous trading day's closing price.} Ref(C,-1)Ref(Fml("True High"),-1) AND A:=BarsSince(Cross( FmlVar("TD REI","TDREI")  ,-40)-BarsSince(Cross(-40,  FmlVar("TD REI","TDREI")))); Z:=BarsSince(Cross(  FmlVar("TD REI","TDREI"),-40)=0); B:=Ref(C,-1)>Ref(C,-2) AND (O<=Ref(H,-1)) AND (H>(Ref( Fml( "True High"),-1)) AND A<=6)AND Z; {Plot} B; Can you help? Regards, Dr.Chatterjee Edited by user Saturday, September 9, 2017 4:07:26 PM(UTC)  | Reason: Not specified
 wabbit #12 Posted : Sunday, September 10, 2017 3:49:27 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) Thinking logically -- your code produces a DBZ error and my code produces the same DBZ error; but neither code has any division in it, so where is the error?? Of course, the error is in your TD REI code!  Calling this function is common to both your function and mine, and it has a division operation.  Fix this.And, if you continue to use BarsSince() unnecessarily, you're going to run into more troubles than is worth it.
 Users browsing this topic
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.