Avoiding trading loop in script - NinjaTrader Programming | futures io social day trading
futures io futures trading


Avoiding trading loop in script
Updated: Views / Replies:981 / 5
Created: by mcteague 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 90,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
 

Avoiding trading loop in script

  #1 (permalink)
Elite Member
New York NY USA
 
Futures Experience: Beginner
Platform: esignal, ninjatrader,
Favorite Futures: Stocks
 
Posts: 110 since Oct 2012
Thanks: 54 given, 29 received

Avoiding trading loop in script

This might seem like a silly and basic question. But
When you write a script to take a position when certain conditions occur,
("if this and this and this then do that") how do you make sure the script does not keep taking new positions?

So for example: if I wrote a script to execute a buy of one ES contract when the macd crosses above the signal line, how would I limit the actual number of trades? That particular event could happen a lot.

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)
Elite Member
New York NY USA
 
Futures Experience: Beginner
Platform: esignal, ninjatrader,
Favorite Futures: Stocks
 
Posts: 110 since Oct 2012
Thanks: 54 given, 29 received


I can't believe that I have not done this in so long that forgot how to do a while loop.
Which, in the clarity of a nights sleep, I realize is the answer.

Reply With Quote
 
  #4 (permalink)
Elite Member
NC, USA
 
Futures Experience: None
Platform: None Yet
Favorite Futures: Guitar
 
MrYou's Avatar
 
Posts: 403 since Jun 2011
Thanks: 618 given, 193 received

If NinjaTrader is managing your trades then it will not take another trade beyond "EntriesPerDirection".

Reference this post for an example on how I use the switch and case statements for keeping track of position.

Reply With Quote
 
  #5 (permalink)
Elite Member
Ithaca, NY
 
Futures Experience: Beginner
Platform: Ninjatrader
Favorite Futures: CL
 
Posts: 7 since Oct 2011
Thanks: 1 given, 1 received

If you set EntriesPerDirection to 1, that should stop it.

I believe UniqueEntries does something similar, but I've never used it. I think it stops the entry with the same tag from triggering twice, but I'm not sure...

Reply With Quote
 
  #6 (permalink)
Trading for Fun
College Point, NY (Queens)
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AMP/CQG
Favorite Futures: YM
 
Posts: 63 since Nov 2009
Thanks: 5 given, 20 received


mcteague View Post
This might seem like a silly and basic question. But
When you write a script to take a position when certain conditions occur,
("if this and this and this then do that") how do you make sure the script does not keep taking new positions?

So for example: if I wrote a script to execute a buy of one ES contract when the macd crosses above the signal line, how would I limit the actual number of trades? That particular event could happen a lot.

It's simple. I use a state machine. I have three states: IAmNoPosition, IAmLong, IAmShort. When I have no position, the state is IAmNoPosition. When I enter a long position, the state changes to IAmLong, likewise for short. I can only enter a position when the state is IAmNoPosition, and I can only exit a position from IAmLong or IAmShort. If I exit a position, the state changes to IAmNoPosition.

So in your case, the MACD crossing would change the state from IAmNoPosition to IAmLong (after entering the order, and possibly checking the ack).


Last edited by kandlekid; December 28th, 2012 at 03:44 AM.
Reply With Quote

Reply



futures io > > > > > Avoiding trading loop in script

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Feedback loop for Elite trading journals? drw112 Feedback and Announcements 0 April 2nd, 2012 01:01 PM
S.E.C. Is Avoiding Tough Sanctions for Large Banks kbit News and Current Events 0 February 3rd, 2012 10:00 AM
ATM TRADING USING SCRIPT STRATEGY demit177 NinjaTrader Programming 4 May 29th, 2011 10:37 PM
OODA Loop and Trading...... tradersam Psychology and Money Management 1 May 18th, 2011 03:36 PM
Avoiding Secondhand Trading Psychology Anagami Psychology and Money Management 3 March 28th, 2011 12:28 PM


All times are GMT -4. The time now is 03:28 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, 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 2017-12-18 in 0.10 seconds with 19 queries on phoenix via your IP 54.163.209.109