![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Eric,
You can use EnterShort() after a conditional statement like: Code:
if (Close[0] == 1100.75) EnterShort(); Code:
if (Close[0] == CurrentPrice + TickSize * 3) EnterShort();
Ryan M
NinjaTrader Customer Service
Last edited by NinjaTrader_RyanM; 02-19-2010 at 11:53 AM.
|
|
|
|
|
|
#5 |
|
Member
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
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(); |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Eric,
You can specify the quantity of the order. EnterShort(int quantity) http://www.ninjatrader-support.com/H...nterShort.html
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Member
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
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) |
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Member
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Member
Join Date: Mar 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |