COCO研究院

 找回密碼
 註冊
搜索
查看: 1872|回復: 2

[其他程式語言] 指定出場方式?

[複製鏈接]
發表於 15-8-18 19:16 | 顯示全部樓層 |閱讀模式
A策略:(獨立)

inputs:Strength1(4),Strength2(4);

vars:var0(false),var1(0),var2(false),var3(0),MP(0);

MP = MarketPosition ;

condition1 = SwingHigh( 1, High, Strength1, Strength1 + 1 ) <> -1 ;

if condition1 then begin

var0 = true ;

var1 = High[Strength1] ;

end else begin condition1 = var0 and High >= var1 + 1 point ;

if condition1 then var0 = false ;

end;

condition2 = SwingLow( 1, Low, Strength2, Strength2 + 1 ) <> -1 ;

if condition2 then begin

var2 = true ;

var3 = Low[Strength2] ;

end else begin

condition1 = var2 and Low <= var3 - 1 point ;

if condition1 then var2 = false ;

end;

if MP=0 and var0 then Buy ("B1") next bar at var1+1 point stop ;

if MP=0 and var2 then SellShort ("S1") next bar at var3-1 point stop ;

if MP>0 then sellshort("BL1") next bar at entryprice(0)-20 stop;

if MP<0 then buy("SL1") next bar at entryprice(0)+20 stop;

B策略:(獨立)

variables:CDP(0),AH(0),NH(0),NL(0),AL(0),MP(0);

vars:TodayHigh(high),TodayLow(low),Price1(0),Price2(0);

MP = MarketPosition ;

if time<1330 then Begin

TodayHigh = HighD(0);

TodayLow = LowD(0); end;

Price1 = TodayHigh-(TodayHigh-TodayLow)/3 ;

Price2 = TodayLow +(TodayHigh-TodayLow)/3 ;

if date<>date[1] then begin

CDP=(highD(1)+lowD(1)+2*closeD(1))/4;

AH=CDP+(highD(1)-lowD(1));

NH=CDP*2-lowD(1); NL=CDP*2-highD(1);

AL=CDP-(highD(1)-lowD(1));

end;

if MP=0 then Buy("B2") next bar at AH stop;

if MP=0 then sellshort("S2") next bar at AL stop;

if MP>0 then sellshort("BL2") next bar at Price2 stop ;

if MP<0 then buy("SL2") next bar at Price1 stop ;

A策略和B策略同時在同一個圖表一起運作(停損後反向操作)~會發生B1進場後不以BL1出場,反而以BL2出場,或S2進場後不以SL2出場,反而以SL1出場~我想要B1進場後就以BL1出場~S2進場後就以SL2出場~要怎麼修正呢?謝謝!!
發表於 15-8-18 20:43 | 顯示全部樓層
本帖最後由 沒房子的阿捨 於 15-8-18 20:45 編輯

幫你爬文了...............
http://www.coco-in.net/forum.php?mod=viewthread&tid=41301&page=1#pid661662

 樓主| 發表於 15-8-19 09:56 | 顯示全部樓層
沒房子的阿捨 發表於 15-8-18 20:43
幫你爬文了...............
http://www.coco-in.net/forum.php?mod=viewthread&tid=41301&page=1#pid661662 ...

感謝你的爬文!但如果是要寫在同一個訊號檔案內要怎麼寫?
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-4-26 05:59

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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