//@version=5
indicator("price of Apple")
apple_price = request.security("AAPL", "D", close)
plot(apple_price)
//@version=5
indicator("Forex Sessions", overlay=true)
Tokyo = time(timeframe.period, "0000-0800")
London = time(timeframe.period, "0700-1500")
NY = time(timeframe.period, "1200-2000")
bgcolor(na(Tokyo) ? na : color.fuchsia)
bgcolor(na(London) ? na : color.blue)
bgcolor(na(NY) ? na : color.green)
str.contains() //区分大小写
str.contains(syminfo.description, "QQQ")
str.startswith()
str.endswith(syminfo.ticker, "GBP")
str.length()
if syminfo.description == ""
label.new(bar_index, high, "The instrument has no description!")
barstate.islastconfirmedhistory
StrContains(string source, string substring) =>
str.contains(str.lower(source), str.lower(substring))
StrRemovePrefix(string source, string prefix, ignoreCase=false) =>
sourceStr = ignoreCase ? str.lower(source) : source
prefixStr = ignoreCase ? str.lower(prefix) : prefix
if str.startswith(sourceStr, prefixStr)
str.substring(source, str.length(prefix))
else
source
//returns "0.10" for a stock that quotes in two decimals, and "0.10000" for currency pairs whose price uses 5 decimal digits.
str.tostring(0.1, format.mintick)
labelText = syminfo.description +
"\nLast price: " + str.tostring(close, "#,###.00") +
"\nAverage price: " + str.tostring(emaValue, format.mintick) +
"\nDifference: " + str.tostring(priceDiff, "0.00%")
//@version=5
strategy(title="My Strategy", overlay=true, pyramiding=10,
default_qty_type=strategy.cash, default_qty_value=7500,
margin_long=100, margin_short=100,
initial_capital=25000, currency=currency.EUR,
backtest_fill_limits_assumption=2, slippage=1,
commission_type=strategy.commission.cash_per_order, commission_value=2,
max_lines_count=500, max_labels_count=500, max_boxes_count=500)
// Make a session input define the time interval to highlight
tradeTimes = input.session("0700-1300", title="Trading Times")
// InSession() returns 'true' when the current bar happens inside
// the specified session, and 'false' when the bar isn't inside
// that time period (or when the chart's time frame is 1 day or higher).
InSession(sessionTimes) =>
not na(time(timeframe.period, sessionTimes))
// Make the background orange for bars inside the session
bgcolor(InSession(tradeTimes) ? color.new(color.orange, 80) : na)