Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
how to enter a trade when price cross an indicator
Collapse
X
-
Hello babouin77,
Thanks for your post.
The exitshortstoplimit has an incorrect signal name.
One issue you will run into is that in real time an order will not fill as fast your code will execute when using Calculate.OnPriceChange or Calculate.OnEachTick so Position.AveragePrice will not be correct until the order fills at the exchange and the exchange sends back an update to the position object with the order status and the entry price (internet transmission time delay).
What I suggest is that in another set you check for Position.MarketPosition == MarketPosition.Long and then set the exit orders. (create another set for the short orders). You will likely need to a bool variable (one for long and short) so that you only do this once for the order. The bool would need to be true in the conditions and then set false in the actions. In the entry order set you would need to set the bool to be true so that on each new order the sets will respond but again only once per entry order.
Comment
-
Good evening,
Is it possible to set a condition based on the price where 2 emas cross using strategy builder? For example, exit the trade if the cross price is below the 50 EMA.
Thanks
Comment
-
Hello conniejforextrader,
As an example:
if (CrossBelow(EMA(7), EMA(50), 1))
{
ExitLong();
}
In the Strategy Builder > Condition Builder select Indicators > EMA, set Period to 7, in the center select CrossBelow, on the right select Indicators > EMA, set Period to 50.
Below is a link to a support article with helpful resources on getting started with NinjaScript and C#. Be sure to watch the 'Automate Your Trading with NinjaTrader's Strategy Builder' training video.
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
51 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
127 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment