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

RE: [amibroker] Help - How to export symbol, buy date, buy close price, sell date, and sell close price as a single line per trade directly to a csv file when run backtest


  • To: <amibroker@xxxxxxxxxxxxxxx>
  • Subject: RE: [amibroker] Help - How to export symbol, buy date, buy close price, sell date, and sell close price as a single line per trade directly to a csv file when run backtest
  • From: "Duke Jones, CMT" <Duke@xxxxxxxxxxxxx>
  • Date: Wed, 14 Sep 2005 07:59:22 -0500

PureBytes Links

Trading Reference Links

I feel the same about my competence as well with AFL but everyday a little more of the light comes on albeit still pretty dim. :-) I searched the archives and found this that does create an excel file. Maybe this will work as is for what you need.
 
 
SetCustomBacktestProc("");

if( Status("action") == actionPortfolio
) {
   fh1=
fopen("C:\\Documents AND Settings\\Amit\\My Documents\\Results\\NewTemp.csv", "w"
);
   string1=
"Date,Equity,Cash,OpenPos,OpenPosEquity,ClosedPos,Entries,Exits"
;
  
fputs(string1 + "\n"
, fh1);

   bo =
GetBacktesterObject
();
   bo.PreProcess();
// Initialize backtester


   dt=
DateTime
();
   PreOpenPos=
0
;
   PreclosedPos=
0
;

  
for(bar=0; bar<BarCount
; bar++) {
      OpenPos=
0
;
      ClosedPos=
0
;
      OpenPosEquity=
0

      

      
// Run through all closed positions at bar

      
for (trade=bo.GetFirstTrade(); trade; trade=bo.GetNextTrade())  // iterate through current closed positions

         ClosedPos++;
      
      
// Run Through all open positions at bar

      
for (trade=bo.GetFirstOpenPos(); trade; trade=bo.GetNextOpenPos()) { // iterate through current open positions

         OpenPos++;
         OpenPosEquity=OpenPosEquity+trade.GetPositionValue();
      }

      bo.ProcessTradeSignals(bar);
// Process current bar's signals

        String1=
NumToStr(dt[bar],formatDateTime)+ ","+ NumToStr(bo.equity)+ ","+ NumToStr(bo.Cash)+ ","+ NumToStr(OpenPos)+ ","+ NumToStr
(OpenPosEquity)+ ","+ NumToStr(ClosedPos)+ ","+ NumToStr(Max(OpenPos-PreOpenPos,0))+ ","+ NumToStr(ClosedPos-PreclosedPos);
      
if
(fh1)
         
fputs(string1 + "\n"
, fh1 );

      PreOpenPos=OpenPos;
// Reserve current bar value for next bar's Entries figure

      PreclosedPos=ClosedPos;
// Reserve current bar value for next bar's Exits figure

   }

   bo.PostProcess();
   
fclose(fh1);  

}
 
// Your trading system here 
Buy=C>MA(C,200) AND H>Ref(HHV(H,100),-1);
Sell=C<MA(C,200
);
PositionSize=-0.5


________________________________________________________________________________________________________
 

Duke Jones, CMT

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of dpweir
Sent: Wednesday, September 14, 2005 7:25 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Help - How to export symbol, buy date, buy close price, sell date, and sell close price as a single line per trade directly to a csv file when run backtest

I was looking at FPUTS. I was wondering how you reference the buy date and the sell date, and place them on the same line ? The example given, while impressive seems to output only ticker information, and I can’t easily see how it could be applied to pull out the information from a backtest.

 

My level at AFL is so limited at this stage, and it is so frustrating not to be able to do something which would appear simple on the surface =(

 

Regards

 

Dave

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Duke Jones, CMT
Sent: Wednesday, 14 September 2005 9:58 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Help - How to export symbol, buy date, buy close price, sell date, and sell close price as a single line per trade directly to a csv file when run backtest

 

Here is Graham's file for exporting intraday data. Looks like it could be adapted. Might give you some ideas. I usually just copy and paste from the AA window using addcolumns to insert the fields I want.

 

Duke Jones, CMT

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of dpweir
Sent: Wednesday, September 14, 2005 6:48 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Help - How to export symbol, buy date, buy close price, sell date, and sell close price as a single line per trade directly to a csv file when run backtest

Hello

 

Can anyone script an export of the symbol, buy date, buy close price, sell date, and sell close price as a single line per trade (buy and sell) directly to a csv file when running a backtest ?

 

Very much appreciate any help.

 

Regards

 

Dave

 

 

 

 

 

 

 




--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.24/101 - Release Date: 9/13/2005



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.24/101 - Release Date: 9/13/2005


--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.24/101 - Release Date: 9/13/2005



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





--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.24/101 - Release Date: 9/13/2005