![如何在K線圖上繪製進出場訊號?](/wp-content/uploads/2016/04/8-006.png)
![indicator35](/wp-content/uploads/2016/04/indicator35.png)
variable: intrabarpersist position_1(0); // 目前position variable: intrabarpersist entry_price(0); // 最後一次進場的價格 //進場邏輯 // condition1 = close crosses above average(close, 5); // 出場邏輯 // condition2 = close crosses below average(close, 5); if position_1= 0 then begin if condition1 then begin position_1= 1; entry_price = close; print("(ENTRY) Date:", Date, " EntryPrice:", entry_price); plot1(low * 0.98, "entry"); end; end else begin if condition2 then begin position_1= 0; entry_price = 0; print("(EXIT) Date:", Date); plot2(high * 1.02, "exit"); end; end;由於今天的主題是說明怎麼樣在圖上顯示進出場點,所以千萬不要問小編這個策略會不會賺錢......不過如果有人對腳本內容有興趣,可以寫信給我們,這樣小編又可以多寫一篇文章。在這個腳本中,我們把進場訊號的點位存在plot1,出場訊號的點位存在plot2。直接疊加到主圖上,畫面是這個樣子。
![indicator36](/wp-content/uploads/2016/04/indicator36.png)
![indicator38](/wp-content/uploads/2016/04/indicator38.png)
![](/wp-content/uploads/2016/04/1.png)
![](/wp-content/uploads/2016/04/2.png)
![indicator35](/wp-content/uploads/2016/04/indicator35.png)