Hardcode Back Test General Settings in AFL

Hello Amibroker Community,

I have a code with some initial settings... see eg below


//---------------------------------------- Initial Capital & Risk ----------------------------------------//  
SetOption("InitialEquity", 12000000);  
SetOption( "UsePrevBarEquityForPosSizing", 1 ); //*set the use of last bars
SetOption("MinPosValue",10000); // min value of shares to purchase // 
RiskPerShare =  3 * ATR( 14 ); //Risk Per share // 
PositionRisk = 5; // risk 5% of entire equity on single trade // 
PctSize =  PositionRisk * BuyPrice / RiskPerShare; // position size calculation - no of shares// 
SetPositionSize( PctSize, spsPercentOfEquity ); //set position size) 
SetOption( "AllowPositionShrinking", True ); // Shrink Position on Loss // 
RoundLotSize = 1; // Lot Size // 
SetOption("RefreshWhenCompleted",True); // Refresh when completed // 
//--------------------------------------------------------------------------------------------------------//  
  
  
  
//--------------------------------------------- COMMISSIONS ----------------------------------------------//  
SetOption("CommissionMode", 1); // Percent Mode  
SetOption("CommissionAmount",0.25); // 0.25% of Trade Value  
//--------------------------------------------------------------


my Question is how do i hard code the below Backtest General Settings in AFL ?

  1. positions (long/short/both)
  2. periodicity - i tried setoption("periodicity", indaily); --- didnt work
  3. Futures mode
  4. Pad and align ref data
  5. annual fixed int rate
  6. account margin

apart from this would also like to hard code

  1. Limit trade size as % of entry and 2. i do not want to include stocks or sectors with no volume data

Would really appreciate if anyone could guide me in the right direction pls.

thanks,
Gautam

1 Like

Just save your .APX project file (File->Save from main menu when Analysis window is open). This will save your formula AND all settings in one file. Such file can be also sent to other person/computer and he/she will have same formula and settings that way.

image

Then you save the project file

image

Then you can later load it using

File->Open

or

File->Recent Files

1 Like

Dear TJ,

Thank you very much for your e-mail.

Since we are talking about settings, I also would like to raise a point please.

Actually there is one key setting where APX file does not save the relevant setting: Here the point refers to FX conversion settings in preferances where functional currency of the report could be defined.

What would really make it practical, if APX file also captures this FX conversion settings.

So far these FX settings are global to Amibroker & what would make life easier, if these could be amended in such a way to be saved down within the APX file.

Many thanks,

Kind regards,

AD

I don't think it would be easier. You would need to define FX for each backtest separately, which would be more work, not less.

Dear TJ,

In UK location due to legislation/regulation we have two types of brokers. First, usual brokers all traders use globally. Second, spread betting ones. The latter provides accounts on one currency only. For instance, you can run all instruments in EUR or GBP irrespective of the underlying currency of the futures contract. So these types of brokers transfer FX risk from trader to themselves.

To Test same strategy with these two different brokers requires continues alignment of FX conversion rates within Preferences.

If APX file would have saved these conversion rates then one APX file could be used for one type broker and second APX file for the other.

I do have a feeling that I will not get what I ask for in the short run but put it out there so requirement would be known for UK clients.

Many thanks,

Kind regards,

AD

Thank you Tomasz. Appreciate the help. cheers