Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Limit orders
Collapse
X
-
Limit orders
I need to be able to cancel limit orders that are not filled. I am using the wizard. I am sure this is easy, but I am new to this and its not jumping out at me.Tags: None
-
Hmm...must be something else causing this then. It didn't do this in backtesting, but it does seem to be leaving those orders in place after the bar closes. I probably screwed it up somewhere else. Thanks.
Comment
-
Let us say you have a simply condition for your limit order.
Code:if (Close[0] > Open[0])
Josh P.NinjaTrader Customer Service
Comment
-
Sorry, what I meant is a stop order, not a limit. I am looking for 3 down bars and then an up bar at which point I want to buy 5 ticks above the high of the up bar, which I use a buy stop with a offset of 5 from the high of the last bar.
Comment
-
Hello,
Try something like this:
if(Open[1] < Close[1] && Open[2] > Close[2] && Open[3] > Close[3] && Open[4] > Close[4])
{
EnterLongStop(DefaultQuantity, High[1] + 5 * TickSize, "")
}
Now, when the new bar forms after this order is placed, your order will be cancelled automatically.
Note: I am not using the current bar in my code, which you may or may not want to do. The auto cancelling functionality will not change however.DenNinjaTrader Customer Service
Comment
-
Pretty much what I have. But that bring me to something else. The "current bar" is (0) but if you are using calculate on bar close then are you really using the current bar to place an order against or the last bar closed? When I tried it the way you describe I was always one bar too far in the past.
I am using exactly what You have there except I have the Open[0] < Close[0]. This confused me at first since how do you have a Close of the current bar? Once a bar closes, isn't it no longer the current bar? I decided to ignore this since it seemed to work fine...
Comment
-
Hello,
The current bar is the currently closed bar. So Close[0] refers to the most recently closed bar close value.
You will probably want to shift all of the index values up (from my code: [1] to [0]) by one if CalculateOnBarClose is set to true.
So what you probably want is:
if(Open[0] < Close[0] && Open[1] > Close[1] && Open[2] > Close[2] && Open[3] > Close[3])
{
EnterLongStop(DefaultQuantity, High[1] + 5 * TickSize, "")
}DenNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by DJ888, Yesterday, 06:09 PM
|
2 responses
9 views
0 likes
|
Last Post
by DJ888
Today, 10:31 PM
|
||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
40 views
0 likes
|
Last Post
by jeronymite
Today, 10:10 PM
|
||
Started by bill2023, Today, 08:51 AM
|
2 responses
16 views
0 likes
|
Last Post
by bill2023
Today, 10:10 PM
|
||
Started by sidlercom80, 10-28-2023, 08:49 AM
|
167 responses
2,260 views
0 likes
|
Last Post
by jeronymite
Today, 09:54 PM
|
||
Started by warreng86, 11-10-2020, 02:04 PM
|
7 responses
1,362 views
0 likes
|
Last Post Today, 09:41 PM |
Comment