免費論壇 繁體 | 簡體
公告:SCLUB雲端專屬主機己開放租用
分享
MT4程式(Program)專業代寫服務(請email:letgofortrading@gmail.com) 警告:文章內容可能有大便,不喜請勿入。請不要像動物一樣,不歡迎也請勿自行進來找碴和找大便。私人網頁,後果請自行負責~
返回列表 發帖

Multicharts ADE應用:連賠N次後才實際進場


Multicharts ADE應用:連賠N次後才實際進場


All Data Everywhere ,跨圖表資料傳送.原本是使用在Tradestation上

而跨圖表資料傳送可以幹嘛?

運用上很多, 如多策略口數控制,不同商品的套利策略(下單時間先後,當然也可以用下單機搞定)

但如果沒有要回測只是指標數值在不同圖表間互傳

那用內建的

GVSetNamedDouble (把要傳的值放入籃子裡)

GVGetNamedDouble (從籃子裡拿值出來用)

就可以了~



如果是像標題:連賠N次後才實際進場,並想要回測

那就必需用到ADE.

這個方式就是:

開兩個圖A,B,執行相同策略.圖A策略賠N次後送出允許訊號給圖B,圖B的策略才可以下單

那A送給B的訊號,就是用ADE來溝通.

(ADE 會呼叫DLL,卷商版的這個功能被鎖住了,如果是卷商版的無法使用,或是用特別的辦法去呼叫DLL..)



要用ADE首先要做一些設定方式

下載這個檔案


如果是裝64位元的,下載這個DLL取代原本的

剛下載的檔案內就有詳細的英文說明

Please perform the following steps to install ADE:

Install ELCollections as described in the “Collections for EasyLanguage” topic on TSW.
Create a directory called C:\ADE. This is the ADE root directory. You can use a different name and/or a different drive, but if you do, see Step 6 for additional instructions.
Create the following subdirectories in the ADE root directory:



C:\ADE\Data
C:\ADE\Classes
C:\ADE\Code



This is an important step. ADE uses these subdirectory names, and some functions will not work correctly if they do not exist.

The root directory name (C:\ADE) can be different, but the subdirectories must be called “Data”, “Classes”, and “Code”.

Extract the ADE.zip file into the ADE root directory. Some of the files used by ADE must be in the ADE root directory,

so this is the simplest way to ensure that they are there.

Move the OHLCV.txt file into the Classes subdirectory.

Import the AllDataEverywhere.ELD file into TradeStation.





如果不想看英文, DK有寫中文設定說明.

照著設定就可以了.



如何用?

(如果以下這邊看不懂,直接跳過從下面的圖示開始看)

說明檔內有舉個例子,使用在兩個圖表分別是5分和30分K 之間的RSI,ADX 指標傳送(30分的指標顯示在5分K上)



指標程式,執行在30分K的圖上,從30K上拿RSI和ADX資料

Vars:

   Class(“ADX&RSI”),   // identifies our metrics with a unique name

   InfoMap(MapSN.New); // used to pass data to ADE



// Put the information we want to store in our InfoMap

Value1=MapSN.Put(InfoMap, "ADX", ADX(14));

Value1=MapSN.Put(InfoMap, "RSI", RSI(Close, 14));



// Tell ADE to store this info for the current symbol and bar interval

Value1=ADE.PutBarInfo(Class, GetSymbolName, ADE.BarInterval,

   ADE.BarID, InfoMap);



把拿到的RSI和ADX資料放到5K圖上並畫出來

Inputs:  Interval(30);

Vars:

   Class(“ADX&RSI”),   // identifies our metrics with a unique name

   InfoMap(MapSN.New), // used to retrieve data from ADE

   MyADX(0), MyRSI(0);



// Retrieve the info for the current symbol and bar interval into InfoMap

Value1=ADE.GetBarInfo(Class, GetSymbolName, Interval,

   ADE.BarID, InfoMap);



// Fetch the values from the InfoMap into variables

MyADX=MapSN.Get(InfoMap, "ADX");

MyRSI=MapSN.Get(InfoMap, "RSI");



// Plot them

Plot1(MyADX, "ADX");

Plot2(MyRSI, "RSI");



==========================================================================================

以下為簡化版

如果上面的例子看不懂,且沒有要用到多對多,或雙向互傳,

只要使用到一對多,單向送資料(單圖運算結果,單向傳給多圖)

可以從下面說明開始看:

為了方便使用,我寫成兩個函數

ADE.Put

ADE.Get

以下用圖形說明這兩個函數

可以想像成一個載具(車),把值(人)從這個圖送到另一個圖.

  





以下實際用程式舉例:

