期貨期權交流具有取得加倉信息的barssinceentry函數 [MC]
- 咨詢內容:
mc內置的barssinceentry是無法取得加倉信息的 比如加倉兩次 我想取得最后一次加倉到當根bar的bar數量 這個無法取得
不過easy language 強大的功能 讓我們有自己發揮的空間
這個函數編好后 ,以后在寫信號腳本的時候就可以直接調用過來 根據自己的要求輸入參數即可
函數說明 :
1:這個函數的參數有三個marketpositionvalue, currententries1, times;
其中marketpositionvalue參數就代表marketposition;
currententries1代表currententries;
times 取0 代表 取未平倉部位的第一次進場至今bar數,取1 ,代表取最近一次加倉至今bar數 ,取2 ,代表取次近一次加倉、、、、
2:這個函數沒有像barsinentry(1)或barsinentry(2) 這種取已經平倉部位信息的功能,如果需要 可以在原腳本的基礎上改變稍微復雜一點 , 但考慮到實際 ,我們實盤很少考慮比如,上上次已經平倉部位的第二次加倉至今的bar數 ,至少我本人沒試過,,所以意義不大;
3 我定義的加倉 currententries>currententries[1 ] and currententries[1]>0;
4
寫信號腳本引用時 注意寫法
value1=marketposition;
value2=currententries;
times自己選0,1,2、、、、根據自己想要的
value3=myentrybar(value1,value2,times);
- MC技術部:
本帖最后由 sadrick 于 2015-7-24 16:57 編輯
一會發函數源碼
input:marketpositionvalue(NumericSeries),currententries1(NumericSeries),times(NumericSimple);
if marketpositionvalue<>marketpositionvalue[1] and marketpositionvalue<>0 then
value1=currentbar;
if times=0 then
begin
if currententries1>=1 then
myentrybar=currentbar-value1
else
myentrybar=0;
end;
if times>=1 then
begin
if currententries1>=2 then
begin
if times>currententries1-1 then
value3=currententries1-1
else
value3=times;
myentrybar=mro(currententries1>currententries1[1] and currententries1[1]>0,currentbar-value1,value3);
end;
if currententries1<=1 then
myentrybar=0;
end;//
mc 有個不好的地方就是要設定策略的最大參考bar 如果少了會報錯 但我么那怎么知道事先由幾個bar要參考到呢
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 511411198 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容