Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Stopping Trending strategy on chop days
Collapse
X
-
Stopping Trending strategy on chop days
I was looking at reference samples for stopping astretegy on chop days . I want to be able to shut down system after 2 or 3 losers in a row. There was a post in the ref samples that stated just that , I couldnt gather how to impliment it into my strategy can you explain further?Tags: None
-
DinoSchu, we can't program strategies for customers, but we can help you get started. This code snippet identifies when the last three trades have all been losers:
There are quite a few helpful samples (complete with code) here.Code:if (Performance.RealtimeTrades.Count >= 3) { if (Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 1].ProfitPoints < 0 && Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 2].ProfitPoints < 0 && Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 3].ProfitPoints < 0) { // the last three realtime trades have all been losers. do something, like halt the strategy. } }AustinNinjaTrader Customer Service
-
You could for example check into this specific sample here Dino working with the Performance class - http://www.ninjatrader-support2.com/...ead.php?t=4084
Comment
-
Refrences samples dont work !!!
This is what I I put in to the onbar update section .
// After two straight losers stop strategy
if (Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 1].ProfitPoints < 0 &&
Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 2].ProfitPoints < 0)
{
/* A custom method designed to close all open positions and cancel all working orders will be called.
This will ensure we do not have an unmanaged position left after we halt our strategy. */
StopStrategy();
// Halt further processing of our strategy
return;
To halt strategy after two straight losers.. The sample you gave me was the halt basic strategy and when I compile my strategy or tghe sample strategy I get the same error message. StopStrategy does not exist in the current context CS0103 . I get it for both mien and sample . is there something I am missing?
Comment
-
Dino, unfortunately wouldn't know how your custom method is programmed and what issues it may cause - lets try to simplify - did you test the SamplePnl strategy and does it work as you would expect, i.e. stopping trading for the day if either one of the following are happening -
- profit exceeds 1000
- losses exceed 400
- more than 10 trades done
Comment
-
sample works fine
You are correct when running I believe the sample sorked fine. Instead of having dollar amounts as the trugger to turn stategy off . I am looking for consecutive losers . I put in the code below .
http://www.ninjatrader-support2.com/...ad.php?t=25129 and made my adjustments to fit my stategy . the codign to actually turn the system off I cant figure out.
when the last two trades are losers do something like halt trading.
That part i can't seem to write corretly in the system. I know you cant write anything for me . I just want to be able to turn my system off after 2 traight losers no matter what my conditions on the strategy are . If you need more infromation from me just tell my what to copy and paste
Comment
-
Comment
-
I copied the sampl portion and pasted directly into my strategy . Wiht the 1000 and 400 dollar limits and it still wont compile . It does on the sample but not On mine . same error StopStrategy(); ... does not exist in its currecnt context . CS0103 error . just can t figure our what i am missing
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
649 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 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
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
576 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment