How would I go about making a trigger

Enfenete1993

New member
So I've been trying make a trigger when signal is made it adds 1 to a value and when it crosses below sets it back to 0

Examples
Trigger =0
Buy = When signal is shown and trigger=0 then set trigger too =1

sell= when signal is shown and trigger=1 then set trigger=0

how would I make this possible?
 
Your best bet is to setup a counter that uses recursion... Searching for those two words should yield some results... The issue is that you need to save the state of your counter variable...

I'm assuming that a counter is what you want... Or are you simply looking to have multiple criteria be true as your signal...??? The more details your provide, the better we can assist you...
 
How do you use a counter and this is the best I can really explain I'm just trying to have a array that holds one number that can be altered by signal change
Your best bet is to setup a counter that uses recursion... Searching for those two words should yield some results... The issue is that you need to save the state of your counter variable...

I'm assuming that a counter is what you want... Or are you simply looking to have multiple criteria be true as your signal...??? The more details your provide, the better we can assist you...
 
@Enfenete1993 TOS doesn't support Arrays which is why I referenced state... If you have some code written please post it here so we have a better idea of what you are trying to accomplish... Perhaps you aren't adequately conveying exactly what it is that you want... What is the intended purpose of what you are doing...??? The code will tell us that...
 
@Enfenete1993,

I think you may be looking for a structure like this (caution - untested pseudocode):

Code:
def myVar;

if {some condition} then
   myVar = {new value};
else
   myVar = myVar[1];

The point is to define the variable without assigning it a value, then create an if/then statement which determines if it needs to be changed or not. If so, change it. If not, set it equal to the previous bar's value to carry that value forward. I hope this is aiming you in the right direction.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
277 Online
Create Post

Similar threads

Similar threads

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