TradingView
ImmortalFreedom
11. Febr. 2020 04:07

barssince() Built-in Replacement with 2nd Occurrence Parameter 

American Eagle Outfitters, Inc.NYSE

Beschreibung

This is a barssince() replicant with a 2nd `Occurrence` Parameter. The Pine built-in barssince() function only has the `condition` parameter. It's a handy little function I believe will be very useful in the future for developers of the Tradingview community.

Use it as you please, this is free code to implement into your new Pine projects. I don't require credit for anyone to use this function. I simply don't want any credit. I would however like to see some great ideas utilizing this when I randomly and accidentally come across them in the public library. I didn't know where to put this script, so I just tossed into the "Trend Analysis" category. I'm pondering we members need a "Miscellaneous" category some time in the future.

The comments section below is solely just for commenting and other remarks, ideas, compliments, etc... regarding only this indicator, not others. When available time provides itself, I will consider your inquiries, thoughts, and concepts presented below in the comments section, should you have any questions or comments regarding this indicator. When my indicators achieve more prevalent use by TV members, I may implement more ideas when they present themselves as worthy additions. As always, "Like" it if you simply just like it with a proper thumbs up, and also return to my scripts list occasionally for additional postings. Have a profitable future everyone!

Versionshinweise

Added max_bars_back()
Kommentare
hanahmet
hi.
After selling, he will buy when it rises by %BUY from the last bar to the instant value.
After buying, it will sell when it drops by %SALES from the most recently bought bar to the instant value.

it will sell when it goes down 3% after the last buy trade (from the lowest bar), and buy when it goes up 2% after the last sell trade (from the highest bar).
I don't want to go back 7 bars. I want to go to the last traded bar.

study("My_Proje", shorttitle="AHAP", overlay=false)
length=input(7)
get_buy=input(3)
get_sell=input(3)
highest_peak=highest(length)
bottom_hole=lowest(length)
buy=close>bottom_hole+(bottom_hole/100*get_buy)?1:0
sell=close<highest_peak-(highest_peak/100*get_sell)?1:0
plot(buy,color=green)
plot(sell, color=red)

I tried to do it, it didn't work. Because I need to add barssince command. This command always gave an error. I would be glad if you help.

Thanks in advance. . .
hanahmet
I don't want to go back 7 bars. Using the "barsince" command, I want to go to the most recently traded bar.
iamthree
Very useful indeed :)
Thank you for publishing this awesome script !!!

@midtownsk8rguy
your scripts are amazing and your work on color has changed my hole Chart Layout and left a mark on all of my indicators :)
ImmortalFreedom
@iamthree, I humbly appreciate your gratitude. One thing I have commonly noticed, is the application of strategic color is far more important than the lines and numbers in our charts. I tend to think of old fashioned black&white console TVs compared to the splendor of full color on 4K, and the value it brings to our entertainment. Applying vivid color splashing to indicators is no different in theory. Glad to hear my intentions of occasional inspiration are benefiting you.
iamthree
@midtownsk8rguy, 100% agree with you

I think color can help us to simplify the interpretation of an indicator
lets say we add a rising falling condition that changes the indicators color
we pick up much faster and easier when color is a part of the signal

I also use color to differentiate between my ema levels
so now I know o yes thats the ema 30 or 200 just by its color :)

I really want to start applying intensity to the color as well ...

there is some thing about a good color pallet that just jumps out and makes sense

your color indicator hex codes should get built into trading view as that publication is legendary :) !!!

yes black and white is quite two dimensional
while indicators that incorporate color have perhaps a third dimension :)

and the best thing about my view on color is that its not more = better
in this case more color = more simple :)
e2e4mfck
wow, thats definetly useful! thank you for sharing ;)
Mehr