NexusFi: Find Your Edge


Home Menu

 





How do I set up a timer for when a condition is true


Discussion in TradeStation

Updated
    1. trending_up 1,818 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

How do I set up a timer for when a condition is true

  #1 (permalink)
Mgem
New York City
 
Posts: 15 since Apr 2021
Thanks Given: 2
Thanks Received: 0

I am trying to set up a timer for when a condition is true. For example if Condition1 = true then start timer. If timer > 30 seconds then sell next bar O. Thanks!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Exit Strategy
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
18 thanks
The Program
18 thanks
  #2 (permalink)
 bchip 
Torino, Italy
 
Experience: Advanced
Platform: TradeStation
Trading: ES,YM,CL,GC
Posts: 132 since Sep 2017
Thanks Given: 160
Thanks Received: 116


Mgem View Post
I am trying to set up a timer for when a condition is true. For example if Condition1 = true then start timer. If timer > 30 seconds then sell next bar O. Thanks!

Hi

You'll probably use something like

vars: ChkTime(0);

if (some cond) then ChkTime = CurrentTime + 30


if (CurrentTime > ChkTime) then Sell at next bar



CurrentTime will return a value of 101525 for 10:15:25 AM

I think the caveat here is that TS Engine might only run per bar,
not necessarily per second, so if your using a 15min timeframe it might miss the signal

Reply With Quote
Thanked by:
  #3 (permalink)
Mgem
New York City
 
Posts: 15 since Apr 2021
Thanks Given: 2
Thanks Received: 0



bchip View Post
Hi

You'll probably use something like

vars: ChkTime(0);

if (some cond) then ChkTime = CurrentTime + 30


if (CurrentTime > ChkTime) then Sell at next bar



CurrentTime will return a value of 101525 for 10:15:25 AM

I think the caveat here is that TS Engine might only run per bar,
not necessarily per second, so if your using a 15min timeframe it might miss the signal



Awesome I think this is close to what I was looking for. So then if I were to say


if (cond1 = True) then ChkTime = CurrentTime + 30


if (cond1 = False) then ChkTime = 0


Then it would pretty much restart the timer if Cond1 = False right?

Reply With Quote
  #4 (permalink)
 bchip 
Torino, Italy
 
Experience: Advanced
Platform: TradeStation
Trading: ES,YM,CL,GC
Posts: 132 since Sep 2017
Thanks Given: 160
Thanks Received: 116


Mgem View Post
Awesome I think this is close to what I was looking for. So then if I were to say


if (cond1 = True) then ChkTime = CurrentTime + 30
if (cond1 = False) then ChkTime = 0


Then it would pretty much restart the timer if Cond1 = False right?

I wouldnt make ChkTime = 0

The 2nd part of the code will then read:
if (CurrentTime > 0) then Sell at next bar

Which will be true most of the time, so you'll keep getting sell signals
if (cond1 = True) then ChkTime = CurrentTime + 30

You cant make it more than the CurrentTime either (with if False) as it continuously overwrite it.
So you should only have the red text

Reply With Quote




Last Updated on April 28, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts