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

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



PureBytes Links

Trading Reference Links

Donna,

 

I found you entire code (I think) and applied your changes. Then I added two Plots to see the value of your if () and else if () tests. The changes do occur. The problem is they very rarely occur. Plot the attached AFL, zoom out and look for the black and white peaks which represent days your conditions are true. On those days your code works as expected. So, it is working, but 99% of the days are "stay" days.

--

Terry

-----Original Message-----
From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of dmarval
Sent: Thursday, Novem
ber 17, 2005 21:52
To:
amibroker@xxxxxxxxxxxxxxx
Su
bject: [amibroker] Re: Problem with for,if, else statement

 

Sorry, typo error.

WMT --August 24,2005  Open: 46.35 ,   FBAvg: 46.38 gives value DiffO:  -.03

WMT --September 9,2005  Open: 45.65 ,   FBAvg: 45.58 gives value DiffO:  +.07

Donna

--- In amibroker@xxxxxxxxxxxxxxx, "dmarval" <dmarval@xxxx> wrote:

Terry,

You are right!! I'm sorry. I should have paid more attention. It does make it easier to read the code this way. I put the code as stated and got  syntax error, so I put 2 brackets and it works.

for( i = 0; i < BarCount; i++ ) >>

{>>

    if (SBAvg[i]>FBavg[i] AND (CalcO[i]>= -0.11 AND CalcO[i]<= 0.11))  >>

   {>>

      wi = "    DiffO:    " + WriteVal(O[i] - FBAvg[i],1.2);>>

   }>>

   else if(SBAvg[i]>FBAvg[i] AND (CalcC[i]>= -0.11 AND CalcC[i]<= 0.11))>>

   {>>

      wi = "    DiffC:   " + WriteVal(CalcC[i],1.2);>>

   }>>

   else>>

  {>>

      wi = "   stay  ";

>> 

>_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);

>

Yes, I would like and appreciate it if you could help me  see the values on the chart area for a given bar. I have clicked on the bars but the title will not show value of the day I clicked. ie:

WMT --August 24,2005  Open: 46.35 ,   FBAvg: 46.38 gives value DiffO:  +.07

instead the value in the title says stay.

Thank you.

Sincerely,

Donna


--- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxxx> wrote:

Donna,

You said: "I only want to search within these ranges. I don't want to find values that are over 0.11 cents or under the -0.11. Just either or condition within the +0.11 and -0.11 range."

I gave you the answer already. I also said try this first and I'd help more, but if you aren't going to listen then I'm not going to help. I make mistakes too so my answers are not always perfect, but in this case I double checked after Bob's comment and re-explained. This answer is in this email below and re-copied here:

 

( CalcO[i] <= 0.11 AND CalcO[i] >= -0.11 ) //Number is BETWEEN -0.11 and +0.11

 

It makes more sense for reading code to reverse the terms (the plus and minus values and < > ) like this:

 

( CalcO[i] >= -0.11 AND CalcO[i] <= 0.11 ) //Number is BETWEEN -0.11 and +0.11

 

 

Simply scrolling through a window changes nothing except the values reported in the Y axis on the right side of the graph. If you want to see values (on the chart or in the Interpretation window) for a given bar, you must click on the bar.

 

 

As to Diff not changing, I see you have the same logic error inside the loop as shown above. Apply the same fix that as above to stop getting the same answers regardless of the data values.

 

 

There is more code I have not evaluated yet. If the above is changed and still does not solve your problem, write back.




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




Attachment: Description: Binary data