So I am left with using prints after almost every single line? Previously, my code worked. But with added code from manual, it started to fail. If you could load it up in your system and run, maybe you as an expert could spot a problem much easier than I would.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Cancel EnterLongStopMarket order if it is not triggered after 5 bars
Collapse
X
-
I watched the screencast video and will try to make something with Visual studio tomorrow. But I still don't understand. If it stops the script at breakpoints, how would I know which part contains an error? If I don't set the breakpoint at "correct" (i.e. containing an error) location, it would just run and that's it?
So I am left with using prints after almost every single line? Previously, my code worked. But with added code from manual, it started to fail. If you could load it up in your system and run, maybe you as an expert could spot a problem much easier than I would.
-
Hello UltraNIX,
The break points would let you step through parts of the code. If you hit a break point and the script is still running, the code up to that break point was not the cause and ran without issue, then it gets to the next break point, and the next, until the error occurs and we know the code in between two break points is the issue.
Using prints we would be seeing the prints appear and know the code before the print is ok. When the prints stop appearing and the error occurs, we know the code below the last print is where the issue is.
Yes, using prints and debugging is also the process we all use to find issues.
(This is why I put together videos that demonstrate the process we use to find issues)
I am not able to debug a script on your behalf.
Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.
That said, I am happy to answer any questions you may have about NinjaScript if you decide to continue.
You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.Chelsea B.NinjaTrader Customer Service
Comment
-
Maybe we could do this the other way around. I've seen in the forums that support department members set up example files that address the issue a forum member is having. Could you do an example file with "SampleMACrossOver" strategy, but instead of EnterLong() you would use EnterLongStopMarket(1, (High[0] + TickSize) , "Long Entry") and add funcionality to auto-cancel the EnterLongStopMarket order, if it is not filled within 2 bars. I hope you could do that.Originally posted by NinjaTrader_ChelseaB View PostI am not able to debug a script on your behalf.
Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.
That said, I am happy to answer any questions you may have about NinjaScript if you decide to continue.
I am sure that other people would also benefit from this technique and could use in their solutions.
By the way, I downloaded 74 strategies from this site for NinjaTrader 8 and NONE use any CancelOrder method.
I again searched in Google, searched in this forum, found couple other topics, tried to adapt the code, still nothing is working. And it's so painful.
Comment
-
Hello UltraNIX,
We have a sample of using CancelOrder in the help guide reference samples area, you can see it here: https://ninjatrader.com/support/help...thod_to_ca.htm
This specifically uses an EnterLongLimit but otherwise contains what you are asking to do. You could modify this to use a stop market if you would like to see that happen.
I would suggest to review all of the reference samples we have in the help guide. We have most of the basic concepts surrounding common tasks so they can be very useful starting points or can be used to copy/paste concepts into your script.
I look forward to being of further assistance.
Comment
-
Yes, I downloaded it 2 days ago and tried to adapt the code, but it didn't work as expected. I think I am running out of options.Originally posted by NinjaTrader_Jesse View PostHello UltraNIX,
We have a sample of using CancelOrder in the help guide reference samples area, you can see it here: https://ninjatrader.com/support/help...thod_to_ca.htm
This specifically uses an EnterLongLimit but otherwise contains what you are asking to do. You could modify this to use a stop market if you would like to see that happen.
I would suggest to review all of the reference samples we have in the help guide. We have most of the basic concepts surrounding common tasks so they can be very useful starting points or can be used to copy/paste concepts into your script.
I look forward to being of further assistance.
Comment
-
Hello UltraNIX,
If you tried something that didn't work out we generally suggest to make a post about that and include a sample of what you tried with the steps to see the problem. We can only assist if we know what problem you are having and because you made modifications we won't know what you did there.
The sample is intended to work as is but if you start making modifications that could certainly prevent it from working. We generally would suggest to use Prints regularly in your code to make sure the code is executing as you expect it to. If its not the prints can help to highlight that as a debugging step. I saw that you were trying to use visual studio to debug it however we won't be able to assist with that specifically so Prints are a good alternative so that we can assist.
Please let me know if I may be of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
56 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
132 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
73 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment