Reply

Whats the simplest way to expire a variable?

3 replies

Threshold

Customer, bbp_participant, community, 723 replies.

Visit profile

8 years ago #113680

I find myself going through complicated means to “expire” a variable’s price.

is there a simple way to expire a variable’s price after 1 day or 5 for example?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

8 years ago #130326

Not sure what you need to achieve. Can you provide some trading example?

0

Threshold

Customer, bbp_participant, community, 723 replies.

Visit profile

8 years ago #130334

So lets say indicator criteria meet a certain requirement.
 

Assign variable ‘X’ high[1]

After a certain amount of days, whats the best way to “expire” ‘X’ back to 0.
Making a

Assign variable ‘X’ high[1]
 and Assign variable ‘Y’ date

If (‘Y’ + 5 days) = today’s date
Then
Assign ‘X’ 0

Doesnt work because dates include weekends when adding.

0

seaton

Customer, bbp_participant, community, 161 replies.

Visit profile

8 years ago #130707

One simple way is to create a new countdown variable  

 

In the same rule you set the X variable set DaysToExpire

 

e.g. DaysToExpire = 5

 

Have a rule for checking when a new daily bar and subtract 1 from above variable

 

have an expire rule to test if DaysToExpire <= 0 then when it tests true reset your X variable X=0

 

You can also use this approach as a leaky integrator.  Where you may not want to expire exactly in X days but you may want to extent the time based on certain events where could have a rule when an event happens and you want to stay in a bit longer then increments the variable i.e. adds 1  and then you still have the normal event in case above your daily bar where it decrements (subtracts) and  you still have the check when 0 you do what you intended on doing.   so if the events don’t happen then you still get out or reset as intended, if they do then you take advantage of them.

 

Regards,

 

Stephen.

0

Viewing 3 replies - 1 through 3 (of 3 total)