1

很直接。我只想在thinkscript中打印。如果这个问题表明我通过提出这个问题而错过了 thinkscript 的一个关键元素,请也告诉我。

4

2 回答 2

1

使用这样的东西:AddLabel(yes, if close > 0 then "whatyouwanttoprint"

于 2021-03-08T15:18:37.870 回答
0
  • 如果您询问如何实际打印出脚本的代码:我能找到的最好的方法是将代码复制到另一个编辑器中并从那里打印。

  • 如果您正在寻找用于调试目的的输出方法,例如,@Mteam888 的答案AddLabel是一种方法。另一个是AddChartBubble

#hint: Demonstrates adding a chart bubble at a given bar number and a label showing the last (most recent) bar number.\nNote: bar[0] is the rightmost, or most recent, bar. It is actually n bars from the leftmost side of the chart;\nbar[1] is one bar left of bar[0], and bar[2] is 2 bars left of bar 0.\nThis example also shows no plot is required in this case.

def isLastBar = !IsNaN(close) and IsNaN(close[-1]);
def lastBarNum = if isLastBar then BarNumber() else 0;

AddChartBubble( "time condition"=(BarNumber() == 15), "price location"=high, text="BarNumber" + BarNumber(), color=Color.YELLOW);
AddChartBubble( "time condition"=(BarNumber() == 30), "price location"=high, text="BarNumber" + BarNumber(), color=Color.YELLOW);
AddChartBubble( "time condition"=(BarNumber() == 45), "price location"=high, text="BarNumber" + BarNumber(), color=Color.YELLOW);


AddLabel(visible=isLastBar, text="bar[0] (rightmost): " + lastBarNum, color=Color.GREEN);
AddLabel(visible=isLastBar, text="bar[1]: " + (lastBarNum - 1), color=Color.YELLOW);
AddLabel(visible=isLastBar, text="bar[2]: " + (lastBarNum - 2), color=Color.ORANGE);


#plot Data = close;  #plot is not required if only adding labels/chart bubbles

于 2021-03-22T01:32:57.717 回答