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 04-06-2012, 04:58 PM   #1
raefon72
Member
 
Join Date: Jun 2010
Location: gold coast australia
Posts: 92
Thanks: 15
Thanked 6 times in 5 posts
Default Stop loss errors

Hi Guys,

I am having a problem with multiple entires. When I use the term Firstentry it sets the stop to my entry price not the danchain chanel low. If I dont use the entry name it ignores the stop. If I dont use an entry name when I enter its ok.

Code:
 
// If a long position is open, allow for stop loss modification to breakeven
else if (Position.MarketPosition == MarketPosition.Long)
{

barcounter = barcounter +1 ;
if (DonchianChannel(stoptrail).Lower[1]> Position.AvgPrice)
{ 
SetStopLoss("Firstentry", CalculationMode.Price, DonchianChannel(stoptrail).Lower[1] - stoptrailoffset* TickSize , false);
//SetStopLoss("Secondentry", CalculationMode.Price, DonchianChannel(stoptrail).Lower[1] - stoptrailoffset* TickSize , false);
//Print("Firstentry last value= "+(DonchianChannel(stoptrail).Lower[1] - stoptrailoffset* TickSize) + " " + Close[0]+ " " +(Time[0].ToString()) );
}
}


Attached Images
File Type: gif Stoploss error NT7.png (98.2 KB, 5 views)
raefon72 is offline  
Reply With Quote
Old 04-07-2012, 11:19 AM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

raefon,

The "Firstentry" would tie that stop loss to the entry that has entrance signal string "Firstentry".

What is stoptrailoffset? How is it defined?
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-07-2012, 02:30 PM   #3
raefon72
Member
 
Join Date: Jun 2010
Location: gold coast australia
Posts: 92
Thanks: 15
Thanked 6 times in 5 posts
Default

Stoptrailoffset is a private int variable. Its an offset below the low period. Its the entry name that seems to be the problem however.
raefon72 is offline  
Reply With Quote
Old 04-07-2012, 03:37 PM   #4
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

raefon,

Could you post more of our code?
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-07-2012, 04:24 PM   #5
raefon72
Member
 
Join Date: Jun 2010
Location: gold coast australia
Posts: 92
Thanks: 15
Thanked 6 times in 5 posts
Default

attached as zip
Attached Files
File Type: zip NT7Forumpost.zip (9.3 KB, 3 views)
raefon72 is offline  
Reply With Quote
Old 04-09-2012, 12:52 AM   #6
ramfx
Junior Member
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
Default hi am get some problem in stop loss

hi,
am also get some problem in stop loss.how may i solve this .
ramfx is offline  
Reply With Quote
Old 04-09-2012, 07:24 AM   #7
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

raefon,

DonchianChannel(stoptrail).Lower[1]> Position.AvgPrice

The DonchainChannel is not necessarily greater than the Position.AvgPrice initially. You would want to set an initial stop loss before you enter the trade.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-09-2012, 07:27 AM   #8
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

ramfx,

If you could post your code I'd be happy to take a quick look.
NinjaTrader_AdamP 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
How do I change the stop-loss order into a stop-loss-limit order? op684 ATM Strategies (Discretionary Trading) 10 01-23-2011 03:02 AM
Turning on and off the trailing stop feature of a stop loss set by an ATM ohowie ATM Strategies (Discretionary Trading) 2 01-12-2011 03:19 AM
Stop market order for stop loss submitted by NinjaScript-created ATM strategy cyrotiv Strategy Development 6 10-05-2009 11:03 AM
Order Entry Property: Use stop market for stop loss orders higler SuperDOM and other Order Entry Windows 7 07-02-2007 09:06 AM
Stop Loss Orders activated by number of trades past stop level DoveforUsAll Suggestions And Feedback 1 02-08-2006 01:19 AM


All times are GMT -6. The time now is 06:36 AM.