The lows in the price movement are detected by the Low finder script by RafaelZioni. It finds the potential lows based on the difference between RSI and EMA RSI. The MTF RSI formula is part of the MTFindicators library developed by Peter_O and is integrated in the Low finder code to give the option to use the RSI of higher timeframes. The sensitivity of the LowFinder is controlled by the MA length. When potential lows are detected, a Moving Average, a MTF Stochastic (based the the MTFindiicators by Peter_O) and the average price level filter out the weak lows. In the settings the minimal percentage needed for a low to be detected below the average price can be specified.
Order Sizing and Pyramiding
Pyramiding, or spreading multiple positions, is at the heart of this strategy and what makes it so powerful. The order size is calculated based on the max number of orders and portfolio percentage specified in the input settings. There are two order size modes. The ‘base’ mode uses the same base quantity for each order it opens, the ‘multiply’ mode multiplies the quantity with each order number. For example, when Long 3 is opened, the quantity is multiplied by 3. So, the more orders the bigger the consecutive order sizes. When using ‘multiply’ mode the sizes of the first orders are considerably lower to make up for the later bigger order sizes. There is an option to manually set a fixed order size but use this with caution as it bypasses all the risk calculations.
Stop Level, Take Profit, Trailing Stop
The one indicator that controls the exits is the Stop Level. When close crosses over the Stop Level, the complete position is closed and all orders are exited. The Stop Level is calculated based on the highest high given a specified candle lookback (settings). There is an option to deviate above this level with a specified percentage to tweak for better results. You can activate a Take Profit / Trailing Stop. When activated and close crosses the specified percentage, the Stop Level logic changes to a trailing stop to gain more profits. Another option is to use the percentage as a take profit, either when the stop level crosses over the take profit or close. With this option active, you can make this strategy more conservative. It is active by default.
And finally there is an option to Take Profit per open order. If hit, the separate orders close. In the current settings this option is not used as the percentage is 10%.
I published an earlier version of this script a couple of weeks ago, but it got hidden by the moderators. Looking back, it makes sense because I didn’t pay any attention to risk management and save order sizing. This resulted in unrealistic results. So, in this script update I added a Stop Loss option. There are two modes. The ‘average price’ mode calculates the stop loss level based on a given percentage below the average price of the total position. The ‘equity’ mode calculates the stop loss level based on a given percentage of your equity you want to lose. By default, the ‘equity’ mode is active. By tweaking the percentage of the portfolio size and the stop loss equity mode, you can achieve a quite low risk strategy set up.
Variables in comments
To sent alerts to my exchange I use a webhook server. This works with a sending the information in the form of a comment. To be able to send messages with different quantities, a variable is added to the comment. This makes it possible to open different positions on the exchange with increasing quantities. To test this the quantities are printed in the comment and the quantities are switched off in the style settings.
This code is a result of a study and not intended for use as a worked out and full functioning strategy. Use it at your own risk. To make the code understandable for users that are not so much introduced into pine script (like me), every step in the code is commented to explain what it does. Hopefully it helps.
Gerçek TradingView ruhuyla, bu betiğin yazarı, yatırımcının anlayabilmesi ve doğrulayabilmesi için onu açık kaynak olarak yayınladı. Yazarın eline sağlık! Bunu ücretsiz olarak kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Kullanım Koşulları ile yönetilir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.