![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Aug 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
What is the code for the reverse logic of the EnterLong on this snippet of straetgy code taken from: http://www.ninjatrader-support.com/H...lPressure.html ------------------------------------------ protected override void OnBarUpdate() { // Looking for a long breakout signal if (Close[0] > DonchianChannel(20).Upper[5]) { // !! See notes below !! if (Historical || BuySellPressure().BuyPressure[0] > 70) EnterLong(); } } ------------------------------------------ How would it be coded to go short & cover a long position lets say and vise versa?
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
This is basically the opposite of what you have below: if (Close[0] < DonchianChannel(20).Lower[5]) { if (Historical || BuySellPressure().SellPressure[0] > 70) EnterShort(); } Please note that BuySellPressure will only work in real-time operation and not in backtesting.
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Aug 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for the reply. I got that far. Let me correct my initial question. How is the code structured (nested, i think) so that it looks to see if the long condition exists first and go long (and/or cover a short), otherwise looks for the short condition and goes short (and/or to cover a long)
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
You are on the right track. Do something like this: if(....) EnterLong(); else if(....) EnterShort();
Ben
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MRO logic question | Burga1 | Strategy Development | 4 | 04-09-2008 08:56 PM |
| simple order management logic problem | Willl | Strategy Development | 3 | 03-27-2008 11:13 AM |
| Ninjascript logic and Live Orders | ohowie | General Programming | 3 | 01-19-2008 09:10 AM |
| Order Pending Logic | Oli | Automated Trading | 12 | 04-02-2007 03:13 AM |
| Order logic and OnBarUpdate | MrBaffalo | Strategy Development | 2 | 01-29-2007 04:54 AM |