1.5k電子期的RSI值,顯示在1k台指期上



從5k 電子期上拿值(rsi)

vars: var1( 0 );

var1=RSI(close,14);

value1=ADE.Put(var1,0,0);

將這個程式執行在電子期上得到rsi值

ADE.Put(     ,     ,     )->可以運送3個值,把要運送的值填入就行了

這裡是填入var1 就是rsi值,剩下兩個沒用到就寫0

==========================================

丟值出來在台指一分k圖上,並畫出來

vars:var1(0),var2(0),var3(0);

value1=ADE.Get(5,var1,var2,var3);

plot1(var1);



將這個程式執行在台指期圖上,就可以得到電子期的RSI值

ADE.Get(Bar_Type,var1,var2,var3)

->第一格填入送值過來的圖形k線週期,從5k電子期上拿的所以寫5

之後的三格就是要送出來的值啦

var1->rsi ,var2->0 ,var3->0

再把 var1畫出來就 ok 了.

很簡單吧  ^^

  





2.連賠N次後才實際進場

有些勝率很低的策略,是靠幾次大賺來補小賠的金額,

這種策略有些特性是:大賺後都會有一直小賠的過渡期.

這時候就會想能不能大賺後先不要下單,等賠個兩三次後再下單呢?

+

程式方法如下:

用簡單的均線策略說明:

策略:

inputsengtH1(20),Length2(80);

vars:a1(0),a2(0);

a1=XAverage(close,LengtH1);
a2=XAverage(close,Length2);

condition1=a1 Crosses Above a2;
condition2=a1 Crosses Under a2;

//===

if condition1=true then Buy ("Long_in" ) next bar at market ;
if condition2=true then sellshort ("short_in") next bar market ;



將這個策略改寫成兩個,一個正常執行,但記錄賠錢次數,一個用這個條件來限制是否要下單





正常執行的程式,加入記錄程式碼

inputsengtH1(20),Length2(80);

vars:a1(0),a2(0);

a1=XAverage(close,LengtH1);
a2=XAverage(close,Length2);

condition1=a1 Crosses Above a2;
condition2=a1 Crosses Under a2;

//===

if condition1=true then Buy ("Long_in" ) next bar at market ;
if condition2=true then sellshort ("short_in") next bar market ;

//============ADE=======================================

vars:var5(0);

if positionprofit(1)>20000 then var5=0;
if positionprofit(1)<0 and positionprofit(2)<0 and positionprofit(3)<0  then var5=1 ;

value1=ADE.Put(var5,0,0);



->單筆賺超過2萬,讓var5=0,如連賠3次後讓var5=1 把var5值放上車



另一個有限制的策略程式

inputsengtH1(20),Length2(80);

vars:a1(0),a2(0);

vars:var1(0),var2(0),var3(0);

value1=ADE.Get(30,var1,var2,var3);

if var1=1 then begin

a1=XAverage(close,LengtH1);
a2=XAverage(close,Length2);

condition1=a1 Crosses Above a2;
condition2=a1 Crosses Under a2;

//===

if condition1=true then Buy ("Long_in" ) next bar at market ;
if condition2=true then sellshort ("short_in") next bar market ;

end;

當傳過來的值等於1才執行,就是用傳來的值判斷這個策略要不要run



最後,開兩個相同的30k圖,分別執行這兩個策略

一個就是正常策略,一個就是大賺後賠三次才進場的策略

可以跑回測看報表績效如何.

如實際交易要用這種方式就一個開自動交易(有限制的),另一個不要開(要記錄值的)



還有很多可以運用的,如20個策略但最多只想同時有10口單,或破MDD後自動停止下單,等績效回來後再開始自動下單

(這也是用兩個圖執行相同策略一個有開自動交易,一個不要開->用來記錄是否破MDD或績效又起死回升丟值控制有開自動交易的圖下單,

當然也可以做回測)

另外還有賺多少後自動做口數調整等等比較複雜的資控,大部份都可以用這種方式達成~



那兩個函數下載在 這裡



簡單的功能可以直接用,要較複雜的就不能用這個兩函數囉.



資料來源:程式交易
!qqconnect:connect_viewthread_share_title!: !qqconnect:connect_viewthread_share_to_qzone!!qqconnect:connect_viewthread_share_to_qzone! !qqconnect:connect_viewthread_share_to_weibo!!qqconnect:connect_viewthread_share_to_weibo! !qqconnect:connect_viewthread_share_to_pengyou!!qqconnect:connect_viewthread_share_to_pengyou!
LMAX 顛覆外匯交易經驗/擊敗所有外匯經紀商

返回列表