[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Problem with for,if, else statement



PureBytes Links

Trading Reference Links

Hello,
 
Construct like
 
if( ... )
{
...
}
else
if( ... )
{
...
 
}
else
{
...
}
 
is perfectly OK.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: amartinod
Sent: Thursday, November 17, 2005 9:35 PM
Subject: RE : [amibroker] Problem with for,if, else statement

I would never write two consecutive else like that......

 

Al,

 

 

 

-----Message d'origine-----
De : amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] De la part de dmarval
Envoyé : jeudi 17 novembre 2005 21:26
À : amibroker@xxxxxxxxxxxxxxx
Objet : [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





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS