Attachments forums

List of attachments posted on this forum.


All files on forums: 136114

Re: MT4 Indicator requests and ideas

TransparentTrader, Sun May 14, 2023 11:37 am

Bulls Vs Bears, Normalized [TradingView]

kvak or mrtools, I have an idea for the normal Bulls Vs Bears indicator that can also be applied to other indicators.

What's featured here is a normalized version of Bulls Vs Bears created by TradingView user Mihkel00.

The description is below:

This script helps you identify the relative strength of bulls and bears in the market. It calculates the difference between the high and the moving average for bulls, and the difference between the moving average and the low for bears.

Then it normalizes the values between -100 and 100 using the highest and lowest values of the last "bars back" periods. This allows you to compare the current strength of bulls and bears relative to their historical strength.

The output of the script is a colored column chart that represents the difference between the normalized bulls and bears values. If the chart is mostly green, it means the bulls are currently stronger than the bears, and vice versa for a mostly red chart.

Additionally, the script provides bullish and bearish signals based on when the normalized bulls cross above or below the user-defined "Line Height" value. You can use this script to help you identify potential trend changes in the market, as well as to confirm existing trends.


Here is the code:

Code: Select all

//@version=4
study("Bulls v Bears")

// Input settings
len = input(title="BvB Period", type=input.integer, defval=14, minval=1)
bars_back = input(title="Nomralized bars back", type=input.integer, defval=120, minval=1)
tline = input(80, title="Line Height" )

// Calculation
ma = ema(close, len)
bulls = high - ma
bears = ma - low

// Normalize the values between -100 and 100
min_bulls = lowest(bulls, bars_back)
max_bulls = highest(bulls, bars_back)
norm_bulls = ((bulls - min_bulls) / (max_bulls - min_bulls) - 0.5) * 100

min_bears = lowest(bears, bars_back)
max_bears = highest(bears, bars_back)
norm_bears = ((bears - min_bears) / (max_bears - min_bears) - 0.5) * 100

// Calculate the total and add signals
total = norm_bulls - norm_bears
bullish_o = total > tline
bearish_o = total < -tline

// Plot the total with colored columns
col = total >= 0 ? color.green : color.red
plot(total, color=col, style=plot.style_columns, title="BvB")
plotshape(bullish_o, style=shape.circle, location=location.top, color=#ff00d4, title="Bullish Crossover")
plotshape(bearish_o, style=shape.circle, location=location.bottom, color=#eeff00, title="Bearish Crossover")

// Horizontal lines
hline(tline, color=color.gray)
hline(-tline, color=color.gray)

// Alerts
alertcondition(bullish_o, title="Bullish Crossover", message="Bullish overbought")
alertcondition(bearish_o, title="Bearish Crossover", message="Bearish oversold")
alertcondition(crossover(total, 0), title="Total Crossover", message="BvB total crossover")

You'll notice on both candlestick and Renko charts, the indicator does a good job of (1) determining trend strength/direction, but more importantly (2) detecting tops and bottoms in a real-time non-repainting fashion.



At 42 lines of simple code, I can't imagine this would be too difficult to port into MT4. If this works the way I think it does, I have a number of other indicators I would like "normalized". It would be a great way to make a number of standard indicators far more useful.

No need for any extra features like MTF, buttons, alerts, arrows, and so on for the time being. I just want to see if we can successfully re-create this default indicator as a MQ4 file.

Thanks for helping out as always!
All files in topic