COCO研究院

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

買賣價超過K BAR 範圍

[複製鏈接]
 樓主| 發表於 14-11-6 09:05 | 顯示全部樓層
本帖最後由 skyler 於 14-11-6 09:08 編輯

ZS #F ZS #F.zip (1.18 MB, 下載次數: 94)

AFL code   PolicyNo4.zip (796 Bytes, 下載次數: 116)

had a short sign
at 2014/11/04 01:00:00
short price is 1038
and the k bar high price is 1035
backtest result show this trade
It's wrong




發表於 14-11-6 10:35 | 顯示全部樓層
參考一下
Yahoo! Groups上buyprice不依help上的O,C的作法。


Hello,

You got it all wrong. DO NOT change default settings unless you know very well what you are doing.

Correct formula is:

SetOption("PriceBoundChecking", TRUE); //DO NOT CHANGE DEFAULTS!
HistoVolat_10 = StDev(log(C / Ref(C, -1)), 10) * sqrt(260); // * 10;
formula = (Avg * HistoVolat_10) * sqrt(Days/260);
HiPrc = C + formula/2;
LoPrc = C - formula/2;

BuyPrice = Ref(LoPrc,-1);
Buy = L < BuyPrice AND H > BuyPrice;

SellPrice = Ref(HiPrc,-1);
Sell = L < SellPrice AND H > SellPrice;


Best regards,
Tomasz Janeczko
amibroker.com

On 2013-04-01 23:09, ewn87544 wrote:
> I am trying to backtest the script below but
> It will buy or sell at the BUYPRICE or SELLPRICE
> even when it is out of the range of the price bar.
> How do I make this statement be binding?
> IIf(L < BuyPrice AND H > BuyPrice, Buy = 1,0 );
> Thanks
>
> SetOption("PriceBoundChecking",0); //fALSE
> SetTradeDelays( 1, 1, 1, 1 );
> HistoVolat_10 = StDev(log(C / Ref(C, -1)), 10) * sqrt(260); // * 10;
> formula = (Avg * HistoVolat_10) * sqrt(Days/260);
> HiPrc = C + formula/2;
> LoPrc = C - formula/2;
>
> BuyPrice = Ref(LoPrc,-1);
> IIf(L < BuyPrice AND H > BuyPrice, Buy = 1,0 );
>
> SellPrice = Ref(HiPrc,-1);
> IIf(L < SellPrice AND H > SellPrice,Sell = 1,0);
>
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at

> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:

>
> Yahoo! Groups Links
>
>
>
 樓主| 發表於 14-11-6 11:19 | 顯示全部樓層
atrader 發表於 14-11-6 10:35
參考一下
Yahoo! Groups上buyprice不依help上的O,C的作法。

恩呀~ 這做法就是我在 8F裡寫的
Buy = (BuyPrice >= L);
Sell = (SellPrice <= H);
Short = (ShortPrice <= H);
Cover = (CoverPrice >= L);

我不確定這個問題是 BUG
或是個案
但我覺得
為了以防萬一
還是將買賣價設定在K線範圍的邏輯寫在買賣訊號中

不然就會像我再重新回測時
前後回測的結果差異大到你吐血崩潰


發表於 14-11-6 21:26 | 顯示全部樓層
There is no bug. The bug is that you don't understand.

Exploration for example does not support portfolio level functionalities.
You can only use single security backtester function Equity() there in exploration. That one (as it's name says - "single security backtester") does not support newer portfolio level backtester functionalities and some backtest settings supported only for portfolio level. for example priceboundchecking is not supported by Equity() function. Equity() was introduced in 4.40. Priceboundchecking was introduced in 4.45. Simply check development log.

If you wanna be smarter than TJ then contact him.
發表於 14-11-6 21:29 | 顯示全部樓層
本帖最後由 joshsmi 於 14-11-6 21:37 編輯

Here is some altered alternative apx file

3.png
2.png

Apx.zip

5.03 KB, 下載次數: 157

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

本版積分規則

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

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

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 |