简体   繁体   中英

pine script error - script could not be translated from: null

My pine code (simple trading bot) is not compiling and returns the error in Tradeviews editor "Script could not be translated from: null".

I tried to compile part by part, and researched online, but failed.

Can somebody help?

Much appreciated, Thx, Denis


if (consolidatingMarket(consolidationPeriod, consolidationThreshold))
{
if (breakoutDetected(breakoutThreshold))
{
enterLong()
}
}
else
{
exit()
}

study(title="Consolidating Market")
plot(consolidatingMarket(consolidationPeriod, consolidationThreshold))

function consolidatingMarket(period, threshold)
{
var avgRange = sma(range, period)
return range \<= avgRange \* threshold
}

study(title="Breakout Detected")
plot(breakoutDetected(breakoutThreshold))

function breakoutDetected(threshold)
{
var period = consolidationPeriod
var avgRange = sma(range, period)
return range \>= avgRange \* threshold
}

function enterLong()
{
var stopLossPrice = entryPrice \* (1 - stopLoss/100)
var takeProfitPrice = entryPrice \* (1 + takeProfit/100)
strategy.entry("Long", strategy.long, stop_loss=stopLossPrice, take_profit=takeProfitPrice)
}

function exit()
{
strategy.close()
}

You should start reading the pinescript manual. Your code is NOT in pinescript langage.
Read at least on time this User Manual and look how the examples are made: https://www.tradingview.com/pine-script-docs/en/v5/index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM