Increasing Volume as Price Crosses 9 period SMA

New member
First time here. Just looking for a way, a function or a condition of some sort to meet these conditions

So my current code looks something like this:
Code:
``plot Pricecross = close >= SimpleMovingAvg() and Volume crosses above Volume [-1];``

I have also tried this
Code:
``plot PriceCross = close crosses above SimpleMovingAvg() and if volume crosses above volume()[-1] then 1 else 0;``

This works because it indicates when the price crosses the average, however from what I understand when the script is running its checking the and part of the script and making sure that each successive candle has more volume than the previous, I don't want this to happen. What I want to occur with the script is when the price crosses the moving average, the volume is greater than the previous candle. I'm not asking for my hand held (not that I wouldn't mind) but I'd greatly appreciate it if anyone can give me the tools to make it work. (TOS thinkscript website is kinda barebones).

If it is not possible or I need to elaborate further please let me know.

Code:
``plot Pricecross = close crosses above SimpleMovingAvg() and Volume > Volume [1];``

Code:
``plot Pricecross = close crosses above SimpleMovingAvg() and Volume > Volume [1];``
I appreciate the reply but that doesn't seem to work as it will return the value to 0 on the first bar the volume is not greater than the previous.

I only want to 'check' if the volume is greater than the bar previous IF the close crosses the SMA. (I'm not angry or anything I'm just trying desperately not to confuse anyone who tries to help haha)

Code:
``plot Pricecross = if close crosses above SimpleMovingAvg() then if Volume > Volume [1] then 1 else 0 else 0;``

Code:
``plot Pricecross = if close >= SimpleMovingAvg() then if Volume > Volume [1] then 1 else 1 else 0;``

I got it to work. It was just the matter of changing the cross to greater than! maybe I can change the if statement more and make a third condition where the price is less than and the volume goes up? I don't know. I wouldn't have gotten it without your help. For anyone to reference, above is the modified script

Not sure I understand the logic of this code, but shouldn't it be something like:
Code:
``plot Pricecross = if close >= SimpleMovingAvg() and Volume > Volume [1] then 1 else 0``

Not the exact question you're looking for?

87k+ Posts
290 Online

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?