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,BertrandNinjaTrader Customer Service
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
-
I've tried to edit the original script from wizard, where T/P was fixed:
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
-
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:
Code: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 frankthearm, Today, 09:08 AM
|
5 responses
14 views
0 likes
|
Last Post Today, 10:19 AM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
43 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by yertle, Today, 08:38 AM
|
5 responses
15 views
0 likes
|
Last Post Today, 09:45 AM | ||
Started by adeelshahzad, Today, 03:54 AM
|
3 responses
19 views
0 likes
|
Last Post Today, 09:43 AM | ||
Started by bill2023, Yesterday, 08:51 AM
|
6 responses
27 views
0 likes
|
Last Post Today, 09:37 AM |
Comment