f-cksociety / backtesting-trading-engine-pinecoders

Masterpiece of PineCoders script https://www.tradingview.com/script/dYqL95JB-Backtesting-Trading-Engine-PineCoders/ in v3, this is the project to upgrade it to v4-v5 and implement dynamic variable alerts message from within an indicator() alertcondition as discussed here https://t.me/pinescripters/31982
Mozilla Public License 2.0
9 stars 3 forks source link

dynamic variable alerts message #7

Open HeyMrRobot opened 2 years ago

HeyMrRobot commented 2 years ago

dynamic variable alerts message from within an indicator() alertcondition

https://github.com/f-cksociety/backtesting-trading-engine-pinecoders/blob/main/study-dynamic-variable-alert.pine

[backtesting-trading-engine-pinecoders] bte.pine (Lines 329-341)


// ————— N. Alert Configuration
_8 = input.bool(true, "═════════════ Alert Triggers")
AlertType1 = input.bool(false, "Long Entry")
AlertType2 = input.bool(false, "Long Pyramiding Entry")
AlertType3 = input.bool(false, "Short Entry")
AlertType4 = input.bool(false, "Short Pyramiding Entry")
AlertType5 = input.bool(false, "Long Exit")
AlertType6 = input.bool(false, "Short Exit")
AlertType7 = input.bool(false, "Event 1: Price nearing Stop")
AlertType8 = input.bool(false, "Event 2: Possible Tops/Bottoms")
AlertType9 = input.bool(false, "Event 3: Stop Move")
AlertType10 = input.bool(false, "Event 4: Price Swing")

Open in IDE · Open on GitHub [backtesting-trading-engine-pinecoders] bte.pine (Lines 1839-1854)


// ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
// ——————————————————————————————————————————————— 15. Alerts —————————————————————————————————————————————————————————————
// ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
// If your alerts are sent to an execution bot, then you will need to include the proper encoding in the message field.
A1  = AlertType1    and LongEntryTrigger    and not PyramidLongEntry
A2  = AlertType2    and LongEntryTrigger    and PyramidLongEntry
A3  = AlertType3    and ShortEntryTrigger   and not PyramidShortEntry
A4  = AlertType4    and ShortEntryTrigger   and PyramidShortEntry
A5  = AlertType5    and LongExitTrigger
A6  = AlertType6    and ShortExitTrigger
A7  = AlertType7    and EventType1Trigger
A8  = AlertType8    and EventType2Trigger
A9  = AlertType9    and EventType3Trigger
A10 = AlertType10   and EventType4Trigger
alertcondition(A1 or A2 or A3 or A4 or A5 or A6 or A7 or A8 or A9 or A10, title=SystemName, message=TradeId)

Open in IDE · Open on GitHub

Created from VS Code using CodeStream