PureBytes Links
Trading Reference Links
|
Terry & Bob,>> To Terry who wrote:>> > > Change this:>> if (SBAvg[i]>FBavg[i] AND CalcO[i]<= 0.11 OR CalcO[i]>= -0.11)>> To this:>> if (SBAvg[i]>FBavg[i] AND CalcO[i]<= 0.11 AND CalcO[i]>= -0.11)>> >> With or without that fix, I get different answers for each day I click on.>> > > What I want my code to do is "....CalcO[i]<= 0.11 OR CalcO[i]>= -0.11)" , not the AND function . I do not need both of the requirements to be met, just either one or the other. You said that you get different values for each day you click on. I don't. If I click anywhere within the window, the value in the title stays the same (the value of the last trading day), and if I scroll through the window different values will appear in the title (but only showing value of the last trading day shown in the window) If I click in the middle of the window --the value of that day will not show. I am at a loss. I believe my problem may lie with this code line: wi = " DiffO: " + WriteVal(O[i] - FBAvg[i],1.2); And thanx for the _N tip. I really appreciate it. To Bob who wrote: if (SBAvg[i]>FBavg[i] AND ( CalcO[i]<= 0.11 OR CalcO[i]>= -0.11 ) ). [The added parens are needed because AND has a higher precedence than OR]. When I added the parens in my code I no longer had any values show up in the title. Just ---- shows up in the title window, which belongs to this part of my code: else { wi = "------"; Sincerely, Donna --- In amibroker@xxxxxxxxxxxxxxx, "Bob Jagow" <bjagow@xxxx> wrote: > > Terry., > Re the logic, he clearly wants > if (SBAvg[i]>FBavg[i] AND ( CalcO[i]<= 0.11 OR CalcO[i]>= -0.11 ) ). > [The added parens are needed because AND has a higher precedence than OR]. > > if (SBAvg[i]>FBavg[i] AND (CalcO[i]<= 0.11 OR CalcO[i]>= -0.11) == > true, > but if (SBAvg[i]>FBavg[i] AND CalcO[i]<= 0.11 AND CalcO[i]>= -0.11) == > false > > Didn't check the looping logic because it should be doable with the original > arrays IMO. > > Regards, > > Bob > > -----Original Message----- > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf > Of Terry > Sent: Thursday, November 17, 2005 12:44 PM > To: amibroker@xxxxxxxxxxxxxxx > Subject: RE: [amibroker] Problem with for,if, else statement > > One step at a time (saves me time!) > Please first fix this statement as ANY values always give TRUE the way it > is. Note red text. > > Change this: > if (SBAvg[i]>FBavg[i] AND CalcO[i]<= 0.11 OR CalcO[i]>= -0.11) > To this: > if (SBAvg[i]>FBavg[i] AND CalcO[i]<= 0.11 AND CalcO[i]>= -0.11) > > With or without that fix, I get different answers for each day I click on. > If that doesn't fix it, write back > > Also, please "wrap" your Title statement in _N(Title = .); to keep the > garbage out of the Interpretation window. > > _N(Title = Name() + " (" + StrLeft(FullName(), 10) + ") -- " + Date() +" > O: "+ WriteVal(O,1.2 )+ " H: " + WriteVal(H,1.2) + " L: " + > WriteVal(L,1.2) + " C: " + C + " Fast = " + WriteVal(FBAvg,1.2)+ > EncodeColor( colorPaleTurquoise )+ wi); > > PS: It's okay, IMHO, to write. I do this frequently as required. > If (cond1) {do stuff} > Else if (cond2) {do other stuff} > Else {do third stuff} > -- > Terry > > -----Original Message----- > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf > Of dmarval > Sent: Thursday, November 17, 2005 13:26 > To: amibroker@xxxxxxxxxxxxxxx > Subject: [amibroker] Problem with for,if, else statement > > Can someone please help me figure out what's wrong with > my "for,if,else...." code. I am new at attempting to code. My > problem is that my formula only calculates the value difference for > the last trading day, and if I click on any other previous trading > days, my title value still states value of the last trading day. > What I would like this code to do, is calculate the different values > for each individual current and previous trading days and to have > the values reflected in my title. > > > FastPeriods =5; > SlowPeriods = 20; > > > FBAvg = Sum( Volume * Close, FastPeriods ) / Sum( Volume, > FastPeriods); > SBAvg = Sum( Volume * Close, SlowPeriods ) / Sum( Volume, > SlowPeriods); > > > Plot(FBAvg,"Fast ",colorAqua,styleLine); > Plot(SBAvg,"Slow ",colorDarkBlue,styleLine+styleThick); > > //Calculations// > CalcO = O - FBAvg; > CalcC = C - FBAvg; > > for( i = 0; i < BarCount; i++ ) > { > if (SBAvg[i]>FBavg[i] AND CalcO[i]<= 0.11 OR CalcO[i]>= -0.11) > { > wi = " DiffO: " + WriteVal(O[i] - FBAvg[i],1.2); > } > else if(SBAvg[i]>FBAvg[i] AND CalcC[i]<= 0.11 OR CalcC[i]>= -0.11) > { > wi = " DiffC: " + WriteVal(CalcC[i],1.2); > } > else > { > wi = "------"; > } > } > > > > Title = Name() + " (" + StrLeft(FullName(), 10) + > ") -- " + Date() +" O: "+ WriteVal(O,1.2 )+ " H: " + > WriteVal(H,1.2) + " L: " + WriteVal(L,1.2) + " C: " + C > + " Fast = " + WriteVal(FBAvg,1.2)+ EncodeColor( > colorPaleTurquoise )+ > wi; > > > > > > > > Please note that this group is for discussion between users only. > > To get support from AmiBroker please send an e-mail directly to > SUPPORT {at} amibroker.com > > For other support material please check also: > http://www.amibroker.com/support.html > > > Yahoo! Groups Links > > > > > > > > Please note that this group is for discussion between users only. > > To get support from AmiBroker please send an e-mail directly to > SUPPORT {at} amibroker.com > > For other support material please check also: > http://www.amibroker.com/support.html > > > > > > _____ > > YAHOO! GROUPS LINKS > > * Visit your group " amibroker > <http://groups.yahoo.com/group/amibroker> " on the web. > > * To unsubscribe from this group, send an email to: > amibroker-unsubscribe@xxxxxxxxxxxxxxx > <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe> > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of > Service <http://docs.yahoo.com/info/terms/> . > > _____ >
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
YAHOO! GROUPS LINKS
|