![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Dec 2007
Posts: 17
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,masters,
Is there any way I can refer to "the price of previous entry buy point" by using Ninja Script Wizard? For example: I want to buy another 100 shares once the current price drop 5% "below the previous buy entry point. So I want to add a condition in the wizard which says: when current price< previous entry price*(1-5%) then buy 100 shares more Since I am not sure "how many bars ago" I entered the previous buy point. Is there any other way refer to the "previous entry price"? thanks, Justmake
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Unfortunately not, you can only referece the open positions' average entry price.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Dec 2007
Posts: 17
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,Ray,
Thanks for reply. Is there any way for me to refer to the previous entry price in Ninja Script language? thanks, Justmake |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You can save the current position's avg entry price into a temporary variable. That will grant you access to it in the future. Definitely doable with custom programming in NinjaScript.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Dec 2007
Posts: 17
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for the answer,Josh.
Do you offer the service of writing customized ninja script ? how would you charge it? Justmake |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
No.
Here is a current list of available NinjaScript consultants available for contract work. http://www.ninjatrader.com/webnew/pa...injaScript.htm
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: May 2010
Posts: 66
Thanks: 6
Thanked 1 time in 1 post
|
Let say the strategy isfilled with quantity of 2.
When i'm trying this, see attachment.. it doesnt work? |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Nov 2009
Location: Denver, CO
Posts: 1,424
Thanks: 0
Thanked 3 times in 3 posts
|
Hi no111,
Can you clarify a little on what you are intending to do? Position.AvgPrice will return the average price of a strategy's position. More info at - http://www.ninjatrader-support.com/H....html?AvgPrice
Tim
NinjaTrader Customer Service |
|
|
|
|
|
#9 | |
|
Member
Join Date: May 2010
Posts: 66
Thanks: 6
Thanked 1 time in 1 post
|
Quote:
|
|
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Nov 2009
Location: Denver, CO
Posts: 1,424
Thanks: 0
Thanked 3 times in 3 posts
|
Hi no111,
This can be done using the wizard as well, and the logic descrsibes.... "if the close of the previous bar is greater than the close of the current bar"
Tim
NinjaTrader Customer Service |
|
|
|
|
|
#11 | |
|
Member
Join Date: May 2010
Posts: 66
Thanks: 6
Thanked 1 time in 1 post
|
Quote:
But I want that only if there is already a position of 2. How do I set that. My purpose is to average in.. |
|
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello no111,
This is controlled through EntriesPerDirection and EntryHandling properties. These properties can be hard coded or set when you run the strategy. If you want to access the current position, you can access this in the wizard under Strategy > Current Position size.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Member
Join Date: May 2010
Posts: 66
Thanks: 6
Thanked 1 time in 1 post
|
Max. entries: 66.
When RSI is below 25; 2 long. So the nextbar should be added by 3 because of: if (Position.Quantity == 2) { EnterLong(3, "long3"); } But it doesn't.. what is wrong? PHP Code:
|
|
|
|
|
|
#14 |
|
Member
Join Date: May 2010
Posts: 66
Thanks: 6
Thanked 1 time in 1 post
|
Does anyone know how to fix this?
|
|
|
|
|
|
#15 |
|
NinjaTrader Customer Service
Join Date: Nov 2009
Location: Denver, CO
Posts: 1,424
Thanks: 0
Thanked 3 times in 3 posts
|
Hi no111,
If the only condition is Quantitiy==2, you could simply enter with 5 contracts initially. If you're looking to add more conditions to that, start by adding Print()s to ensure your condition is being met and entered. More info at - http://www.ninjatrader.com/support/f...ead.php?t=3418 Also, it may take another bar for it to recognize the initial contracts. Check for any errors in the Log tab while running the script.
Tim
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Avg Entry Price in a Strategy | Sartis23 | SuperDOM and other Order Entry Windows | 1 | 03-28-2008 08:17 AM |
| Price Entry and EMA Close | gygraham | Strategy Development | 6 | 03-21-2008 10:06 AM |
| Price Entry and EMA Close | gygraham | Strategy Development | 0 | 03-19-2008 12:38 PM |
| Best way to get priorclose from days previous to the previous | scriabinop23 | General Programming | 3 | 02-02-2008 12:41 AM |
| Incorrect entry price displayed in SuperDOM | EuroFX | Miscellaneous Support | 2 | 09-24-2006 01:34 PM |