Buy and Sell indicator

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I need input on this code it will not work, what is wrong?

# Trend Indicator for ToS

def Currentsum ;
def SDevCurrent;
def BBCurrentAve;
def Currentsumdirection;
#def CurrentSumPosture;

Currentsum = If(ExpAverage(close, 3) > ExpAverage(close, 7), 1,0) +
If(ExpAverage(close, 2) < ExpAverage(close, 5),-1,0)
+Currentsum[1];
Currentsumdirection = Currentsum - Currentsum[1];
BBCurrentAve = Average(Currentsum, 10);
SDevCurrent = StandardDeviation(Currentsum, length = 10);


plot Trendline = Currentsum ;

plot BBlower = BBCurrentAve - SDevCurrent * 1;
plot BBUpper = BBCurrentAve + SDevCurrent * 1;
AddCloud(BBLower, BBUpper, Color.red, Color.yellow);

#CurrentSumPosture = If(BBlower+Currentsum<0,BBlower+Currentsum,If((BBLower+Currentsum>=0 and Currentsum+BBUpper<=0),0,If(Currentsum+BBUpper>0,BBUpper-Currentsum,0)));
#AddCloud(CurrentSumPosture, -CurrentSumPosture, Color.red, Color.green);
 
@PSandy Where did the code come from and is it related to this topic...??? Is this code you wrote, or did you find it elsewhere...??? All you've said is it doesn't work without any background as to what it should be doing... The more information we have the better we can be of assistance...
 
@PSandy Trying to get your logic in this, are you looking for the start of a downtrend?
It seems this event will only occur occasionally, I am not sure how you get a trend line from it. I think you need to plot an arrow where this condition currentsum is true. And maybe replace the " + " in your equation with an " and ".
 
@PSandy Where did the code come from and is it related to this topic...??? Is this code you wrote, or did you find it elsewhere...??? All you've said is it doesn't work without any background as to what it should be doing... The more information we have the better we can be of assistance...
This code was given to me, it is supposed to indicate when money goes into a stock and when money is flowing out.
@PSandy Trying to get your logic in this, are you looking for the start of a downtrend?
It seems this event will only occur occasionally, I am not sure how you get a trend line from it. I think you need to plot an arrow where this condition currentsum is true. And maybe replace the " + " in your equation with an " and ".
This indicator is supposed to show money going in and money going out.
 
I need input on this code it will not work, what is wrong?

I think the issue here is that this is meant to be a lower study but it doesn't declare that in the code. If you put it in the upper area of the chart the values aren't scaled to be relevant to current prices and it only appears near price coincidentally on some symbols.

Add a line to the code that says...
Ruby:
declare lower;
...and in your studies, drag it to one of the study slots labeled Lower.
 
I think the issue here is that this is meant to be a lower study but it doesn't declare that in the code. If you put it in the upper area of the chart the values aren't scaled to be relevant to current prices and it only appears near price coincidentally on some symbols.

Add a line to the code that says...
Ruby:
declare lower;
...and in your studies, drag it to one of the study slots labeled Lower.
I think the issue here is that this is meant to be a lower study but it doesn't declare that in the code. If you put it in the upper area of the chart the values aren't scaled to be relevant to current prices and it only appears near price coincidentally on some symbols.

Add a line to the code that says...
Ruby:
declare lower;
...and in your studies, drag it to one of the study slots labeled Lower.
Where would you recommend to put this line code?
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
343 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top