• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

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?
 

rad14733

Well-known member
VIP
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

New member
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...
 

rad14733

Well-known member
VIP
@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.
 

Similar threads

Top