Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Help converting a SC spreadsheet formula into Tradingview's pine script
I've tried messing around with pinescript and else if statements but I'm not getting anywhere and don't want to keep wasting hours on something that might take someone a little smarter than me minutes.
Was looking at something along the lines of this but like I say its not happening.
trend = if high[1] > high[2] and low[1] < low[2] and high > high[1] and low >= low[1]
1
else if high[1] > high[2] and low[1] < low[2] and high <= high[1] and low < low[1]
-1
......
else
trend[1]
//Background
col = trend == 1 ? lime : red
bgcolor(col, transp = 80)
If someone can help that you be great.
Cheers
Can you help answer these questions from other members on NexusFi?
It's a work in progress but have this so far which is getting close.
trend = high[1] > high[2] and low[1] < low[2] and high > high[1] and low >= low[1] ? color.lime :
high[1] > high[2] and low[1] < low[2] and high <= high[1] and low < low[1] ? color.red :
high[1]>high[2] and low[1]>=low[2] and high>high[1] and low>=low[1] ? color.lime :
high[1]<=high[2] and low[1]<low[2] and high<=high[1] and low<low[1] ? color.red :
high[1]>high[2] and low[1]>low[2] and high<=high[1] and low>=low[1] ? color.lime :
high[1]>high[2] and low[1]<low[2] and high<=high[1] and low>=low[1] and close[1]>open[1] ? color.lime :
high[1]<high[2] and low[1]<low[2] and high<=high[1] and low>=low[1] ? color.red :
high[1]>high[2] and low[1]<low[2] and high<=high[1] and low>=low[1] and close[1]<open[1] ? color.red :
close[0]>high[1] ? color.lime :
close[0]<high[1] ? color.red : color.lime
bgcolor(trend)
I don't know how to have the trend variable reference itself and it's prior result if no conditions are matched so I'm going to have to create a condition for all scenarios but should get the end result I need once I get time to do that properly.
Sure there is a better way but I'm not smart enough to figure that out.
Consider posting the whole code between the code tags, if it's not confidential.
When you get errors, consider posting screenshots of any errors that are displayed.
Great job with your progress so far!
If I understand you correctly, you may be able to use another variable to hold the old trend. Not positive how it should be done in pine script, but if you are able to post the whole code, between code tags, I may look into it this weekend.
But for now, here's the general idea: Store the old value in a different variable, before the new value is calculated. This way, you'll have access to the old and the new values.
We have coders exclusive group of "pinescripters" on telegram, if and when you run into such an issue where you could use a little suggestion from others, do consider joining there. I won't provide links to avoid breaking any rules, if any, just letting you know since it's rare to see people here be interested in TV coding.
You can ask for group link directly in TV help chat window too.
Your instinct was correct. We do not permit external discussion group links on FIO. The groups may be completely legitimate, and I'm sure you wouldn't have mentioned one that isn't, but our issue here is that it opens an opportunity for unscrupulous vendors to have a shot at future.io members for advertising and promotional purposes, far away from our ability to moderate their content.
I understand your intent was to be helpful. But we feel we need to handle things this way.
Bob.
When one door closes, another opens.
-- Cervantes, Don Quixote
Yup, that's always an issue. And it is completely understandable, if I was running the forum I would do the same. For exactly same reasons we also don't call that group "official" help forum, because its a free social media grp outside of TV itself and is free for all and we can't do anything if someone scams someone else.