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

RE: [amibroker] Intraday data chart



PureBytes Links

Trading Reference Links




Herman,
 
Short story:
Your code does NOT really need index addressing, 
setbarsrequired, barindex at all.
Somehow you managed to complicate thing 
when it is very, very simple and can be coded in 2 lines:
MyCustomArray = EMA(C,3); Title = 
"NumberFromMyCustomIndicator ="+NumToStr(MyCustomArray ,1.2);
<FONT face=Arial 
size=2> 
Long 
story:
 
Take a look at picture below:
 

<TABLE  cellSpacing=0 
cellPadding=0 width=529 border=0 x:str>
  
  <COL  
  width=97>
  <COL  
  width=32>
  <COL  
  width=28>
  <COL  
  width=31>
  <COL  
  width=28>
  <COL  
  width=30>
  <COL  
  width=32>
  <COL  
  width=29>
  <COL  
  width=37>
  <COL  
  width=36>
  <COL  
  width=35>
  <COL  
  width=40>
  <COL  
  width=32>
  <COL  
  width=42>
  
  
    <TD class=xl24 
     
    width=97 height=17>Bar Index
    <TD class=xl24 
     
    align=right width=32 x:num>0
    <TD class=xl24 
     
    align=right width=28 x:num>1
    <TD class=xl24 
     
    align=right width=31 x:num>2
    <TD class=xl24 
     
    align=right width=28 x:num>3
    <TD class=xl24 
     
    align=right width=30 x:num>4
    <TD class=xl24 
     
    align=right width=32 x:num>5
    <TD class=xl24 
     
    align=right width=29 x:num>6
    <TD class=xl24 
     
    align=right width=37 x:num>7
    <TD class=xl26 
     
    align=right width=36 x:num>8
    <TD class=xl24 
     
    align=right width=35 x:num>9
    <TD class=xl24 
     
    align=right width=40 x:num>10
    <TD class=xl24 
     
    align=right width=32 x:num>11
    <TD class=xl24 
     
    align=right width=42 x:num>12
  
    <TD class=xl25 
     
    height=17>Array element
    <TD 
    ><FONT 
      face="Arial CE" size=2>
    <TD 
    ><FONT 
      face="Arial CE" size=2>
    <TD 
    ><FONT 
      face="Arial CE" size=2>
    <TD 
    ><FONT 
      face="Arial CE" size=2>
    <TD class=xl25 
     
    align=right x:num>0
    <TD class=xl25 
     
    align=right x:num>1
    <TD class=xl25 
     
    align=right x:num>2
    <TD class=xl25 
     
    align=right x:num>3
    <TD class=xl26 
     
    align=right x:num>4
    <TD class=xl25 
     
    align=right x:num>5
    <TD 
    >
    <TD 
    >
    <TD 
    >
 
 
You see: Bar index represents ENTIRE data set you 
have.
Array may be actually smaller than your entire data 
set (if visible area for indicator is small) and
may have LESS elements than entire data set you 
have.
Array in indicator builder when QuickAFL is on may 
include only visible part (plus some extra bars).
 
Now selected bar is shown with red color. As you 
can see although it has a bar index of 8,
the actual array element has the number of 
4.
 
That's why you can not use barindex to address your 
arrays directly.
 
Instead use SelectedValue directly on array, by 
simply typing:
 
MyCustomArray = 
EMA(C,3); NumberFromMyCustomIndicator = SelectedValue( 
MyCustomArray );
 
It is way simpler than your code 
and works always and you do not need to bother about quickafl and 
setbarsrequired at all.
 
In fact NumToStr already performs "selected value" 
so you code can be simplified to 2 lines:

 
MyCustomArray = EMA(C,3); Title = 
"NumberFromMyCustomIndicator ="+NumToStr(MyCustomArray 
,1.2);
 
It performs as you wanted it to perfom and takes 2 
lines instead of 5.
It is all actually simpler than you think. 

Best regards,Tomasz 
Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Herman van den 
  Bergen 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Friday, July 23, 2004 12:45 
