NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 02-19-2010, 10:20 AM   #1
ericgood
Member
 
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default Auto order Entry with certain conditions

hi,

i am trying to program a strategy with the wizard that will automatically enter a long or short position when the price is a certain # of tics from a starting price. For example, if the starting current price is 1100.00, then if the price rises to 1100.75 (3 tics), i want NT to automatically enter a short position with one contract.

i have attached some screen shots of what i did. it does not work so far. can you advise as to what i am doing wrong and what might fix it?

Thx

eric
Attached Images
File Type: jpg Auto entry strat1.JPG (52.5 KB, 8 views)
File Type: jpg Auto entry strat2.JPG (64.8 KB, 6 views)
File Type: jpg Auto entry strat3.JPG (98.5 KB, 5 views)
ericgood is offline  
Reply With Quote
Old 02-19-2010, 10:32 AM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Eric,

The fill isn't going to happen because you're adding the current bid to your variable current price. This value will equal 2200+. You're then comparing it to a value around 1100.

On the condition builder you will want to select a reasonable price input on the left. This could be Bid, Ask, or Close but not offset by 1100 points.
NinjaTrader_RyanM is online now  
Reply With Quote
Old 02-19-2010, 11:00 AM   #3
ericgood
Member
 
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

Ahhh...right. ok - so i set the offset back to 0. and still does not work. wondering if i need to do something to let NT know that the start price is 1100.00 and so when it gets 3 ticks away from 1100.00 it will put an order in for me. am i thinking right? how would i do that?

eric
ericgood is offline  
Reply With Quote
Old 02-19-2010, 11:36 AM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Eric,

You can use EnterShort() after a conditional statement like:

Code:
 
if (Close[0] == 1100.75)
   EnterShort();
If the last traded price equals 1100.75 then enter short. If you want to work with your CurrentPrice, then:

Code:
 
if (Close[0] == CurrentPrice + TickSize * 3)
   EnterShort();
Condition Builder - Price Data Comparisons
Last edited by NinjaTrader_RyanM; 02-19-2010 at 11:53 AM.
NinjaTrader_RyanM is online now  
Reply With Quote
Old 02-19-2010, 12:48 PM   #5
ericgood
Member
 
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

thanks. is there a way to do this with the wizard?? if not what would be the best way to write this after unlocking the code?

thanks for your excellent help.

EG
ericgood is offline  
Reply With Quote
Old 02-19-2010, 01:53 PM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Eric,

Yes, it can be done in the wizard. The link there goes over working with price data in the condition builder. The next article discusses using offsets.

http://www.ninjatrader-support.com/H...mparisons.html



http://www.ninjatrader-support.com/H...ItemValue.html
NinjaTrader_RyanM is online now  
Reply With Quote
Old 02-19-2010, 01:57 PM   #7
ericgood
Member
 
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

Ok - this works! now, how would i write it so that it will only happen once during the life of the strategy (until i use the strategy the next time)? do you know what i mean?

Eg

Code:

if (Close[0] == CurrentPrice + TickSize * 3)
EnterShort();
ericgood is offline  
Reply With Quote
Old 02-19-2010, 02:06 PM   #8
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Eric,

I answered a similar question yesterday. Here's the thread:
http://www.ninjatrader-support2.com/...ad.php?t=25943

Most likely won't be possible using only the condition builder.
NinjaTrader_RyanM is online now  
Reply With Quote
Old 02-21-2010, 06:45 PM   #9
ericgood
Member
 
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

Ryan,

thanks for the concept - how would i apply this to the current conditions i have written so that it only enters and order one time at that price? here is the condition that i have written so far.

if (Close[0] == StartPrice + TickSize * 3)
EnterShort();
thanks

EG
ericgood is offline  
Reply With Quote
Old 02-22-2010, 09:19 AM   #10
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Eric,

You can specify the quantity of the order.

EnterShort(int quantity)

http://www.ninjatrader-support.com/H...nterShort.html
NinjaTrader_RyanM is online now  
Reply With Quote
Old 02-22-2010, 09:34 AM   #11
ericgood
Member
 
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

are you saying that if i only want one order entered only one time at that price that i would type the following?:

EnterShort(int 1)
ericgood is offline  
Reply With Quote
Old 02-22-2010, 09:42 AM   #12
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Eric,

No, that won't work. The "int quantity" just displays the input type expected, an integer. If you want to enter one order to Enter Short, you can use:
EnterShort(1);

The condition will continue to be evaluated on subsequent bars and enter based on the settings defined in the properties EntriesPerDirection and EntryHandling.

http://www.ninjatrader-support.com/H...Direction.html
NinjaTrader_RyanM is online now  
Reply With Quote
Old 02-22-2010, 10:45 AM   #13
ericgood
Member
 
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

ok, i understand that. what i am after is after EnterShort(1) happens at that price, if the price moves up or down away from the entry price and then comes back to it again, i don't want it to EnterShort(1) again at that price.

so if the price hits 1100.00, say, the strategy will enter one short contract. then the price moves down to 1099.00, turns around and then come back up and hits 1100.00 again - when it does this, i DO NOT want the strategy to enter a short contract. i only want that to happen the first time the price hits 1100.00. Hope this makes sense.

how would i program this scenario?

thx
EG
ericgood is offline  
Reply With Quote
Old 02-22-2010, 11:20 AM   #14
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Eric,

If you are currently in a short position and don't want to accept more signals to enter short, then this is managed with EntriesPerDirection and EntryHandling properties.

If you are currently flat and don't want to accept further entry signals beyond your first, one approach to this is covered in the thread I linked earlier.
http://www.ninjatrader-support2.com/...ad.php?t=25943
NinjaTrader_RyanM is online now  
Reply With Quote
Old 02-22-2010, 02:38 PM   #15
ericgood
Member
 
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

its not that i don't want to accept any more order entries, i just don't want any more orders at the same price.

I would like to receive order entries to go short at 1100.00, 1101.00, and 1102.00 and each only once, no matter how many times the price retraces to these levels.

if i get filled short 1 ct at 1100.00, and then the price goes to 1099.00 and then goes to 1101.00, i don't want to receive another order at the 1100.00, but i do want to receive the first 1 ct order at 1101.00.

make sense what i am wanting? let me know what you think.

EG
ericgood is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancelling Order/Entry Order filled cancels all other entry orders ScottB ATM Strategies (Discretionary Trading) 2 06-03-2009 12:19 PM
Auto-filling order qty in Basic Entry based on available funds in account? Hauser ATM Strategies (Discretionary Trading) 1 05-06-2009 02:32 PM
AUTO Entry MANUAL Exit Khalaad Automated Trading 8 03-02-2009 07:03 AM
Any reason NT would not enter an order if conditions are met? dendy Strategy Analyzer 14 09-11-2008 11:23 AM
how to submit order when the first tick met the conditions MoreYummy Automated Trading 3 08-15-2008 08:22 AM


All times are GMT -6. The time now is 12:45 PM.