is Sleep(0) ok within an indicator? - NinjaTrader Programming | futures io social day trading
futures io futures trading


is Sleep(0) ok within an indicator?
Updated: Views / Replies:59 / 3
Created: by ycomp Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

is Sleep(0) ok within an indicator?

  #1 (permalink)
Trading for Fun
Shanghai
 
Trading Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: liquid
 
Posts: 101 since Sep 2013
Thanks: 9 given, 20 received

is Sleep(0) ok within an indicator?

Is it ok to use Thread.Sleep(0) in OnBarUpdate() of an Indicator ?

I ask because the indicator I was using had a lot of plots and this seems to be the reason it would grind NT8 to a halt so that it took several seconds between clicking on a tab to change to that chart... or for a dialog like Data series to pop up.

I added it, so far so good- very responsive NT8 UI and no problems I can see.. but I'm just wondering if anyone can forsee any problems here.. I'm not a C# or NinjaScript expert.

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Trading Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,539 since Jun 2009
Thanks: 3,716 given, 4,258 received



ycomp View Post
Is it ok to use Thread.Sleep(0) in OnBarUpdate() of an Indicator ?

I ask because the indicator I was using had a lot of plots and this seems to be the reason it would grind NT8 to a halt so that it took several seconds between clicking on a tab to change to that chart... or for a dialog like Data series to pop up.

I added it, so far so good- very responsive NT8 UI and no problems I can see.. but I'm just wondering if anyone can forsee any problems here.. I'm not a C# or NinjaScript expert.

A sleep for 0 millisecond will do nothing. Using a value > 0 will only delay the moment when the buggy/heavy computing stuff will be done, so not useful either. Also it will only delay one thread, not the GUI thread.
Globally a bad idea.

Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following user says Thank You to sam028 for this post:
 
  #4 (permalink)
Trading for Fun
Shanghai
 
Trading Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: liquid
 
Posts: 101 since Sep 2013
Thanks: 9 given, 20 received


sam028 View Post
A sleep for 0 millisecond will do nothing. Using a value > 0 will only delay the moment when the buggy/heavy computing stuff will be done, so not useful either. Also it will only delay one thread, not the GUI thread.
Globally a bad idea.

well it seems to have eliminated my responsiveness problems. And cpu usage also drops for ninjatrader (I have several charts open)

Sleep(0) does something, I have used it in other languages in many situations to reduce cpu usage and delays when you're in a loop... it is similar to Yield() but with differences... https://stackoverflow.com/a/16584612/270143

as you can imagine, you don't want to have to wait several seconds or longer (could be 5 or 10 seconds or more sometimes) every time you switch to another chart tab or open a dialog.

I think this problem is not common because most indicators only use a handful of plots.


Last edited by ycomp; March 18th, 2019 at 01:21 PM.
Reply With Quote

Reply



futures io > > > > > is Sleep(0) ok within an indicator?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

Order Flow Patterns and Set-ups w/Anthony Drager @ Verbal Journal

Apr 18
 

Donít Let One Bad Trade Wipe Out Your Entire Account w/GFF Brokers

Apr 23
 

New CME Micro Indices: New Trading Opportunities w/FuturesTrader71

Elite only
 

Benefits of Trading the Micro E-Minis w/Stage 5 & CME Group

Apr 30
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone managing sleep/work while trading the London Session from the US? mangolassi Currency Futures 28 March 18th, 2019 07:02 PM
Price within X percent of high within Y days eddieo ThinkOrSwim 2 March 30th, 2017 09:50 PM
Overcoming Sleep Issues goldilocks Off-Topic 22 July 18th, 2012 03:30 AM
'high-class hookers refuse to sleep with bankers ..... kbit Off-Topic 1 March 27th, 2012 11:29 AM
Autotrading systems - do you trust them while you sleep? Twiddle Traders Hideout 4 August 17th, 2010 01:05 PM


Tags
c#, data, data series, indicator, indicators, ninja, ninjascript, ninjatrader, nt8

All times are GMT -4. The time now is 11:48 AM. (this page content is cached, log in for real-time version)

Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432 WhatsApp Business, info@futures.io
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.
no new posts
Page generated 2019-04-19 in 0.18 seconds with 14 queries on phoenix