BURSATRENDBANDCHART

Hantar time frame chart ke dalam alert

Pendidikan
MYX:CMSB   CAHYA MATA SARAWAK BHD
Kita 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 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 = [__tag__=relativestrengthindex]rsi[/__tag__](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", [symbol=nz]nz[/symbol](highest(high,52)), lookahead=barmerge.lookahead_on)
weekly_ll = security(syminfo.tickerid,"W", [symbol=nz]nz[/symbol](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= [symbol=msg]msg[/symbol], freq=alert.freq_once_per_bar)

Komen

line nom 17 ada error pada rsi(close,14)
Balas
@sammie82, yer, priginal memang rsi(close,14) saja...tapi bila paste ke sini, dia jadi mcm tu..
+1 Balas
sammie82 BURSATRENDBANDCHART
@BURSATRENDBANDCHART, bila guna rsi(close,14) sahaja akan ada error pd line 50
Balas
@sammie82, ganti mcm dlm gambar ni https://ibb.co/KNSSx7k
Balas
sammie82 BURSATRENDBANDCHART
@BURSATRENDBANDCHART, alhamdulillah berjaya, terima kasih tuan
Balas
Terima Kasih 😍😍
Balas