繁体   English   中英

松脚本金字塔入口

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM