בחירות העורכים
OPEN-SOURCE SCRIPT

Stochastic Momentum Index (SMI) of Money Flow Index (MFI)

מעודכן
"He who does not know how to make predictions and makes light of his opponents, underestimating his ability, will certainly be defeated by them."
(Sun Tzu - The Art of War)


▮ Introduction

The Stochastic Momentum Index (SMI) is a technical analysis indicator that uses the difference between the current closing price and the high or low price over a specific time period to measure price momentum.
On the other hand, the Money Flow Index (MFI) is an indicator that uses volume and price to measure buying and selling pressure.
When these two indicators are combined, they can provide a more comprehensive view of price direction and market strength.


▮ Improvements

By combining SMI with MFI, we can gain even more insights into the market. One way to do this is to use the MFI as an input to the SMI, rather than just using price.
This means we are measuring momentum based on buying and selling pressure rather than just price.
Another way to improve this indicator is to adjust the periods to suit your specific trading needs.


▮ What to look

When using the SMI MFI indicator, there are a few things to look out for.
First, look at the SMI signal line.
When the line crosses above -40, it is considered a buy signal, while the crossing below +40 is considered a sell signal.
Also, pay attention to divergences between the SMI MFI and the price.
If price is rising but the SMI MFI is showing negative divergence, it could indicate that momentum is waning and a reversal could be in the offing.
Likewise, if price is falling but the SMI MFI is showing positive divergence, this could indicate that momentum is building and a reversal could also be in the offing.

In the examples below, I show the use in conjunction with the price SMI, in which the MFI SMI helps to anticipate divergences:
תמונת-בזק
תמונת-בזק

In summary, the SMI MFI is a useful indicator that can provide valuable insights into market direction and price strength.
By adjusting the timeframes and paying attention to divergences and signal line crossovers, traders can use it as part of a broader trading strategy.
However, remember that no indicator is a magic bullet and should always be used in conjunction with other analytics and indicators to make informed trading decisions.
הערות שחרור
The TSI and signal lines were blurred by the histogram.
הערות שחרור
- Added limits customization for gradient theme (last theme in the list, which is now number 26):
(examples are from my other indicator DMI SMI which has common parameters)
תמונת-בזק
תמונת-בזק

- New themes added:
תמונת-בזק

Some examples:
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
תמונת-בזק
הערות שחרור
Minor fixes:
- The term "Opacity" was not correct. The correct one is "Transparency".
הערות שחרור
- Added a parameter to customize the Histogram transparency level.
This can be useful to make the graph less cluttered in certain situations.
Below is an example with the type changed from Histogram to Area (in the Style tab), and then with the transparency level at 70%:
תמונת-בזק

- New themes added.
The themes were reorganized by value ranges, in order to facilitate the choice and future implementations:
תמונת-בזק

10 to 15 → Spectrum Blue-Green-Red
20 to 21 → Monokai
30 to 31 → Spectrum White-Green-Red
40 to 41 → Green-Purple
50 to 51 → Blue-Red
60 to 61 → Blue-Yellow
70 to 71 → Green-Red
80 to 81 → Green
90 to 91 → Purple
100 to 107 → Blue
120 to 123 → Blue-Aqua
130 to 133 → Blue-Green
140 to 153 → Red
160 to 161 → Red-Yellow
170 to 171 → Red-White
180 to 185 → White-Black
190 to 191 → Spectrum Blue-Red

Codes 190, 191:
תמונת-בזק
תמונת-בזק

- Fine adjustments were made in the standard parameters of Levels for TSI's Theme and Signal's Theme aiming at a better visualization of the colors.

- Added 2 color gradient format theme option for Histogram.
Example:
תמונת-בזק

- Improved crossing alert messages. There are now 8 alerts available:
1. 'TSI crossing above Signal when within limits'
2. 'TSI crossing below the Signal when within limits'
3. 'TSI exiting the Dynamic Zone at the top'
4. 'TSI entering the Dynamic Zone at the top'
5. 'TSI exiting the Dynamic Zone at the bottom'
6. 'TSI entering the Dynamic Zone at the bottom'
7. 'TSI crossing above the centerline'
8. 'TSI crossing below the centerline'

There are now two ways to add alerts over here:
תמונת-בזק

In the first form, technically speaking, the alert() function is used. This is the fastest way and works best with automations.
Alerts are chosen via indicator parameters. That done, then just add the "Any alert()" alert, as indicated in circle 1.

