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

[amibroker] Backtesting Market Timing Signals



PureBytes Links

Trading Reference Links



I downloaded the Amibroker Demo and I am trying to backtest market
timing signals.

I put the buy/sell dates in a csv file and am trying to read it in and
convert it into buy/short arrays. I have not been very successful.

I cannot see my printf out output because I cannot figure out how to
display the output window.

The code is 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(StrRight(mm_dd_yyyy,4)); 
  Date_Num = (10000 * (yy_ - 2000)) + (100 * mm_) + dd_; 
  RESULT = Date_Num; 
  return RESULT;
} 

procedure getSignalDates( filename)
{
  fh = fopen( filename, "r");
  if( fh )
  {
    while( ! feof( fh ) )
    {
      s=fgets(fh);
      Index = ValueWhen( DateNum() == Date_To_Num(StrExtract( s,1 )),
BarIndex(), 1);
      sig=StrExtract( s,0 );
      if( sig == "B")
      {
        Buy[Index]=1;
        Cover[Index]=1;
      }
      else
      {
        if( sig == "S")
        {
          Short[Index]=1;
          Sell[Index]=1;
        }
        else
        {
          if( sig == "C")
          {
            Sell[Index]=1;
            Cover[Index]=1;
          }
          else
          {
            printf( "ERROR in %s/n", filename );
          }
        }
      }
    }
  }
  else
  {
  printf("ERROR: file can not be found (does not exist)");
  }
}

Buy=Sell=Short=Cover=0;
getSignalDates( "d:/my\ programs/amibroker\fssignals");
for( i=0; i<BarCount; i++)
{
  printf("%d",Buy[i]);
}








------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/