pine script - pineScript to thinkScript - request - Stack Overflow

I want to conver the pivot point Supertrend indicator to ThinkScript- but I am unable to ;====I conve

I want to conver the pivot point Supertrend indicator to ThinkScript- but I am unable to ;

==== I converted the pineScript to ThinkScript - but its not work; and as far as I could debug issue is with "TUp" and "TDown"

declare lower;

input ATRPeriod = 10;
input ATRFactor = 3;
input PivotPointPeriod = 2;
input showLabels = yes;

def ATR = Average(TrueRange(high, close, low), ATRPeriod);
def ph = if high == Highest(high, PivotPointPeriod * 2 + 1) then high else Double.NaN;
def pl = if low == Lowest(low, PivotPointPeriod * 2 + 1) then low else Double.NaN;

rec center = if !IsNaN(ph) then ph else if !IsNaN(pl) then pl else center[1];

def UpperBand = center - ATRFactor * ATR;
def LowerBand = center + ATRFactor * ATR;

rec TUp = if close[1] > TUp[1] then Max(UpperBand, TUp[1]) else UpperBand;
rec TDown = if close[1] < TDown[1] then Min(LowerBand, TDown[1]) else LowerBand;

def Trend = if close > TDown[1] then 1 else if close < TUp[1] then -1 else Trend[1];
def TrailSL = if Trend == 1 then TUp else TDown;

plot SuperTrend = TrailSL;
SuperTrend.SetDefaultColor(GetColor(1));
SuperTrend.SetLineWeight(2);

# Plot Buy/Sell signals
def BuySignal = Trend == 1 and Trend[1] == -1;
def SellSignal = Trend == -1 and Trend[1] == 1;

AddChartBubble(showLabels and BuySignal, low, "Buy", Color.GREEN, no);
AddChartBubble(showLabels and SellSignal, high, "Sell", Color.RED, yes);

# Alerts for buy/sell
Alert(BuySignal, "Buy Signal", Alert.BAR, Sound.Chime);
Alert(SellSignal, "Sell Signal", Alert.BAR, Sound.Bell);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745639785a4637619.html

相关推荐

  • pine script - pineScript to thinkScript - request - Stack Overflow

    I want to conver the pivot point Supertrend indicator to ThinkScript- but I am unable to ;====I conve

    22天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信