The second way is more laborious, but allows individual insertion of alerts.
Note that in this case, the checkboxes mentioned above make no difference.

Due to the added alerts using the alert() function, I had to remove the timeframe parameterization.

* Note: the example images are from my other indicator named "DMI Stochastic Momentum Index" as the parameters are similar.
הערות שחרור
Added a new parameter to choose a different timeframe. Useful for combined analysis of multiple timeframes, as suggested by trader Robert Miner in his book "High Probability Trading Strategies".

Example:
תמונת-בזק
הערות שחרור
- [Bug] Correction in theme "1" (User defined). The colors weren't showing up correctly.

Before:
תמונת-בזק

After correction:
תמונת-בזק

- [Minor fix] Removed unnecessary "var" declarations in order to follow official best practices.

- [Feature] Added themes 134, 135 (green-blue, blue-green), 162, 163 (yellow-red, red-yellow).
תמונת-בזק
הערות שחרור
New themes:
תמונת-בזק
הערות שחרור
[FEATURES]

1. Added a repaint option (thanks for PineCoders).
תמונת-בזק
2. Added a set of separate MFI parameters for the Histogram.
This permitis to give a histogram with a longer period, and at same time use TSI Oscillator with faster periods.
תמונת-בזק
3. Added a new option for Histogram: "Multiplier".
Using longer periods, the histogram can become flattened, making it difficult to see. The multiplier solves that.
An example with different MFI settings for Histogram:
תמונת-בזק
4. Added separate alerts for TSI crosses inside/outside Dynamic Zone, with separate bounds for both.
Crossing points were repositioned to facilitate visualization.
5. Added trend lines with breakouts (thanks to HoanGhetti - tradingview.com/script/85fU3JnE-Simple-Trendlines/)
תמונת-בזק
6. Added divergence detector (thanks to TradingView - tradingview.com/chart/?solution=43000589127)
תמונת-בזק

[FIX AND IMPROVEMENTS]

1. Minor fixes in tooltips.
2. Minor change in default colors.
3. Default values for histogram changed to match six equal parts.
4. Default length for MFI used in Histogram: changed from 14 to 55.
5. Default length for TSI Long used in Histogram: 55.
6. Default length for TSI Short used in Histogram: 13
7. Default source for MFI used in TSI: changed from hl2 to close.
8. Removed alertcondition function to permit show divergence detector (due to limitation of maximum number of elements in screen).
הערות שחרור
1. Added the option to choose the data source for trend lines and divergence, which can be TSI (default) or histogram.
2. Changed default divergence values from 8 to 13, with minimum to 8.
3. Minor text corrections.
הערות שחרור
Script updated with several fixes.
תמונת-בזק

1. This indicator is the "SMI - Stochastic Momentum Index", and SMI is not the same as "SMII - Stochastic Momentum Index Ergodic Indicator".
The indicator here was behaving like SMII.

In short, SMII is the TSI (True Strength Index) with a signal line.
SMI and SMII may look the same, but the calculation is different.

This has now been corrected, and the indicator will behave like SMI in fact.

Sorry for the confusion.

תמונת-בזק

More info:

SMI - Stochastic Momentum Index:
tradingview.com/support/solutions/43000707882/

SMII - Stochastic Momentum Index Ergodic Indicator:
tradingview.com/support/solutions/43000594669/

SMIO - Stochastic Momentum Index Ergodic Oscillator:
tradingview.com/support/solutions/43000594671/

2. Updated code library usage.

3. Minor fixes and adjustment of default parameter values.

4. Correction in the selection of timeframes and use of "repainting" according to the official documentation:
Higher-timeframe requests


5. Added option to show/hide labels of divergences and trend lines. On a very tight screen this saves space and avoids visual pollution.
הערות שחרור
[FIX] SMI's formula corrected to match the original one.
Now the value is multiplied by 200 instead of 100.
So the oscillator will be in the range of -100 to 100 instead of -50 to 50.

[MISC] Some default parameters changed.
Centered OscillatorsMFIMoney Flow Index (MFI)moneyflowindexSMIstochasticdivergencestochasticmomentumindexTrue Strength Index (TSI)volumeanalysis

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?


To contribute to my work:
⚡Bitcoin Lightning: forwardocean64@walletofsatoshi.com
🟠Bitcoin: bc1qv0j28wjsg6l8fdkphkmgfz4f55xpph893q0pdh
🔵PayPal: paypal.com/donate/?hosted_button_id=D9KRKY5HMSL9S
גם על:

כתב ויתור