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

Re: [amibroker] "if" and/or "SelectedValue" problem



PureBytes Links

Trading Reference Links




Chuck,
 
if statement has to decide which path has to be 
taken.
It can make such decision only using SINGLE 
value.
Arrays have many values (elements) therefore you have 
to
choose one element to base "if" decision.
 
If you want to check ALL values of array you need a 
loop:
 
for( i = 0; i < BarCount; i++ )
{
 
 ShortOK = OI[ i ] > 600;
 
  if( ShortOK )
  {
    // do something
  }
}
 
If you want to check SINGLE value of array ,
you have to choose WHICH element you want to 
check.
 
you can choose any bar from 0...(BarCount-1) 
range.
 
For example, to check the very first bar:
 
ShortOK = OI[ 0 ] > 600;
if( ShortOK )
{ 
  // do something
}
 
SelectedValue is a function that retrieves 'selected element' 
of the array.
Since 'selection line' is available only for CHARTS. 
SelectedValue gives
the value of array at bar that is currently selected in chart 
by vertical line.
This is how it works in INDICATORS, INTERPRETATION and CHART 
COMMENTARY
(because they are relative to selected bar)
 
In AA window 'selected element' means THE LAST BAR of 
currently selected
analysis range. It is the last available bar for "all quotes" 
and "last n quotes" range.
It is the the bar corresponding to "End Date" when using 
"From-To" range.
 
So if you choose "all quotes" in AA
SelectedValue function is equivalent to 
 
OpenInt[ BarCount - 1 ]
 
- it gives you SINGLE value equal to the OpenInterest for the 
LAST bar
available
 
Therefore second column of your exploration would list the 
same, one value
that represents last analysis bar.
 
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=chuck_rademacher@xxxxxxxxxx 
  href="">Chuck Rademacher 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Sunday, May 11, 2003 10:26 AM
  Subject: [amibroker] "if" and/or 
  "SelectedValue" problem
  
  I'm 
  hoping that someone can help me to understand what is happening with my AFL 
  code.
  <FONT face=Arial color=#0000ff 
  size=2> 
  AB 
  won't let me do the following:
  <FONT face=Arial color=#0000ff 
  size=2> 
  <FONT face=Arial color=#0000ff 
  size=2>ShortOK = OI > 600;
  if 
  (ShortOK) {
  <FONT face=Arial color=#0000ff 
  size=2>    do something
  <FONT face=Arial color=#0000ff 
  size=2>}
  <FONT face=Arial color=#0000ff 
  size=2> 
  It 
  won't let me do that because ShortOK is an array, not an integer or 
  boolean.
  <FONT face=Arial color=#0000ff 
  size=2> 
  <FONT face=Arial color=#0000ff 
  size=2> 
  So, 
  I tried this:
  <FONT face=Arial color=#0000ff 
  size=2> 
  <FONT face=Arial color=#0000ff 
  size=2>ShortOK = OI > 600;
  if 
  (SelectedValue(ShortOK)) {
  <FONT face=Arial color=#0000ff 
  size=2>    do something
  <FONT face=Arial color=#0000ff 
  size=2>}
  <FONT face=Arial color=#0000ff 
  size=2> 
  AB 
  will let me do it, but I don't seem to be getting the correct 
  value.   
  <FONT face=Arial color=#0000ff 
  size=2> 
  <FONT face=Arial color=#0000ff 
  size=2> 
  So, 
  I made up some very simple code:
  <FONT face=Arial color=#0000ff 
  size=2> 
  <FONT face=Arial color=#0000ff 
  size=2>ShortOK = OI > 600;
  <FONT face=Arial color=#0000ff 
  size=2>Filter = 1;
  <FONT face=Arial color=#0000ff 
  size=2>AddColumn (ShortOK, "shortok");
  <FONT face=Arial color=#0000ff 
  size=2>AddColumn (SelectedValue(ShortOK), "selected");
  <FONT face=Arial color=#0000ff 
  size=2> 
  When 
  I run an exploration, I get different values for ShortOK and 
  SelectedValue(ShortOK) and I expected them to be the same.
  <FONT face=Arial color=#0000ff 
  size=2> 
  <FONT face=Arial color=#0000ff 
  size=2> 
  So, 
  I must not understand what SelectedValue means and/or I don't understand how 
  to get my "if" statement to work.
  <FONT face=Arial color=#0000ff 
  size=2> 
  Any 
  assistance would be appreciated, if you can wade your way through my 
  notes.
  <FONT face=Arial color=#0000ff 
  size=2> 
  <FONT face=Arial color=#0000ff 
  size=2>ThanksSend 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


ADVERTISEMENT









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.