// Conditional on OnBarUpdate()
if (( CrossAbove(KPA900(), KPAutoStop(), 1)) && TipoTrade == "Venta")
{
// Debug Flag
Print (" KPA900 Cruza sobre KPAutoStop en Variable de Trade:" + TipoTrade+ " Entrando con Posiciones activas: " + Position.Quantity.ToString());
// Exit from positions on next bar :(
ExitShort ( );
// Control Var
TipoTrade = "Libre";
// message to Alert Windows
Alert("MyAlert2", Priority.High, "Saliendo de una Venta. Estado Bandera: " + TipoTrade , @"C:\Archivos de Programa\NinjaTrader 6\sounds\Alert2.wav", 60, Color.LightPink, Color.Black);
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Instant Exits and Bars updates
Collapse
X
-
Instant Exits and Bars updates
Hi! I trying to make instant exits with indicator crossovers! But always exits in next bar update. Itīs possible to get exit at moment? here my sample:
Code:Tags: None
-
Ok, I put CalculateOnBarClose = false; in my Initialize(), no problem, but the ExitShort and ExitLong orders, execute in next bar, not in current bar or bar in progress!
Itīs possible to exit inmediatly with current bar, donīt wait to next bar, to execute exits commands?
Comment
-
Hi Josh,
I Will check and reforced Time[0], thanks for the help!
Now I think that the command, the parameter 1, for 1 bar ago will be 0!:
I will change for it:Code:( CrossAbove(KPA900(), KPAutoStop(), 1)
could be it the event that lag the exitshort-long?Code:( CrossAbove(KPA900(), KPAutoStop(), 0)
I will take note of all events and time and will post again!
Thx!
Comment
-
You would normally use 1. I suspect it is simply your indicators not crossing till the end of the bar. You can check this by printing out the values of the indicators.
If you do a crossabove on say SMA(5) over SMA(20) you will see it executes immediately if you have CalculateOnBarClose=falseJosh P.NinjaTrader Customer Service
Comment
-
OK, I check CrossBelow//Above with 0 instead of 1, and dont work
.
But I try with 1 and Work perfectly!
2 o 3 seconds of delay, but work properly. Thanks to all!!!
The checks in debug with Print(), Time[0] and the ExitLong/Short, show that command executed with the indicator, all work perfectly in Real Time.
Another Question: What command or method i use for delays? Thread.Sleep() work???
Comment
-
CrossAbove/Below missing crosses
I have a strategy that I am working on that is looking for crosses from two values of an indicator. Entries seem to be working as expected, but the Exits are missing crosses of the two variables and therefore missing the exits.
Is there something I should be looking for to get the behavior on the exits?
Here is the code:
// Long Entry
if ((CrossAbove(RMO(2,10,30,81).ST1, 25, 2)) &&
(RMO(2,10,30,81).ST4[0] > 0))
{
EnterLongLimit(GetCurrentBid(), "RMO Long Entry");
}
// Long Exit
if ((CrossBelow(RMO(2,10,30,81).ST1, RMO(2,10,30,81).ST3, 1)) &&
(CrossBelow(RMO(2,10,30,81).ST1, RMO(2,10,30,81).ST2, 1)) &&
(Position.MarketPosition == MarketPosition.Long))
{
ExitLong("RMO Long Entry");
}
Comment
-
Hello,
I am sorry, I am not familiar with the RMO indicator.
I suggest testing the logic with a default indicator and see if the logic is correct. If it works with a default indicator I would check the custom indicator values.
Also try using Print() and TradeOrders to debug:
DenNinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
580 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
335 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
102 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment