NinjaTrader Support Forum  
X

Attention!

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


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 03-26-2007, 08:26 PM   #1
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Problem: On enter trade, initial stoploss set to 12 ticks. After a certain profilt is realized I would like to trail with a tighter stoploss, say 6 ticks. Can I do this with the SetTrailStop() in OnBarUpdate? If not, how would this be done? Thank you.
funk101 is offline  
Reply With Quote
Old 03-26-2007, 08:47 PM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

You can call SetTrailStop() in OnBarUpdate and amend an initial trail stop.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 03-26-2007, 09:06 PM   #3
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Ok, next question, what's the best way to calculate, say, a 10 tick profit? At this point, when a 10 tick profit is reached, I want to set the trailing stop from 12 ticks, to 6 ticks. Do I set it up using the ATM functions? or is there a simpler way to test.
funk101 is offline  
Reply With Quote
Old 03-27-2007, 12:57 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

See the Help Guide for information on the Position.GetProfitLoss() method.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-27-2007, 07:03 AM   #5
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Thanks. Got it. Ok, if I have the same strategy on Euro chart, and ER2 chart, does one affect the other? Meaning, do have to go down the Multi-time/Instrument road using BarsArray() or something?
funk101 is offline  
Reply With Quote
Old 03-27-2007, 07:11 AM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Not at all, just apply the same strategy to either chart. Thats it.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-27-2007, 07:26 AM   #7
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Ok, cool. I'm trying the NT 6 & Zen-Fire using CCI, the CCI calculations are not updating OnBarUpdate(), even though I initialized() with

CalculateOnBarClose = false;

What could this be?
funk101 is offline  
Reply With Quote
Old 03-27-2007, 07:34 AM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Do you want the calculations to occur once per bar or on each tick? If once per bar then:

CalculateOnBarClose = true;

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-27-2007, 07:42 AM   #9
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

Sorry, my mistake. I've been working on a strategy that calls a CCI indicator. My strategy was set to
CalculateOnBarClose =
false;



but the indicator was still stuck in the world of

CalculateOnBarClose = true;

this is how we learn, right...?

Thanks for your quick response

funk101 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


All times are GMT -6. The time now is 04:55 AM.