![]() |
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 |
|
Member
Join Date: Dec 2008
Posts: 33
Thanks: 0
Thanked 0 times in 0 posts
|
I want to set my stop loss based on a fixed calculation of 1 tick above the high of the day or 1 tick below the low. How do I do this? Can I use:[/font]
SetStopLoss("", CalculationMode.Ticks, CurrentDayOHL().CurrentHigh[1] + 5 , false); |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
If you want to tell it an absolute price you should be using CalculationMode.Price and not .Ticks.
Also, you should not be doing a simple "+ 5". It should be "+ 5 * TickSize" to ensure accurate tick size values. Finally, this line would only work in OnBarUpdate(). You cannot do this from Initialize().
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Dec 2008
Posts: 33
Thanks: 0
Thanked 0 times in 0 posts
|
My concern about on bar update is that if I lose connection my stop will not activate is this a true concern?
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
No matter where in your code you put the command it will not help you if you lose connection before the order was placed. All you have to do is call the Set() method before you do the Enter() method and it will be placed. Depending on the brokerage technology you are connected with will determine whether or not that order is actually sitting at the exchange or still on your local PC. See this article for more information: http://www.ninjatrader-support2.com/...ead.php?t=5349
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Dec 2008
Posts: 33
Thanks: 0
Thanked 0 times in 0 posts
|
I use IB and based on the link you provided orders are sitting on their server. So is it correct that when my program triggers my entry my stop of 1 tick below the low or above the high will be calculated and simultaneously transmitted to IB even if using the on bar update?
You also said: "All you have to do is call the Set() method before you do the Enter() method and it will be placed" Can you explain with a sample. I am not following. |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
That is correct. Just call Set() before you call Enter(). When the code evaluates an Enter() and gets you into a position, the Set() will be activated exactly the same as if it were in Initialize().
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Dec 2008
Posts: 33
Thanks: 0
Thanked 0 times in 0 posts
|
One last question:
How do I create a copy of a ninja script once outside of the wizard. I have created a copy in the wizard by just changing the name but cannot figure out how to do it outside the wizard. Thanks for all your help |
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You can go to Edit NinjaScript -> select your file and open it in the NinjaScript Editor. From there just right click and select Save As.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Move Stop Loss Based On Last Candle | r2kTrader | Strategy Development | 16 | 06-12-2009 07:25 AM |
| Recalculating position size based on account size, % risked and stop loss | clivehunt | Strategy Development | 18 | 03-22-2009 11:25 AM |
| How do I set stop loss based on low of setup bar? | ninjablanks | General Programming | 1 | 12-12-2008 07:12 AM |
| ATR based Stop Loss | moon_rainz | Strategy Development | 2 | 07-17-2008 11:42 PM |
| Alternative to tick based/bar based strategy calculation? (i.e every minute/X ticks) | Elliott Wave | Strategy Development | 9 | 07-11-2008 03:11 AM |