AM
  Subject: RE: [amibroker] Need help with 
  SetBarsRequired...
  
  The 
  number in the title, did it stay or was it 'replaced' by a 
  permanent error msg? 
  <FONT face=Arial color=#0000ff 
  size=2> 
  The 
  subscript should not be out of range...any idea what is wrong with my 
  code? 
  <FONT face=Arial color=#0000ff 
  size=2> 
  I 
  think the error occurs in the first two passes but not in the last. If nobody 
  can correct me I'll send it to support. I think this problem was reported 
  on the list more than a year ago but i can't remember/find whether there was a 
  solution.
  <FONT face=Arial color=#0000ff 
  size=2> 
  <FONT face=Arial color=#0000ff 
  size=2>thanks!
  <FONT face=Arial color=#0000ff 
  size=2>herman
  
    <FONT face=Tahoma 
    size=2>-----Original Message-----From: Ara Kaloustian 
    [mailto:ara1@xxxxxxxxxx]Sent: Thursday, July 22, 2004 5:48 
    PMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: 
    [amibroker] Need help with SetBarsRequired...Importance: 
    High
    Herman,
     
    I got an answer (in title line) of 19.19 and 
    then an error message saying subscript out of range
    <BLOCKQUOTE 
    >
      ----- Original Message ----- 
      <DIV 
      >From: 
      Herman van den 
      Bergen 
      To: <A 
      title=amibroker@xxxxxxxxxxxxxxx 
      href="">AmiBroker YahooGroups 
      Sent: Thursday, July 22, 2004 12:23 
      PM
      Subject: [amibroker] Need help with 
      SetBarsRequired...
      
      Sorry to raise 
      this topic once more...but could some kind soul please turn ON QuickAFL 
      and run the example code below in an Indicator by 
      pressing APPLY? <SPAN 
      class=500051718-22072004>In the AB Status bar it says it retrieved 89815 
      bars (RT data), <SPAN 
      class=500051718-22072004>Using DebugView, 
      w<SPAN 
      class=500051718-22072004>ith QuickAFL 
      Enabled, pressing Apply gives me these numbers:
      <SPAN 
      class=500051718-22072004> 
      <SPAN 
      class=500051718-22072004>[1704] # 
      BarNum=75,988  BarCount=75989[1704] # BarNum=75,918  
      BarCount=75989[1704] # BarNum=75,918  
      BarCount=483<SPAN 
      class=500051718-22072004>
      It appears that the BarCount 
      returned by <FONT face="Times New Roman" 
      size=3>SelectedValue(BarIndex()) during the first the two passes 
      defaults to normal count even though QuickAFL is enabled<SPAN 
      class=500051718-22072004>, this 
      triggers an error msg. Can somebody 
      please explain how i can run this code with QuickAFL() On and 
      SetBarsRequired()? I know 
      that i can program around the problem but that doesn't help me in my 
      real application. 
      <SPAN 
      class=500051718-22072004><FONT 
      size=2> 
      <FONT face=Arial 
      size=2>Your help will be much appreciated!
      <FONT face=Arial 
      size=2>herman.
      <SPAN 
      class=500051718-22072004> 
      
      
      
      SetBarsRequired( 100,10);
      MyCustomArray = 
      EMA(C,3); BarNum = SelectedValue(BarIndex()); // i want to read 
      the value at the cursorNumberFromMyCustomIndicator = MyCustomArray 
      [Barnum]; Title = "NumberFromMyCustomIndicator 
      ="+NumToStr(NumberFromMyCustomIndicator ,1.2);
      //_TRACE("# 
      BarNum="+NumToStr(BarNum,1.0)+"  
      BarCount="+NumToStr(BarCount,1.0,False));
      
      
      Check AmiBroker web page at:<A 
      href="">http://www.amibroker.com/Check 
      group FAQ at: <A 
      href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
      Check AmiBroker web page at:<A 
      href="">http://www.amibroker.com/Check 
      group FAQ at: <A 
      href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
      Check AmiBroker web page 
  at:<A 
  href="">http://www.amibroker.com/Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  


Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Sponsor


  ADVERTISEMENT 












Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.