deimosaffair

alert!!!!

alerts work over values of plots on the chart. could not find a way to add an alert when a strategy is triggered.
so, i created an alert chart that uses the same conditions as the strategy(i published the example strat in my previous script). an alert chart should be mostly zero, but when the strat fires up, the alert = 1, and when the strat fires down, alert = -1. this way it's easy to check the chart for alerts.

but, if i'm looking at the cahrt and see the strat's arrows, what's the point? well, the point is that we can add alerts to this chart, to send emails, popup on screen, start screaming, whatever. so that now i don't actually need the chart in screen all the time :)

since this alert chart behaves so nice, values = to add an alert is just setting it's value >0.5, or value > -0.5 :)
note: aloert is not actually in the script, it has to be added manually using the button. if Pine has a way to add alerts programatically, i couldn't find it
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?
//@version=2
study("alert", overlay=false) 

//input boxes for the limit date
yearLimit = input(2016,title="year") 
monthLimit = input(1, title="month")
dayLimit = input(1, title="day")

//function that checks if the current date is more recent than the limit
dateOk(yl,ml,dl) =>
    ok = (year < yl) ? false : (yl == year and month < ml ) ? false : (yl == year and ml == month and dayofmonth < dl) ? false : true
    ok
    
checkDate = dateOk(yearLimit,monthLimit,dayLimit)
goUpCheck = (close > open and open > close[1])
goDownCheck = (close < open and open < close[1])

alert = 0
alert := checkDate and goUpCheck ? 1 : alert
alert := checkDate and goDownCheck ? -1 : alert

plot(alert, title="alert",  color=green, linewidth=2, style=line)