Pinescript
Hantar time frame chart ke dalam alertKita akan gunakan 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 !
// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © 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)
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 ||'
+' * Breakout Price: ' +tostring(highesthigh,format.mintick)
+' * Target: ' +tostring(reward,format.mintick)
+' * Stop Loss: ' +tostring(stoploss,format.mintick)
+ ' TimeFrame= ' +tflabel,
color=label_color,
textcolor= close <= highesthigh ? color.white : na,
style=label.style_label_down)
label.delete(l )
//#Lines for breakout price
number = abs(highestbars(high,breakouthigh) )
horizontaline = line.new(bar_index ,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 )
//#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 + ' Entry Above = ' +tostring (highesthigh,format.mintick) + ' Stop Loss = ' + tostring(stoploss,format.mintick)
+ ' Target Price = ' + tostring(reward,format.mintick)
+ ' TF = ' +tflabel
alert(message= msg, freq=alert.freq_once_per_bar)
SIRI PINE SCRIPT - PLOT dan WARNA berbeza untuk garisan hargaMenggunakan fungsi PLOT dan CLOSE PRICE untuk membuat garisan dan bulatan yang berlainan warna.
Di akhir video, saya tukar dari CLOSE PICE kepada nilai RSI.