![](/img/trans.png)
[英]Pine-Script + Strategy + Pyramiding + Different TP + SL + Qty
[英]Pine script pyramiding entry
如何為下一個 position 低於/高於某個價格差異的條目編寫 pine 腳本策略? 示例:最后一次買入是 100 美元,我希望下一次買入低於 95 美元,而不是在策略給出另一個買入信號時。
strategy.opentrades
告訴您未平倉交易的數量。 您可以使用它來確定您是否有未平倉的 position,如果是,請檢查您的附加條件(95 美元)以再次執行掛單。
下面的代碼是一個簡單的例子。 對於每個新訂單,入場價格將下降。
//@version=5
strategy("My strategy", overlay=true, pyramiding = 3)
first_buy = 120
next_buy_step = 5
if (ta.crossover(close, first_buy))
strategy.entry("Long", strategy.long)
if (strategy.opentrades > 0)
if (ta.crossover(close, first_buy - (next_buy_step * strategy.opentrades)))
strategy.entry("Additional Long", strategy.long)
這是購買策略:
if ( enterOnBorderTouchFromInside and crossunder(price, bottom) ) strategy.entry("BUY", strategy.long, qty=tradeSize, comment="BUY") else if( crossover(price, bottom) ) strategy.entry("BUY" , strategy.long, qty=tradeSize, comment="BUY")
if(crossover(price,EMA) 和 closeOnEMATouch) strategy.close("BUY")
如何在此處添加代碼以查找最后入場價格並僅在價格為最后入場價格的 99% 時才進入新的金字塔交易?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.