如何在thinkscript中输出/打印?

时间:2019-10-04 05:49:15

标签: thinkscript

挺直的。我只想用thinkscript打印。如果这个问题表明我通过询问而错过了思考脚本的关键要素,请也让我知道。

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

  • 如果您要问如何实际打印出脚本的代码:我能找到的最好方法是将代码复制到另一个编辑器并从那里打印。

  • 如果您正在寻找出于调试目的的输出方式,例如,@Mteam888's answerAddLabel 是一种方式。另一个是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