1

我试图计算如果一只股票在开盘时上涨 0.05 的概率,它会上涨 0.50 的概率是多少?遇到一些小问题。

这个想法来自外汇交易员“TheRumpledOne”。他称之为“购买区”。如果你不认识他,就去看看他。把它想象成一个基于概率的开局范围。

加载代码后,您可以看到数字不应超过“barsago”长度。

编辑:想通了。在代码中添加了“上面的交叉”。虽然必须有更好的、“更清洁”的方式?还在这部分代码中添加了“...var and...”,如果确实需要,请注意。

def countsells = Sum( var and var1, barsago);

编辑2: 这是我当前的问题。 其他的事情还没有结束。数字似乎不对。现在他们看起来很低。我预计一些股票会在超过 70% 的时间内开盘 + 0.50,但这个指标的说法不同。

# (Probabilty of XYZ FROM THE LAST / PAST XYZ BARS )
# Original/base code By XeoNoX via Usethinkscript.com
# Idea by TheRumpledOne
# By Prison Mike
input barsago = 100;
input buy= .05;
def buyzone= (open + buy);
def var = close crosses above buyzone;
def count = Sum(var, barsago);
AddLabel (yes, "COUNT " +  (count)  );
def pct= round(count/barsago)*100;
AddLabel (yes, "BuyZone " +  (pct)  );

input Sell= .50;
def sellzone= (open + sell);
def var1 =close crosses above  sellzone;
def countsells = Sum(var and var1, barsago);
AddLabel (yes, "COUNT " +  (countsells)  );
def pct2=round (countsells/barsago)*100;
AddLabel (yes, "SellZone " +  (pct2)  );
4

1 回答 1

0

修改:它计算显示图表中有多少条柱(注意:TheRumpledOne 的算法是为日内交易设计的)。在开盘价上涨 5 美分的地方,它会在价格图表上放置一个橙色向上箭头;它在价格上涨 50 美分的地方放置一个绿色箭头。然后它显示带有计数、百分比和highestBar用于计算百分比值的条数(值)的标签。

而且,我同意:在 AAPL 图表上,计算大约 360 个 15 分钟的柱,我得到略高于 30% 的 5 美分,只有大约 3% 上涨了 50 美分。那是酒吧的总数;但是,当我添加仅计算销售百分比的部分时,我仍然只得到大约 8%。与TheRumpledOne 的 Stockfetcher 帖子中建议的数字相去甚远。

注意:我用来测试的图表包括非工作时间柱。也许如果我排除非工作时间,数字会更好看?考虑到我在哪里得到箭头,我不这么认为......

这是修改后的脚本:

#hint: from SO: https://stackoverflow.com/q/66232117/1107226\nThinkscript Probabilty Statistics Study- Need help finishing

def highestBar = HighestAll(BarNumber());

### buy zone ###
input buy = .05;
def buyzone = (open + buy);
plot hitBuyZone = close >= buyzone;
hitBuyZone.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
hitBuyZone.setDefaultColor( Color.ORANGE );

def count = if hitBuyZone then count[1] + 1 else count[1];
AddLabel (yes, " BUY COUNT: " + count + " ", Color.YELLOW );
def pct = Round(count / highestBar) * 100;
AddLabel (yes, " BuyZone %: " + (pct) + " ", Color.YELLOW );

### sell zone ###
input Sell = .50;
def sellzone = (open + Sell);
plot hitSellZone = close >= sellzone;
hitSellZone.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
hitSellZone.SetDefaultColor( Color.GREEN );

def countsells = if hitSellZone then countsells[1] + 1 else countsells[1];
AddLabel (yes, " SELL COUNT: " +  (countsells) + " ", Color.YELLOW );
def pct2 = Round (countsells / highestBar) * 100;
AddLabel (yes, " SellZone %: " +  (pct2) + " ", Color.YELLOW );

### percent of buy count that made it to the full buyzone cents ###
def pctOfBuyCount = Round (countsells / count) * 100;
AddLabel (yes, " Buy Count % of Sell Count: " +  (pctOfBuyCount) + " ", Color.YELLOW );

### show bar count ###
AddLabel(BarNumber() == highestBar, " Bars Counted for %: " + BarNumber() + " ", Color.ORANGE);

于 2021-03-24T19:05:00.570 回答