Debugging 如何在ThinkOrSwim平台中逐步完成thinkscript?
我正在ThinkOrSwim平台上玩ThinkScript代码。专门在MacOSX上运行此工具。我想知道是否有一种调试ThinkScript的方法,就像您附加一个调试器并逐行调试脚本一样。没有内置调试器。但是,在编写自定义研究时,您可以使用addchartbubble()函数在每个栏上显示变量的值。如所述,thinkScript没有调试器工具。您可以按照Gary的建议使用图表气泡,以及图表标签 当满足条件时,显示在指定栏上。满足条件时显示在图表的左上角Debugging 如何在ThinkOrSwim平台中逐步完成thinkscript?,debugging,thinkscript,Debugging,Thinkscript,我正在ThinkOrSwim平台上玩ThinkScript代码。专门在MacOSX上运行此工具。我想知道是否有一种调试ThinkScript的方法,就像您附加一个调试器并逐行调试脚本一样。没有内置调试器。但是,在编写自定义研究时,您可以使用addchartbubble()函数在每个栏上显示变量的值。如所述,thinkScript没有调试器工具。您可以按照Gary的建议使用图表气泡,以及图表标签 当满足条件时,显示在指定栏上。满足条件时显示在图表的左上角 语法 注: 带有空格的参数标签需要双引
语法 注:
- 带有空格的参数标签需要双引号;没有空格的不需要引号
- 如果提供了所有必需的参数,并且这些参数符合预期顺序,则不需要参数标签。为了清晰起见,我在这个语法描述中展示了它们
- 参数不必出现在单独的行上。同样,为了清晰起见,我在这个语法描述中已经这样做了,因此我可以对参数的含义进行注释
#提示:…
在您单击选择列表中的问号时显示代码的“帮助者”消息。此外,提示文本中的\n
会在该点放置一个“换行符”
示例代码:
#hint: Counts a value using an if statement, recursive variable type statement, and a CompoundValue statement.\nDemonstrates using chart bubbles and labels for debugging.
def TrueRange;
if BarNumber() == 1 {
TrueRange = ATR(14)[1];
} else {
TrueRange = TrueRange[1];
}
def tr_rec = if BarNumber() == 1 then tr_rec[1] + 1 else tr_rec[1];
def tr_cmpd = CompoundValue(1, if BarNumber() == 1 then ATR(14)[1] else tr_cmpd[1], Double.NaN);
# plot Data = close; # not req'd if doing only labels and/or bubbles
def numBars = HighestAll(BarNumber());
def halfwayBar = numBars / 2;
# bubble to test a value
AddChartBubble("time condition"=BarNumber() == halfwayBar,
"price location"=high,
text="Bar Number " + BarNumber() + "\n is the halfwayBar (" + halfwayBar + ")",
color=Color.YELLOW,
up=no);
# labels to test values
AddLabel(yes, "# Bars on Chart: " + numBars, Color.YELLOW);
AddLabel(yes, "TrueRange @ bar 1: " + GetValue(TrueRange, numBars - 1), Color.ORANGE);
AddLabel(yes, "TrueRange @ bar " + numBars + ": " + TrueRange, Color.ORANGE);
AddLabel(yes, "tr_rec @ bar 1: " + GetValue(tr_rec, numBars - 1), Color.LIGHT_ORANGE);
AddLabel(yes, "tr_rec @ bar " + numBars + ": " + tr_rec, Color.LIGHT_ORANGE);
AddLabel(yes, "tr_cmpd @ bar 1: " + GetValue(tr_cmpd, numBars - 1), Color.LIGHT_GREEN);
AddLabel(yes, "tr_cmpd @ bar " + numBars + ": " + tr_cmpd, Color.LIGHT_GREEN);
AddLabel(visible, # condition defining whether the label should appear; yes means always
text, # text to display in label
color # label color
);
#hint: Counts a value using an if statement, recursive variable type statement, and a CompoundValue statement.\nDemonstrates using chart bubbles and labels for debugging.
def TrueRange;
if BarNumber() == 1 {
TrueRange = ATR(14)[1];
} else {
TrueRange = TrueRange[1];
}
def tr_rec = if BarNumber() == 1 then tr_rec[1] + 1 else tr_rec[1];
def tr_cmpd = CompoundValue(1, if BarNumber() == 1 then ATR(14)[1] else tr_cmpd[1], Double.NaN);
# plot Data = close; # not req'd if doing only labels and/or bubbles
def numBars = HighestAll(BarNumber());
def halfwayBar = numBars / 2;
# bubble to test a value
AddChartBubble("time condition"=BarNumber() == halfwayBar,
"price location"=high,
text="Bar Number " + BarNumber() + "\n is the halfwayBar (" + halfwayBar + ")",
color=Color.YELLOW,
up=no);
# labels to test values
AddLabel(yes, "# Bars on Chart: " + numBars, Color.YELLOW);
AddLabel(yes, "TrueRange @ bar 1: " + GetValue(TrueRange, numBars - 1), Color.ORANGE);
AddLabel(yes, "TrueRange @ bar " + numBars + ": " + TrueRange, Color.ORANGE);
AddLabel(yes, "tr_rec @ bar 1: " + GetValue(tr_rec, numBars - 1), Color.LIGHT_ORANGE);
AddLabel(yes, "tr_rec @ bar " + numBars + ": " + tr_rec, Color.LIGHT_ORANGE);
AddLabel(yes, "tr_cmpd @ bar 1: " + GetValue(tr_cmpd, numBars - 1), Color.LIGHT_GREEN);
AddLabel(yes, "tr_cmpd @ bar " + numBars + ": " + tr_cmpd, Color.LIGHT_GREEN);