| 
 PureBytes Links 
Trading Reference Links 
 | 
Hi Herman,
Thanks for posting the code. It helped me write my program more
succinctly.
However, I am still getting the same error.
I discovered I can write debugging info to a file so now I can debug
the code.
Here is the problem:
---
Index = ValueWhen( DateNum() == numdate, BarIndex(), 1 );
Buy[Index];
----------^
Error 6.
Array subscript has to be a number
---
The debugging value for Index is 201. If I write:
Buy[201]=1;
There is no error but
Buy[Index];
gives the above error. I don't understand why or how to fix it?
New program listed below.
Bill
---
function Date_To_Num( mm_dd_yyyy ) 
{ 
  mm_ = StrToNum( StrLeft( mm_dd_yyyy,2 ) ); 
  dd_ = StrToNum( StrMid( mm_dd_yyyy,3,2 ) ); 
  yy_ = StrToNum( StrMid( mm_dd_yyyy,6,4 ) ); 
  Date_Num = ( 10000 * ( yy_ - 1900 ) ) + ( 100 * mm_ ) + dd_; 
  RESULT = Date_Num; 
  return RESULT; 
} 
function getSignalString(fh)
{
  if( ! feof( fh ) )
    result = fgets( fh );
  else
    result = "none";
  return result;
}
filename = "d:\\my programs\\amibroker\\fssignals";
fh = fopen( filename, "r" );
signalString = getSignalString(fh);
sig=StrExtract( signalString,0 );
txtdate = StrExtract( signalString,1 );
numdate = Date_To_Num( txtdate );
Index = ValueWhen( DateNum() == numdate, BarIndex(), 1 );
Buy=Sell=0;
while ( signalString != "none" )
{
  if ( sig == "B" )
    Buy[Index] = 1;
  else
  {
    if ( sig == "S" )
      Sell[Index] = 1;
    else
      printf("error in %s", filename);
  }	
  signalString = getSignalString(fh);
  sig=StrExtract( signalString,0 );
  txtdate = StrExtract( signalString,1 );
  numdate = Date_To_Num( txtdate );
  Index = ValueWhen( DateNum() == numdate, BarIndex(), 1 );
}	
fclose(fh);
Plot(Buy,"BUY",5,2);
Plot(Short,"short",4,2);
Title = BuySignal+"\n"+SellSignal;
---
------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 
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
<*> 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:
    http://docs.yahoo.com/info/terms/
 
 |