Thanks for the help!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Exit After 2 Bars Complete
Collapse
X
-
Exit After 2 Bars Complete
Wondering how to use Condition Builder to tell my strategy to exit a position after 2 Renko bars have completed. Looks like all my big losses involve holding beyond that point so closing the position even if profit target isn't hit after 2 bars would be very helpful.
Thanks for the help!Tags: None
-
Please note ...
I already tried "Bars Since Entry" = "2". "Bars Since Entry" > "2". "Bars Since Entry" =/> 2". "Bars Since Entry" = "3". With each of the above, "action" was "Exit Long" and "Exit Short".
I also tried unchecking the "calculate at close" box (shot in the dark, one of hundreds).
Deeply appreciate any help you can offer. Seems a simple parameter to input but it's giving me fits.
-
Thanks but ...
... that is exactly what I've been trying and backtesting shows trades holding for 3 and 4 bars before exiting due to indicator reversal. Attached screen shots show my condition builder setup for getting out after 2 renko bars complete. Any other ideas? Anyone? Ninja "watchers"?
Comment
-
can you try on a non-renko chart, say 3 minutes, and see if it works there?Originally posted by TakingStock12 View Post... that is exactly what I've been trying and backtesting shows trades holding for 3 and 4 bars before exiting due to indicator reversal. Attached screen shots show my condition builder setup for getting out after 2 renko bars complete. Any other ideas? Anyone? Ninja "watchers"?
there is also this post, where someone had to name their entries..i'm not sure what your entries look like, I guess you didn't name them?
Comment
-
Sledge ...
... excellent suggestions but no change on the 3 minute chart test and the referenced thread requires the use of ninjascript/coding which is beyond me. Seems rather odd that a function clearly available in the Condition Builder should simply not work. Frustrating. Such a simple thing condition to boot.
Again - thanks very much for the very thoughtful ideas Sledge. I do appreciate your effort to help.
Comment
-
-
Originally posted by TakingStock12 View Post... excellent suggestions but no change on the 3 minute chart test and the referenced thread requires the use of ninjascript/coding which is beyond me. Seems rather odd that a function clearly available in the Condition Builder should simply not work. Frustrating. Such a simple thing condition to boot.
Again - thanks very much for the very thoughtful ideas Sledge. I do appreciate your effort to help.
I couldn't figure out a direct assignment in the wizard == 2.. but i used variable0.
set1 : if simple (ema>sma).. do: enterlong(defaultquantity, ""), variable0=2
set2: if BarsSinceEntry()==Variable0, do: exitlong("","");
i have no other conditions, calculateonbarclose=true.. it appears to exit on bar #3 on the renko chart with brick = 2. (which would be correct, unless caculatoronbarclose=false)
Comment
-
Request ...
First, thank you so much for actually trying to figure this out! Very kind. Since I've never used user variables, would you mind posting screen shots of your inputs? It would be a great help although I will be trying to figure out how to make those inputs on my own in case you haven't the time. Again, thanks!
Comment
-
Originally posted by TakingStock12 View PostFirst, thank you so much for actually trying to figure this out! Very kind. Since I've never used user variables, would you mind posting screen shots of your inputs? It would be a great help although I will be trying to figure out how to make those inputs on my own in case you haven't the time. Again, thanks!
code ended up like this with view code:
Code:protected override void Initialize() { CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (EMA(6)[0] > SMA(14)[0]) { EnterLong(DefaultQuantity, ""); Variable0 = 2; } // Condition set 2 if (BarsSinceEntry() == Variable0) { ExitLong("", ""); } } #region Properties [Description("")] [GridCategory("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } #endregion
Comment
-
But how did you get Condittion set 1 to include Variable0=2? Been trying to duplicate that to no avail. Sorry to be a bother.
Comment
-
Add button? i can post a pic in the morning..Originally posted by TakingStock12 View PostBut how did you get Condittion set 1 to include Variable0=2? Been trying to duplicate that to no avail. Sorry to be a bother.
post how u did ==2..
i cant find that. im on nt 7.1000.08..??
Sent from HTC Hero on the NOW network!
Comment
-
here ...
From the code you were kind enough to show:
// Condition set 1
if (EMA(6)[0] > SMA(14)[0])
{
EnterLong(DefaultQuantity, "");
Variable0 = 2;
I'm using 7.10000.08 too.
In condition builder, I went to the "do" portion of set 1 where I have the EnterLong(DefaultQuantity,"") already there, hit the "..." to edit that hoping to enter the "Variable0 = 2" which is showing in your code but I can't figure out how to get the variable to input.
Comment
-
See the attachment.
Originally posted by TakingStock12 View PostFrom the code you were kind enough to show:
// Condition set 1
if (EMA(6)[0] > SMA(14)[0])
{
EnterLong(DefaultQuantity, "");
Variable0 = 2;
I'm using 7.10000.08 too.
In condition builder, I went to the "do" portion of set 1 where I have the EnterLong(DefaultQuantity,"") already there, hit the "..." to edit that hoping to enter the "Variable0 = 2" which is showing in your code but I can't figure out how to get the variable to input.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 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
573 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
575 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment