What's the best way to know a trade has been stopped? And is it possible to handle immediately afterward?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Detecting Stopped Trades
Collapse
X
-
Detecting Stopped Trades
I have some code for what happens after I manually exit a trade, which I made my own closeLong/Short functions for, but when a trade gets stopped out, my code will not execute since it was not under my control.
What's the best way to know a trade has been stopped? And is it possible to handle immediately afterward?Tags: None
-
Hello,
Thank you for the post.
I wanted to clarify, are you currently trying to use a NinjaScript strategy to control Manual trades? If so, this is not currently possible using the Strategy logic specifically.
If you are instead using the Addon framework, could you provide details on the logic currently being used? If you are not using the addon framework currently, this is the only way to interact with manual orders correctly. You would need to subscribe to the accounts order events to be able to see manually placed orders. We have a sample of this concept here: https://ninjatrader.com/support/help...ount_class.htm
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Originally posted by gredenko View PostI have some code for what happens after I manually exit a trade, which I made my own closeLong/Short functions for, but when a trade gets stopped out, my code will not execute since it was not under my control.
What's the best way to know a trade has been stopped? And is it possible to handle immediately afterward?
I use OnPositionUpdate to check for any position change. I do not manually exit as you do. I just adjust stops/targets as necessary and use OnPositionUpdate.
This is on ES, and I'm not afraid of partial fills or anything. Stocks would be a little bit of a concern for partial fills.
Comment
-
It seems that I am creating an infinite loop, doing something like what I summarized below.
I was planning on using OnPositionUpdate() as follows.
OnBarUpdate() {
evaluate(); //function that holds all my other function calls.
}
onPositionUpdate() {
evaluate();
}
evaluate() {
//my trade logic for entries, enters longs and shorts inside here while also making other calls that tell me to exit trades manually or adjust profit/stops.
}
My strategy just runs forever until the program crashes, so I'm guessing I can't call a function like this through onPositionUpdate/onBarUpdate. If anyone knows a good workaround, I'd appreciate it. My original issue is that upon exiting a trade, when there's an entry signal on the same bar as the exit, my second trade does not enter. So I wanted to "evaluate" the market again immediately after exiting to see if that would help me catch the next trade. I am using OnEachTick as my Calculate value as well.
What's wrong with doing this?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by cre8able, Today, 01:16 PM
|
1 response
8 views
0 likes
|
Last Post Today, 01:30 PM | ||
Started by chbruno, 04-24-2024, 04:10 PM
|
3 responses
48 views
0 likes
|
Last Post Today, 01:29 PM | ||
Started by samish18, Today, 01:01 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:25 PM | ||
Started by WHICKED, Today, 12:56 PM
|
1 response
8 views
0 likes
|
Last Post Today, 01:17 PM | ||
Started by WHICKED, Today, 12:45 PM
|
1 response
11 views
0 likes
|
Last Post Today, 01:08 PM |
Comment