
各位老師大家好
剛開始使用模擬交易 遇到一些問題 想請問版上前輩解答
附件是我異常的截圖 請問我的設定上是哪裡出現問題嗎? 爬了文找不到答案
謝謝
你需要先到執行記錄分頁查看異常的原因。

謝謝教授回復
如照片顯示 請問可能是哪裡出了問題嗎?
你程式沒寫好,已經沒有庫存,卻一直下平倉單,最後造成系統罷工。
用position來控制,平倉時,讓position<>0才可下平倉單。
謝謝教授回復 我來修改看看 感恩
教授你好 可以麻煩幫我看一次是不是這樣子修改嗎?非常感謝
// 宣告參數
input: MaxPrice(50, "最高股價"),
MaxCapital(50, "最大股本(億元)"),
HighDay(120, "創N日新高"),
VolumeRatio(1, "成交量比"),
StopLoss(5, "停損百分比"),
TakeProfit(5, "停利百分比"),
HoldDays(2, "持有天數");
// 設定變數
var: EntryPrice1(0), EntryBar(0);
// 資料讀取筆數設定
settotalbar(HighDay);
setbarback(HighDay);
// 定義進場條件
condition1 = Close <= MaxPrice; // 收盤價小於50
condition2 = GetField("股本(億)") <= MaxCapital; // 股本小於50億
condition3 = Close = Highest(High, 1); // 目前是最高價
condition4 = Close > Highest(Close[1], HighDay); // 股價創120日新高
condition5 = Volume > Average(Volume, 5) * VolumeRatio; // 成交量大於前5日均量1倍
// 進場邏輯
if position = 0 and condition1 and condition2 and condition3 and condition4 and condition5 then
begin
EntryPrice1 = Close;
EntryBar = CurrentBar;
setposition(1, market, label:="進場");
end;
// 出場邏輯
if position <> 0 then
begin
// 停損
if Close <= EntryPrice1 * (1 - StopLoss / 100) then
setposition(0, market, label:="停損");
// 停利
if Close >= EntryPrice1 * (1 + TakeProfit / 100) then
setposition(0, market, label:="停利");
// 持有時間到
if CurrentBar >= EntryBar + HoldDays then
setposition(0, market, label:="持有時間到");
end;

7 評論