COCO研究院

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

[其他程式語言] 請問如何圖表標記訊號名稱

[複製鏈接]
發表於 18-12-25 09:29 | 顯示全部樓層 |閱讀模式
假設MC我有一個訊號策略的進場語法如下

A段
if X1<=100 then  SellShort 1 contracts next bar at Y2 limit else
buy 1 contracts next bar at Y2 limit;

B段
if x1>100 and X1<500 then  SellShort 1 contracts next bar at Y2 limit else
buy 1 contracts next bar at Y2 limit;
C段
if x1>=500and X1<1000 then  SellShort 1 contracts next bar at Y2 limit else
buy 1 contracts next bar at Y2 limit;

D段
if x1>=1000 then  SellShort 1 contracts next bar at Y2 limit else
buy 1 contracts next bar at Y2 limit;



上述ABCD4段,請問我要怎麼在圖表上顯示說,我今天進場做的單,是因為哪一段觸發才下單的(策略開發初期,所以要確定說訊號有沒有跑錯段)。


懇請大神協助,感謝~


發表於 18-12-26 21:09 | 顯示全部樓層

好寫作架構,容易比較能找出邏輯上的失誤

所有的 else 混亂重疊在一起...

A段
if X1<=100 then  
  SellShort 1 contracts next bar at Y2 limit
else  // 100 < X1
  buy 1 contracts next bar at Y2 limit;


B段
if 100 < X1 and X1< 500 then  
  SellShort 1 contracts next bar at Y2 limit
else  // X1 <= 100 or 500 <= X1
  buy 1 contracts next bar at Y2 limit;



C段
if 500 <= X1 and X1<1000 then  
  SellShort 1 contracts next bar at Y2 limit
else  // X1 < 500 or  1000 <= X1
  buy 1 contracts next bar at Y2 limit;


if x1>=1000 then  
  SellShort 1 contracts next bar at Y2 limit
else  // X1 < 1000
  buy 1 contracts next bar at Y2 limit;






回復 支持 1 反對 0

使用道具 舉報

發表於 18-12-25 21:53 | 顯示全部樓層
如果不論4段於程式內的寫法安排,條件X1前後邏輯...等,只要幫它取個名字,因某條件觸發成交後,便會在圖上顯示出該條件對應名稱,例如:
A段
if X1<=100 then  SellShort ("SA") 1 contracts next bar at Y2 limit else
buy ("BA") 1 contracts next bar at Y2 limit;

B段
if x1>100 and X1<500 then  SellShort ("SB") 1 contracts next bar at Y2 limit else
buy ("BB") 1 contracts next bar at Y2 limit;
C段
if x1>=500and X1<1000 then  SellShort ("SC") 1 contracts next bar at Y2 limit else
buy ("BC") 1 contracts next bar at Y2 limit;

D段
if x1>=1000 then  SellShort  ("SD") 1 contracts next bar at Y2 limit else
buy ("BD") 1 contracts next bar at Y2 limit;
 樓主| 發表於 18-12-26 09:09 | 顯示全部樓層
DanielShih 發表於 18-12-25 21:53
如果不論4段於程式內的寫法安排,條件X1前後邏輯...等,只要幫它取個名字,因某條件觸發成交後,便會在圖上 ...

原來這麼簡單,感謝您的指點迷津,
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-4-27 00:28

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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