![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Sep 2011
Posts: 14
Thanks: 1
Thanked 1 time in 1 post
|
Im starting to feel like im going to have a lot of questions, any help appreciated. Have the following procedure called from OnBarUpdate()
private void GoLong() { EnterLong("target1"); Print(Time[0].ToString()+ " Position.AvgPrice:" + Position.AvgPrice.ToString()); If i enter as above in my EOD strategy Position.AvgPrice is returning 0 I need to work out if the entry price - yesterdays low is greater than 100 and set my initial stop accordingly Cheers, Jlo |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Jlo,
This will return 0 when not in a position. When you access it at the same time you submit the order, it won't have a chance to be filled yet. Better would be to move it to OnBarUpdate() and check it when you are not flat. if (Position.MarketPosition != MarketPosition.Flat) Print(Time[0].ToString()+ " Position.AvgPrice:" + Position.AvgPrice.ToString());
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Sep 2011
Posts: 14
Thanks: 1
Thanked 1 time in 1 post
|
does that mean that on an end of day strategy i could not set the stop until the following day ie. onbarupdate re-occurs?
thanks for the reply |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
It's possible but requires advanced handling. If you need to base any calculations on position average price but cannot wait until the next bar update, then you can work in our advanced framework with IOrders. OnExecution() handler is used for monitoring for order fills.
http://www.ninjatrader.com/support/h...nexecution.htm
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Sep 2011
Posts: 14
Thanks: 1
Thanked 1 time in 1 post
|
ok thanks, another question if you have the time
How do i tell what the current stop value is for a position ie. I set SetStopLoss("L1", CalculationMode.Price,tmpStop,false); can I look back at this value later on or do i need to store it via a variable Regards, JLo |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Yes, you can access the price of these orders. The technique is shown in this reference sample:
http://www.ninjatrader.com/support/f...ead.php?t=5790
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Position.AvgPrice | Trader.Jon | Strategy Development | 4 | 03-21-2011 08:13 AM |
| Clarification on Position.AvgPrice and Position.MarketPosition | skyholder84 | Automated Trading | 1 | 12-26-2010 09:55 AM |
| Position.Avgprice | james377 | ATM Strategies (Discretionary Trading) | 1 | 11-01-2010 04:24 PM |
| Position.AvgPrice | Faspomy | Strategy Development | 7 | 02-16-2010 10:52 AM |
| Position.AvgPrice | MrBaffalo | Strategy Development | 1 | 05-16-2007 09:01 AM |