![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Senior Member
|
I want to be able to place a market order and set the stoploss for that order based on some criteria. Right now, this is how I'm doing it:
Code:
myEntry = EnterLong(contracts,"Going Long"); // Enter long market order
if (target > 0) SetProfitTarget(CalculationMode.Ticks, target);
double stop = <some criteria that returns a stop price or 0>;
if (stop > 0) SetStopLoss(CalculationMode.Ticks, stop);
else SetStopLoss(CalculationMode.Ticks, 0);
Price-Dynamics.com
A NinjaTrader Official Partner Visit http://www.price-dynamics.com to learn more about the Rhythm Relay trading system. Yes, you can discretionary or auto-trade with 75%+ accuracy! Use our Contact Us page to request free access to our daily Trader's Lounge where you can see the system in action in a live account! |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Hi, did you use TraceOrders to debug? http://www.ninjatrader-support.com/H...aceOrders.html
You also want to use Print() statements to debug your conditions - http://www.ninjatrader-support2.com/...ead.php?t=3418 To see sample code how to change the price of a StopLoss, please see this reference samlpe - http://www.ninjatrader-support2.com/...ead.php?t=3222
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
cassb,
Also, check the Log tab in your control center. What you have should work.
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"
PureLogikTrading |
|
|
|
|
|
#4 | |
|
Senior Member
|
Quote:
Good thinking, Mr. I do see an error in the log: Calculated stop order price for strategy 'TJ_BPS ' was smaller/equal 0. No stop order placed. I see my mistake now. I should be using CalculationMode.Price, not Ticks. D'oh -- it's always something simple isn't it? ![]() Thanks! Bryan
Price-Dynamics.com
A NinjaTrader Official Partner Visit http://www.price-dynamics.com to learn more about the Rhythm Relay trading system. Yes, you can discretionary or auto-trade with 75%+ accuracy! Use our Contact Us page to request free access to our daily Trader's Lounge where you can see the system in action in a live account! |
|
|
|
|
|
|
#5 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
you got it!
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"
PureLogikTrading |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Aug 2008
Location: Netherlands
Posts: 159
Thanks: 17
Thanked 5 times in 5 posts
|
I've got the same problem with an dynamic stop loss, and I've written an basic strategy (with the use of this example: http://www.ninjatrader.com/support/f...ead.php?t=3222) and I still receive this error:
Code:
**NT** Calculated stop order price for strategy 'TestStrat' was smaller/equal 0. No stop order placed. PHP Code:
Code:
EnterLong. Stoploss value is: 202,539517134472 **NT** Calculated stop order price for strategy 'TestStrat' was smaller/equal 0. No stop order placed. Adjust Stoploss. Stoploss value is: 202,786202213329 Adjust Stoploss. Stoploss value is: 202,982148979163 Adjust Stoploss. Stoploss value is: 203,229759331933 Adjust Stoploss. Stoploss value is: 203,319350754973 Adjust Stoploss. Stoploss value is: 203,429408226915 Regards, |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ATR Stoploss | RSTLNE | Strategy Development | 3 | 09-01-2008 04:47 PM |
| Problem re-setting StopLoss | Burga1 | Strategy Development | 27 | 05-24-2008 10:30 PM |
| EnterLongLimit and stoploss | ct | Strategy Development | 1 | 12-31-2007 09:18 PM |
| Cancel a StopLoss? | Burga1 | Strategy Development | 3 | 12-07-2007 04:03 PM |
| Setting StopLoss via Automation | MarlinTrader | Automated Trading | 1 | 02-03-2005 04:33 AM |