NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 10-12-2008, 06:06 PM   #1
ericadam
Member
 
Join Date: Aug 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default Reverse Logic (short) question

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?
ericadam is offline  
Reply With Quote
Old 10-13-2008, 07:44 AM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

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.
NinjaTrader_Ben is offline  
Reply With Quote
Old 10-13-2008, 08:04 AM   #3
ericadam
Member
 
Join Date: Aug 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

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)
ericadam is offline  
Reply With Quote
Old 10-13-2008, 08:40 AM   #4
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,


You are on the right track. Do something like this:


if(....)
EnterLong();
else if(....)
EnterShort();
NinjaTrader_Ben is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 05:23 AM.