Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pine script 使用Pinescript根据时间延迟(或文字时钟时间)声明变量_Pine Script - Fatal编程技术网

Pine script 使用Pinescript根据时间延迟(或文字时钟时间)声明变量

Pine script 使用Pinescript根据时间延迟(或文字时钟时间)声明变量,pine-script,Pine Script,Preword——这是一个脚本的摘录,用户为metatrader和tradingview设计了“tradeconnector”浏览器扩展,因此警报消息中有与该语法语言相关的代码,但包含传递的动态绘图变量 我举了一个例子来说明我正在编写的风险管理类型,即这不需要执行策略,可以是或。我有一个交易id计数器,能够从我最终选择的指标中部分平仓,动态止损水平,但如果你仔细检查,你会发现这一切都是基于一个初始进场警报,即一个出价一张票。在tradingview中,我一直在艰难地学习如何处理金字塔和阶梯,我特

Preword——这是一个脚本的摘录,用户为metatrader和tradingview设计了“tradeconnector”浏览器扩展,因此警报消息中有与该语法语言相关的代码,但包含传递的动态绘图变量

我举了一个例子来说明我正在编写的风险管理类型,即这不需要执行策略,可以是或。我有一个交易id计数器,能够从我最终选择的指标中部分平仓,动态止损水平,但如果你仔细检查,你会发现这一切都是基于一个初始进场警报,即一个出价一张票。在tradingview中,我一直在艰难地学习如何处理金字塔和阶梯,我特别想做的是根据时间延迟将阶梯过程延迟到一篮子出价中

我提到了贸易id计数器,因为我想也许我可以制作一个计数器来跟踪蜡烛计数器,使用一系列蜡烛计数来进行每次出价。这是一种策略,当然在脚本中有文字时间代码和日期函数

但我真正需要的是,每隔x分钟或几秒钟,每次经过一段时间,或者在每次延迟后声明一个变量/新警报,以获得更安全的阶梯策略。使用策略而不是研究,您可以启用金字塔,并让它在每次调用strategy.entry时发出警报,每行都会收到一个新变量(基于新策略警报)

有没有人在pinescript中有这样的例子? ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

if GoLong 
    stoploss_long := low<pl ? low : pl
if GoShort 
    stoploss_short := high>ph ? high : ph
// } End of Pivot-points and stop-loss logic


  // **** Trade counter and partial closing mechanism **** {
    var int trade_id=0
    if GoLong or GoShort
        trade_id:=trade_id+1



   TakePartialProfitLong = barssince(GoLong)<barssince(GoShort) and crossover(high,(valuewhen(GoLong,close,0)+TakePartialProfitLevel*syminfo.mintick))
   TakePartialProfitShort = barssince(GoLong)>barssince(GoShort) and crossunder(low,(valuewhen(GoShort,close,0)-TakePartialProfitLevel*syminfo.mintick))
    // } End of Trade counter and partial closing mechanism
    


  //strategy.entry("Long", strategy.long, when=GoLong)
  //strategy.exit("XPartLong", from_entry="Long", qty_percent=50, profit=TakePartialProfitLevel)
  //strategy.exit("XLong", from_entry="Long", stop=stoploss_long, profit=TakeProfitLevel)
  //strategy.entry("Short", strategy.short, when=GoShort)
  //strategy.exit("XPartShort", from_entry="Short", qty_percent=50, profit=TakePartialProfitLevel)
  //strategy.exit("XShort", from_entry="Short", stop=stoploss_short, profit=TakeProfitLevel)



  plot_stoploss_long=plot(stoploss_long, title="SLLong", color=na)
  plot_stoploss_short=plot(stoploss_short, title="SLShort", color=na)
  plot_trade_id=plot(trade_id, title="Trade_id", color=na)
  plot_tp_level=plot(TakeProfitLevel, title="TakeProfitLevel", color=na)
    // //defining plots above are required only for the purpose of passing dynamic variables to alerts. Their color is set to 'na' so that they don't display on the screen.

 alertcondition(GoLong, title='Long', message='long slprice={{plot("SLLong")}} tradeid={{plot("Trade_id")}} tp={{plot("TakeProfitLevel")}}')
 alertcondition(GoShort, title='Short', message='short slprice={{plot("SLShort")}} tradeid={{plot("Trade_id")}} tp={{plot("TakeProfitLevel")}}')
 alertcondition(TakePartialProfitLong, title='ClosePartLong', message='closepart tradeid={{plot("Trade_id")}} part=0.5')
 alertcondition(TakePartialProfitShort, title='ClosePartShort', message='closepart tradeid={{plot("Trade_id")}} part=0.5')
