Attachments forums

List of attachments posted on this forum.


All files on forums: 136877

Re: Buy Sell Pressure indicator for MT4

mrtools, Sat Feb 11, 2023 6:18 am

TransparentTrader wrote: Fri Feb 10, 2023 3:05 pm Ok, so an update to the code from Fract that got released just a half hour ago. If anybody has started working on this indicator and sees this message now, my sincerest apologies.

This pertains to the discussion about using NET BSP on Heikin-Ashi (HA) charts vs. candlestick charts in the quoted message above.

Here is the update from Fract himself:

"To smooth things out for normal candles I found a good solution. With this new script we can use different types of MA's (moving averages). Default is set to HMA because it groups well the NORMAL candlesticks and is reactive even with 24 (length?). Change to SMA or EMA when it comes to dealing with HA candles."

And below is the new code:

Code: Select all

// © fract
//@version=5
indicator(title='NET BSP', overlay=false, timeframe="")

// Inputs and Formula {
bp = close - (math.min(low, close[1]))                      // Buying   Pressure
sp = (math.max(high, close[1])) - close                     // Selling  Pressure
bal = bp - sp
// }
ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "HMA" => ta.hma(source, length)
        "RMA" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

typeMA = input.string(title = "MA Type", defval = "HMA", options=["SMA", "EMA", "HMA", "SMMA (RMA)", "WMA", "VWMA"])
smoothingLength = input.int(title = "Length", defval = 24, minval = 1, maxval = 200)
bsp = ma(bal, smoothingLength, typeMA)
//}
// Conditions {
bspRise = bsp > bsp[1]
bspFall = bsp < bsp[1]
bspG  = bsp > 0
bspF  = bsp < 0
//}
// Colors {
col = bspG ? (bspRise ? color.new(#00aa49, 0) : color.new(#9a9a00, 0)) : (bspFall ? color.new(#ff2929, 0) : color.new(#9a9a00, 0))
// }
// Plots {
plot(bsp, "NETBSP", col, 1, plot.style_columns, true, 0, 0)
// }

Hopefully this is helpful to anybody who wants to code this indicator! I'll make sure to keep this forum as soon as any new updates are announced.
Made the histo version, wasn't able to add the pre-smoothing it would invert the values, so not sure if i messed up somewhere with it or not, but if I figure out what was wrong will add it.
All files in topic