CAHYA MATA SARAWAK BHD
Pendidikan

Hantar time frame chart ke dalam alert

645
Kita akan gunakan
Pine Script®
timeframe.period
untuk dapatkan maklumat time frame carta yang sedang dibuka dan hantar menjadi alert.

Contoh keseluruhan script seperti di bawah
GUNA SEBAGAI CONTOH SAHAJA !

Pine Script®
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © BURSATRENDBANDCHART //@version=4 study("Label with Trading Idea - Example", overlay =true ) //User Input tableaktif = input(title="On/Off", type=input.bool, defval=true) breakouthigh=input(title="Breakout High Candle", type=input.integer, defval=10, minval=1) rewardinput = input(title="Target %", type=input.integer, defval=10, minval=1)/100 riskinput = input(title="Risk %", type=input.integer, defval=4, minval=1)/100 //Calculation highesthigh = highest(high,breakouthigh)[1] stoploss = highesthigh - (highesthigh * riskinput) reward = highesthigh + (highesthigh * rewardinput) rsi1 = rsi(close,14) tflabel = timeframe.period //#Breakout candle barcolor(title="Breakout Candle", color=close > highesthigh ? color.blue : na) //#Label for Trading Idea label_color = close <= highesthigh and rsi1 < 30 ? color.blue : close <= highesthigh and rsi1 > 30 and close <= highesthigh and rsi1 <70? color.green : close <= highesthigh and rsi1 > 70 ? color.red : na l = label.new(bar_index + 5, highesthigh, '|| Entry above breakout price ||' +'\n\n * Breakout Price: ' +tostring(highesthigh,format.mintick) +' \n\n* Target: ' +tostring(reward,format.mintick) +'\n\n* Stop Loss: ' +tostring(stoploss,format.mintick) + '\n\n TimeFrame= ' +tflabel, color=label_color, textcolor= close <= highesthigh ? color.white : na, style=label.style_label_down) label.delete(l[1]) //#Lines for breakout price number = abs(highestbars(high,breakouthigh)[1]) horizontaline = line.new(bar_index[number + 1],highesthigh,bar_index + 5,highesthigh, color=close <= highesthigh and rsi1 < 30 ? color.blue : close <= highesthigh and rsi1 > 30 and close <= highesthigh and rsi1 <70? color.green : close <= highesthigh and rsi1 > 70 ? color.red : na, style=line.style_dotted) line.delete(horizontaline [1]) //#Info Panel weekly_hh = security(syminfo.tickerid,"W", nz(highest(high,52)), lookahead=barmerge.lookahead_on) weekly_ll = security(syminfo.tickerid,"W", nz(lowest(low,52)), lookahead=barmerge.lookahead_on) var table panel = table.new(position.top_right, 2,9, frame_width=1, frame_color=color.black, border_width=0, border_color=color.black) if barstate.islast and tableaktif == false // Table header. table.cell(panel, 0, 0, "INFO PANEL", bgcolor = color.black, text_halign=text.align_right, text_size=size.normal, text_color=color.white) table.cell(panel, 1, 0, "", bgcolor = color.black, text_halign=text.align_left, text_size=size.normal, text_color=color.white) table.cell(panel, 0, 1, "Day's Range", bgcolor = color.new(color.white,100), text_halign=text.align_left, text_size=size.normal, text_color=color.black) table.cell(panel, 0, 2, "Open", bgcolor = color.new(color.white,100), text_color = color.black, text_size=size.normal,text_halign=text.align_right) table.cell(panel, 0, 3, "High", bgcolor = color.new(color.white,100), text_color=color.black, text_size=size.normal,text_halign=text.align_right) table.cell(panel, 0, 4, "Low", bgcolor = color.new(color.white,100), text_color = color.black, text_size=size.normal,text_halign=text.align_right) table.cell(panel, 0, 5, "Close", bgcolor = color.new(color.white,100), text_color = color.black, text_size=size.normal,text_halign=text.align_right) table.cell(panel, 0, 6, "52W Range", bgcolor = color.new(color.white,100), text_halign=text.align_left, text_size=size.normal, text_color=color.black) table.cell(panel, 0, 7, "Low", bgcolor = color.new(color.white,100), text_color = color.black, text_size=size.normal,text_halign=text.align_right) table.cell(panel, 0, 8, "High", bgcolor = color.new(color.white,100), text_color = color.black, text_size=size.normal,text_halign=text.align_right) table.cell(panel, 1, 2, tostring(open), bgcolor = color.new(color.white,100), text_color=color.black, text_size=size.normal) table.cell(panel, 1, 3, tostring(high), bgcolor = color.new(color.white,100), text_color=color.black, text_size=size.normal) table.cell(panel, 1, 4, tostring(low), bgcolor = color.new(color.white,100), text_color=color.black, text_size=size.normal) table.cell(panel, 1, 5, tostring(close), bgcolor = color.new(color.white,100), text_color=color.black, text_size=size.normal) table.cell(panel, 1, 7, tostring(weekly_ll,format.mintick), bgcolor = color.new(color.white,100), text_color=color.black, text_size=size.normal) table.cell(panel, 1, 8, tostring(weekly_hh,format.mintick), bgcolor = color.new(color.white,100), text_color=color.black, text_size=size.normal) //#Alert Example if label_color == color.green msg= 'Look for entry ' + syminfo.tickerid + '\nEntry Above = ' +tostring (highesthigh,format.mintick) + '\nStop Loss = ' + tostring(stoploss,format.mintick) + '\nTarget Price = ' + tostring(reward,format.mintick) + '\nTF = ' +tflabel alert(message= msg, freq=alert.freq_once_per_bar)

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.