TN Alerts: A Smart Approach to Trade Entries and Exits

TN Alerts: A Smart Approach to Trade Entries and Exits

Introduction

The indicator/system we will present is an alert system called TN alerts. This system is designed to identify entry and exit opportunities in the market using weighted moving averages and a trailing stop. The goal of this system is to provide clear signals for executing long and short trades while managing risk through the use of a dynamic trailing stop.

The TN alerts system stands out for its ability to adapt to different market conditions, offering a structured way to identify trends and manage trades efficiently. This system includes advanced features such as re-entries and signal visualization directly on the chart, facilitating decision-making for traders.

Indicator Parameters

The input parameters of the system are as follows:

  • TS (Trailing Stop): Percentage of trailing stop. This parameter defines the trailing stop adjustment percentage relative to the closing price.
  • TSswitch: Enable/disable the display of stop loss. When enabled, the stop loss is shown on the chart.
  • BGswitch: Enable/disable the background color on the chart. It allows clear visualization of long and short entry zones.
  • REswtich: Enable/disable the display of re-entries. Shows re-entry signals on the chart.
  • fastperiod: Fast period for calculating the moving average.
  • slowperiod: Slow period for calculating the moving average.
  • MAtype: Type of moving average to use (e.g., weighted).

These parameters allow high flexibility and customization of the system, adapting it to the trader’s specific needs and market behavior over different periods.

Moving Averages Calculation

Moving averages are a fundamental tool in technical analysis, and this system uses two:

  • wmaSlow: Slow moving average calculated over the period defined by slowperiod.
  • wmaFast: Fast moving average calculated over the period defined by fastperiod.

The moving averages are calculated as follows:

The fast moving average (wmaFast) and the slow moving average (wmaSlow) help identify short-term and long-term trends, respectively. These moving averages are essential for determining the entry and exit conditions in the market.

Entry and Re-entry Conditions (Long and Short)

The conditions for long and short entries are defined as follows:

  • Long Entry: The slow moving average is greater than its previous value, and the current closing price is above the fast moving average, among other conditions.
  • Short Entry: The slow moving average is less than its previous value, and the current closing price is below the fast moving average, among other conditions.

Re-entries

The system also considers re-entries in the same direction of the current trend, allowing to capitalize on extended market movements. This is visualized on the chart with specific colored arrows.

Re-entries are marked with blue arrows for long trades and gray arrows for short trades, indicating moments of reinforcement of the initial position.

Trailing Stop Calculation

The trailing stop is a crucial tool for risk management in trading. This system uses a dynamic trailing stop that adjusts based on the closing price. The trailing stop is calculated as follows:

In this code, tsPercent defines the trailing stop percentage. trailTop and trailBot are used to store the trailing stop values for long and short positions, respectively. The trailing stop adjusts dynamically, allowing to lock in profits while minimizing losses.

Exit Conditions (Long and Short)

The system’s exit conditions are determined by the trailing stop. When the price reaches the trailing stop level, an exit signal is generated. The exit conditions are implemented as follows:

Here, exitlong and exitsh determine if long or short positions should be closed based on the trailing stop. The variables inlong and inshort are used to track the current position status.

Visualization on the Chart

The system visualizes signals on the chart using arrows and background colors. This facilitates the interpretation of signals and decision-making in trading. The visualization is implemented as follows:

In this code, green and red arrows indicate long and short entries, respectively. Blue and gray arrows indicate re-entries, while black symbols indicate exits.

Complete Code of the Indicator/System

Conclusion

This system provides a powerful tool for identifying entry and exit opportunities in the market using moving averages and trailing stops. The customization of parameters allows the system to adapt to different trading styles and markets. It is important to test and adjust the system in various market conditions to maximize its effectiveness.

