简体   繁体   中英

Pinescript: How to isolate a section of an indicator to calculating based on another candle stick pattern

I'm still very new to Pinescript, but am eagerly learning the language. I was never really tech saavy, no know programming languages until tinkering with Pinescript.

The indicator I would like to modify to my trading style is called Vumanchu Cipher B: https://www.tradingview.com/script/Msm4SjwI-VuManChu-Cipher-B-Divergences/

It's the Money Flow Indicator, where the calculation can be found from lines 314-316:

// RSI + MFI Area
rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, timeframe.period)
rsiMFIColor = rsiMFI > 0 ? #3ee145 : #ff3d2e

Thank you in advance if you can help me out!!

I've been trying my best to see if I can isolate the money flow to use calculations based on Heiken Ashi (HA) Candles instead of using the japanese candles I trade with.

I know I have to use something like these commands:

useHA=input(true,"Use heikin ashi candles?")
ha_AP=security(heikinashi(syminfo.tickerid), timeframe.period, AP)

But keep getting errors when I make attempts to put them all together. :'(((

So I guess to summarize, I'd like the Vumanchu indicator to make calculations based on japanese candles, while the Money Flow calculates based on Heiken Ashi.

I hope this makes sense:')

In this script, f_rsimfi is:

f_rsimfi(_period, _multiplier, _tf) => security(syminfo.tickerid, _tf, sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY)

As you can see, this function already uses security function, so you can't call the security function again.

You can however, change the symbol parameter of the security function to use heikinashi instead of "regular" candles. You can for example first set an input as you wanted:

useHA=input(true,"Use heikin ashi candles?")

Then decide which syminfo.tickerid to use according to this input:

t = useHA ? heikinashi(syminfo.tickerid) : syminfo.tickerid

And finally change the function so it will calculate accordingly:

f_rsimfi(_period, _multiplier, _tf) => security(t, _tf, sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM