Thanks!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Displacement parameter
Collapse
X
-
-
Thanks gregid, but I only know the very basics of programming so I wouldn't know how to implement this, when I'm looking at the code though, it looks like it might be the same function as "bars ago" in strategy builder wizard.
Update: I've tried the bars ago parameter, but then when I backtest the strategy it doesn't generate any trade and the displaced SMA isn't even shown on the chart.
Update 2: When I try adding the above code to the strategy I get an error message: The name 'Displacement' does not exist in the current contextLast edited by George09; 07-10-2011, 02:08 AM.
Comment
-
George, the Displacement property would only be for indicators visually - in your strategy you would reference to a certain series value x bars ago to create the same effect - do you see any errors in the log tab if you apply your script to the chart you're testing on? If you attach it here we could take a quick look at it as well then and guide further.
Thanks,
Comment
-
Grrrr, sry guys, just found out the problem was that I didn't have any open data connection, so that's why it didn't generate any trade, thanks for your help though!
BTW, Do you know where I can find a code that would execute profit target on SMA cross? As far as I know it's possible to set only fixed profit targets in strategy wizard.
Comment
-
BrettNinjaTrader Product Management
Comment
-
I've tried to edit the original script from wizard, where T/P was fixed:
And a few error messages pop up:SetProfitTarget("", CrossBelow(EMA(34), EMA(50), 1));
The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.CrossBelow(doub le, NinjaTrader.Data.IDataSeries, int)' has some invalid arguments Argument '2': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries' The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.SetProfitTarget (NinjaTrader.Strategy.CalculationMode, double)' has some invalid arguments Argument '1': cannot convert from 'string' to 'NinjaTrader.Strategy.CalculationMode' Argument '2': cannot convert from 'bool' to 'double'
Comment
-
Hello,
Right. CrossBelow() method returns a value of true or false. Not a number which you need a number here.
You would need to use a number here instead. Such as EMA(24)[0] for example would return the indicator value for the current bar.
Let me know if I can be of further assistance.BrettNinjaTrader Product Management
Comment
-
George09,
That line of code will not work.
CrossBelow() does not return a price value. It returns either true or false for if something crossed below something else.
If you want to try and set a new profit target price when something crossed below something else you need to do this:
Please realize that once code has been called once for SetProfitTarget() it will attach itself going forward to any new orders at the prior defined level. This means you need to reset that level when you are no longer in a trade to your initial profit target level. For more information on this please see this reference sample: http://www.ninjatrader.com/support/f...ead.php?t=3222Code:if (CrossBelow(EMA(34), EMA(50), 1)) SetProfitTarget(CalculationMode.Price, somePriceLevel);Josh P.NinjaTrader Customer Service
Comment
-
Hi, thanks for the info Josh. Actually I don't really need to set a new profit target when 2 EMAs cross, but I would rater have the crossing point as profit target. So I this case, should I use this code:
if (CrossBelow(EMA(34), EMA(50), 1)) SetProfitTarget(CalculationMode.Ticks, 0);
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
24 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
120 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
63 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
41 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
45 views
0 likes
|
Last Post
|

Comment