if GoLong
止损长:=低pH值?高:ph
//}轴心点结束和停止损失逻辑
//****交易柜台和部分关闭机构****{
var int trade_id=0
如果是GoLong或GoShort
交易id:=交易id+1
TakePartialProfitLong=巴朗(GoLong)巴朗(GoShort)和交叉(low,(valuewhen(GoShort,close,0)-TakePartialProfitLong级别*符号信息.mintick))
//}交易结束柜台和部分关闭机制
//strategy.entry(“Long”,strategy.Long,when=GoLong)
//策略.退出(“XPartLong”,from_entry=“Long”,数量百分比=50,利润=TakePartialProfitLevel)
//策略.退出(“XLong”,from_entry=“Long”,止损=止损\u Long,利润=盈利水平)
//strategy.entry(“Short”,strategy.Short,when=GoShort)
//策略.退出(“XPartShort”,from_entry=“Short”,数量百分比=50,利润=TakePartialProfitLevel)
//策略.exit(“XShort”,from_entry=“Short”,stop=stoploss_Short,profit=takeprofittlevel)
plot_stoploss_long=plot(stoploss_long,title=“SLLong”,color=na)
plot\u stoploss\u short=plot(stoploss\u short,title=“SLShort”,color=na)
plot\u trade\u id=plot(trade\u id,title=“trade\u id”,color=na)
plot_tp_level=plot(TakeProfitLevel,title=“TakeProfitLevel”,color=na)
////仅当向警报传递动态变量时,才需要定义上述绘图。它们的颜色设置为“na”,这样它们就不会显示在屏幕上。
alertcondition(GoLong,title='Long',message='Long slprice={{plot(“SLLong”)}}tradeid={{plot(“Trade_id”)}}}tp={{plot(“TakeProfitLevel”)}}
alertcondition(GoShort,title='Short',message='Short-slprice={{plot(“SLShort”)}}tradeid={{plot(“Trade_id”)}}tp={{plot(“TakeProfitLevel”)}}
警报条件(TakePartialProfitLong,title='ClosePartLong',message='closeparttradeid={{plot(“Trade_id”)}}part=0.5')
警报条件(TakePartialProfitShort,title='ClosePartShort',message='closeparttradeid={{plot(“Trade_id”)}}part=0.5')
///////////////////////////////////////////////////////////////////////////////////////////////////////

来源——我相信这可能涉及到这些方面的问题,我刚刚了解到这些函数的存在计算两条线的关闭时间之间的分钟时差=(time_close-time_close[5])/60000
if GoLong 
    stoploss_long := low<pl ? low : pl
if GoShort 
    stoploss_short := high>ph ? high : ph
// } End of Pivot-points and stop-loss logic


  // **** Trade counter and partial closing mechanism **** {
    var int trade_id=0
    if GoLong or GoShort
        trade_id:=trade_id+1



   TakePartialProfitLong = barssince(GoLong)<barssince(GoShort) and crossover(high,(valuewhen(GoLong,close,0)+TakePartialProfitLevel*syminfo.mintick))
   TakePartialProfitShort = barssince(GoLong)>barssince(GoShort) and crossunder(low,(valuewhen(GoShort,close,0)-TakePartialProfitLevel*syminfo.mintick))
    // } End of Trade counter and partial closing mechanism
    


  //strategy.entry("Long", strategy.long, when=GoLong)
  //strategy.exit("XPartLong", from_entry="Long", qty_percent=50, profit=TakePartialProfitLevel)
  //strategy.exit("XLong", from_entry="Long", stop=stoploss_long, profit=TakeProfitLevel)
  //strategy.entry("Short", strategy.short, when=GoShort)
  //strategy.exit("XPartShort", from_entry="Short", qty_percent=50, profit=TakePartialProfitLevel)
  //strategy.exit("XShort", from_entry="Short", stop=stoploss_short, profit=TakeProfitLevel)



  plot_stoploss_long=plot(stoploss_long, title="SLLong", color=na)
  plot_stoploss_short=plot(stoploss_short, title="SLShort", color=na)
  plot_trade_id=plot(trade_id, title="Trade_id", color=na)
  plot_tp_level=plot(TakeProfitLevel, title="TakeProfitLevel", color=na)
    // //defining plots above are required only for the purpose of passing dynamic variables to alerts. Their color is set to 'na' so that they don't display on the screen.

 alertcondition(GoLong, title='Long', message='long slprice={{plot("SLLong")}} tradeid={{plot("Trade_id")}} tp={{plot("TakeProfitLevel")}}')
 alertcondition(GoShort, title='Short', message='short slprice={{plot("SLShort")}} tradeid={{plot("Trade_id")}} tp={{plot("TakeProfitLevel")}}')
 alertcondition(TakePartialProfitLong, title='ClosePartLong', message='closepart tradeid={{plot("Trade_id")}} part=0.5')
 alertcondition(TakePartialProfitShort, title='ClosePartShort', message='closepart tradeid={{plot("Trade_id")}} part=0.5')