The TN alerts is a versatile system that can be used by both novice and experienced traders. Its clear visualization and well-defined rules make it a valuable addition to any trading strategy.

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. Fgats • 305 days ago #

    Thank Ivan for this code !
    Now could you clarify one detail : when I compare line 58 with line 50, I wonder if there is a typo. Shouldn’t we write inshort = inshort[1]?
    Thank for your reply.
    Gabriel

  2. Faisalx • 303 days ago #

    Hola Ivan. Thanks for your great job.
    I would appreciate if you have look at my request
    https://www.prorealcode.com/topic/convert-code-pivot-ribbon/

  3. roccafragius • 303 days ago #

    Thank you for all these useful information!! Very great job Ivan! THank you so much

  4. geroniman • 303 days ago #

    Merci Ivan, super travail. On peut toujours compter sur toi pour apporter des innovations sur ce site. Est-ce que tu as créé un groupe whatsapp ou telegram ?

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
manchokcity can we have it in mql4 platform? or how or which platform do we use it?
camporan I don't use MetaTrader so I won't be able to do the translation myself. Sorry!
Alexander9 This can for amibroker ? . Thanks
riz001 thnk u
geroniman bonjour Nicolas, j ai un indicateur le Tiger . J aiemrai placer des fleches buy et sell dire...
Nicolas Merci de formuler les demandes sur le forum. ça n'est pas le bon endroit et hors sujet ici ! ;)
avatar
Anonymous Hi robertogozzi - thank you very much for sharing this strategy. I have performed various ...
robertogozzi Thank you samsampop.
Dotan Hello guys I really appreciate this coding effort but can I use this code for Mt5 Forex Trad...
LucioleLucide Clean view, thanks for sharing
dertopen hi where i can found the window for candle configuration?
paolosab69 Ciao! . I have seen the pictures that explain this metod but i don't understand when is mome...
winnie37 yes. "No ground breaking math here, but I am finding very useful and some algo based on it i...
Jan Wind Also interesting to know what does not work, which set up you use, saves me investigating ! ...
winnie37 i just set the proorder like this: buy when 50/100/200 phase >0 and sell when under 0, go...
nfulcher Please could someone explain how the following code is calculated:- iDI = TEMA[3](DI[DI2]...
oakenstream Jan, I find sometimes that the priceexit variable is never set. It seems to happen when the ...
Matt66612 I do not understand the first time I launch the backtest I got the same result as you. but ...
coscar Ottimo lavoro. come sempre!
luxrun Nello studio di Sepiashvili viene descritto anche un altro indicatore, il Q-indicator, che è...
Maik2404 wie kann ich den Code bekommen Paul?
jens_kittner Works with US Crude at 1h as well!
Jean-Claude REGIS Je préconise de regarder les graphiques H1 et M15 pour visualiser la tendance de fond et d'...
Leo I don't know, I just copy paste the strategy. The optimisation of the values I wrote them in...
bertrandpinoy hello Leo I'm spending time on your strategy code. do you agree to try to include this code ...
bertrandpinoy //version a: ajout filtre MM defparam cumulateorders=false // --- paramètres taille =...
capgros Bonjour @Nicolas, Thanks a lot for this tool, it is very useful for me. I would like to s...
Hans63 Would you add the possibility to color also the Heikin Ashi and bar chart?
Nicolas That's possible, please open a new topic in the indicator forum explaining what you need exa...
Nicolas
6 years ago
BSTrend
v10.3
BSTrend
10
Indicators
Florian Legeard C’est à dire sur le prix et non sur le temps ? Merci
Rohit82189 bstrend repaints
Nicolas No, it doesn't repaint.
cfta Hi Fulvio, many thanks for sharing this clever indicator, much appreciated. As Pepsmile ment...
cfta Sorry adding the PRT to code didn't work in the above comment so I guess we will have to set...
juanj Something appears to be wrong with this formula as graphing t shows t to almost never be wit...
Nicolas
7 years ago
Maxime Baudin Interesting, Thank you! :)
franck-david Bonjour Nicolas , actuellement je me forme grace a vos videos tres tres bien expliques mer...
Nicolas Merci. ça n'est pas le lieu pour poser ce genre de question :) Merci d'utiliser le forum Pro...
joobeng Sorry, I solved the problem. I have add the CBL indicator using the spanner icon on the pric...
Nicolas Adjust the price settings for the Y Axis to use the price only.
XXXXVII Hello Your indicator is interesting. However, I can't see the orange line. Do you have ...
bharatjai Script 'Adaptive ATR' has been saved line 24: no viable alternative at input 'lr' Gettin...
Nicolas download the itf file and import it into your platform.
Francis3332 Bonjour à tous, J'aime beaucoup cet indicateur et j'aimerais pouvoir l'utiliser sur la dern...
Nicolas Definition of CustomClose: https://www.prorealcode.com/documentation/customclose/ [2] means...
Bard Just wondered Nicolas, say you had set DEFPARAM CumulateOrders = True, is there anyway for t...
Bard Sorry pls ignore last image, try this - it actually has the Dev Stop indicator! https://www...
tradingpro salve io faccio spread trading e volevo sapere come impostare un profitto da chiudere in a...
Nicolas Per favore non fare domande generali, non correlate al post. Usa invece il forum.
Bard Incredible, that is the clearest depiction of the trend I've ever seen Nicolas. (I just chan...
Vonasi Discussion on this indicator/filter can be found here: https://www.prorealcode.com/topic/121...

Top