COCO研究院

 找回密碼
 註冊
搜索
12
返回列表 發新帖
樓主: keymaker

AmiBroker 過濾器 Exploration 的問題

[複製鏈接]
發表於 13-10-20 19:38 | 顯示全部樓層
keymaker 發表於 13-10-20 19:17
Thank you so much!
Everything is correct here,
but I don't know the purpose of variables SetTradeD ...

Just read in the help file

SetTradeDelays
- allows to control trade delays applied by the backtester
Trading system toolbox
(AFL 2.1)

SYNTAX SetTradeDelays( buydelay, selldelay, shortdelay, coverdelay )
RETURNSnothing
FUNCTION Sets trade delays applied by the backtester. This function allows you to override trade delays from the "Settings" page. It is important do understand what trade delays really do. They in fact internally apply the following:
Buy = Ref( Buy, -buydelay );Sell = Ref( Sell, -selldelay );Short = Ref( Short, -shortdelay );Cover = Ref( Cover, -coverdelay );inside backtester after your formula is executed but before backtester starts trade simulation. It is functionally equivalent to having above 4 lines at the end of your formula. Note that NO OTHER variables are affected by trade delays, therefore for example if your position sizing depends on values found in buy/sell/short/cover variables *and* if you are using non-zero trade delays you need to account for that in your code.
EXAMPLEsettradedelays( 1, 1, 1, 1 )


So settradedelays( 1, 1, 1, 1 ) means that you buy, sell, short cover one bar later than signal bar.
So if buy signal is at close then you buy on next bar's open, for example.

as for equityflag ... it is also written in the help file

Equity
- calculate single-symbol equity line
Trading system toolbox
(AFL 2.0)

SYNTAX equity( Flags = 0, RangeType = -1, From = 0, To = 0 )
RETURNSARRAY
FUNCTION NOTE: This function is left here for backward compatibility and is using old, single-security backtester. New coding should rather use portfolio-level equity (special ~~~EQUITY ticker). Function:
Returns single-security Equity line based on buy/sell/short/cover rules, buy/sell/short/coverprice arrays, all apply stops, and all other backtester settings. Flags - defines the behaviour of Equity function

0 : (default) Equity works as in 3.98 - just calculates the equity array
1 : works as 0 but additionally updates buy/sell/short/cover arrays so all redundant signals are removed exactly as it is done internally by the backtester plus all exits by stops are applied so it is now possible to visualise ApplyStop() stops.
2 : (advanced) works as 1 but updated signals are not moved back to their original positions if buy/sell/short/cover delays set in preferences are non-zero. Note: this value of flag is documented but in 99% of cases should not be used in your formula. Other values are reserved for the future.
RangeType - defines quotations range being used:
-1 : (default) use range set in the Automatic analysis window
0 : all quotes
1 : n last quotes (n defined by 'From' parameter)
2 : n last days (n defined by 'From' parameter)
3 : From/To dates
From : defines start date (datenum) (when RangeType == 3) or "n" parameter (when RangeType == 1 or 2)
To: defines end date (datenum) (when RangeType == 3) otherwise ignored

datenum defines date the same way as DateNum() function as YYYMMDD
where YYY is (year - 1900), MM is month, DD is day

December 31st, 1999 has a datenum of 991231
May 21st, 2001 has a datenum of 1010521 All these parameters are evaluated at the time of the call of Equity function. Complete equity array is generated at once. Changes to buy/sell/short/cover rules made after the call have no effect. Equity function can be called multiple times in single formula. IMPORTANT NOTE: Equity() function uses so called "old" single-security backtester that offers only subset of features of new backtester. To retrieve value of portfolio-level equity generated by new backtester use Foreign("~~~EQUITY", "C").
EXAMPLEBuy = //your Buy rule;
Sell = //your Sell rule;
Graph0 = Equity();


Keep in mind that Equity() function is single security backtester function. For portfolio you must use backtester in Analysis window not explorer. Also Equity function is not needed in backtester.

As for flag.
if you enter on same bar as signal bar then you would use flag = 1. If you enter i.e. on next bar's open then you would use flag = 2. But flag = 2 should not be used in Backtester because otherwise it will double the delays (1-bar delay will be applied by Equity call, the other by the backtester itself).

Therefore if using different equityflags then include if( Status( "action" ) == actionexplore) or if( Status( "action" ) == actionIndicator) if you use same system code for exploration/plot and in backtester.






評分

參與人數 1金錢 +2 收起 理由
keymaker + 2 感謝分享..Let me read again..

查看全部評分

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-5-17 11:22

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook