COCO研究院

 找回密碼
 註冊
搜索
查看: 2685|回復: 3

語法求助

[複製鏈接]
發表於 18-12-5 21:01 | 顯示全部樓層 |閱讀模式
本帖最後由 awind72 於 18-12-5 21:07 編輯

if time>=0900 and time<=1343 then begin
if Z1>Y2 and x1>=0 then SellShort 1 contracts next bar at Y2 limit;-------A
if Z1>Y2 and x1<0 then buy 1 contracts next bar at Y2 limit;-------------B
if Z1>Y2 and x1<0and (X5-X2)>=0 and (X3-X5)>=0
then SellShort 1 contracts next bar at Y2 limit;-----------------------C
if Z1<Y2 then SellShort 1 contracts next bar at Y2+15 limit;-----------D
end;
if time >1343 then begin
if marketposition >0 then
sell all contract next bar at market
else if marketposition <0 then
buytocover all contract next bar at market;
end;

我是用分K,上述A,B,C,D四個進場訊號,如何才能符合條件下過一次單之後,該小段訊號今日就停止
例如A訊號符合後下單,然後A段訊號就忽略不跑,B,C,D繼續跑,直到各別訊號符合後該段忽略
請各位大神指教,謝謝

發表於 18-12-6 11:16 | 顯示全部樓層
最簡單的最笨的方法就是ABCD都各給一個flag
下過單就true,還沒下就false
每天早上開盤全部設定成false

底下範例只寫針對a的 以此類推

var:flag_a(false);

//每日開盤重置
if date[0]<>date[1] then begin
flag_a=false;
end;

if time>=0900 and time<=1343 then begin

if Z1>Y2 and x1>=0 and flag_a=false then begin
SellShort 1 contracts next bar at Y2 limit;-------A
flag_a = true;
end;
end;
發表於 18-12-7 10:10 | 顯示全部樓層
樓上的方法也是我常用的寫法,會比較好控制進出
發表於 21-8-6 13:44 | 顯示全部樓層
謝謝大大的分享,
分四種情況下單 當沖的策略
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-4-24 19:06

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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