KryptoNight

Early/Delayed Signal Function

Early/Delayed Signal Function (before the bar close or after)

Usually, signals are considered to be valid at the bar close.
Some traders may prefer to have a chance to enter earlier.
It is of great risk, and the Strategy Tester is unable to provide consistent backtest data with regards to this.

But for those who want to integrate such a choice in their strategies, here is the Early Signal Function.
The function takes 2 parameters
- the signal that is considered valid at the bar close, of type bool
- the early time value in seconds, the time before the signal is valid, of type int
it returns a value of type bool - a New Entry Signal

The resulting conditions used for alerts would be:
- newLongCondition = earlySignal_f(myLongSignal, earlyTime)
- newShrtCondition = earlySignal_f(myShrtSignal, earlyTime)

Note: the signals can also be delayed - use a negative value for early time
Release Notes: improved the early alert function,
using the new built-in function for alerts, that works in both strategy() & study() scripts
Release Notes: test long alert
Release Notes: fix: now it is possible to delay the signals, use a negative value in seconds
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?
Join the Discord Server for more info about the published tools.
https://discord.io/CryptoWorld
a Discord bot for Charting (TradingView and Heatmaps) is available

🟣 If you like any of my Invite-Only Tools, let me know

(DM or Discord for inquiries)

Comments

Hi, thanks for sharing this script. Trying to understand why the script is affected by the Interval? For example, seems to function well at 1min, but when change to hours, the units seems to change. Thanks!
+5 Reply
CryptoRedneck CryptoRedneck
@CryptoRedneck oh wait, dumb question, the seconds in countdown are waiting until the next bar to close. Should have had more coffee this morning... thanks for the script @KryptoNight!
+2 Reply
Very nice. I have been looking for something like this. I tweaked it a little and works better without missing sometimes. Change to: earlySignal = mySignal and (time_close-timenow-earlyTime*1000)/1000<=0

This works well with once per bar. Thanks again!
+2 Reply
Hi can you share the script to make the alert delayed by 1 hour ? im new to script
+1 Reply
@hijjaz, open the indicator settings and set the time to -3600
Reply
hijjaz KryptoNight
@KryptoNight, not working. nothing triggered except the normal time one.
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar About Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter