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
Ninjascript Strategy returning wrong order?
Collapse
X
-
Ninjascript Strategy returning wrong order?
When I set up a simple strategy to buy on a crossover and sell on a crossunder (and it doesn't get much simpler than that), it always fills twice the number of lots??? As an example, if the crossover triggers a buy order of one lot, it submits two orders..... (1) Buy to Cover and (2) Buy! This nets a "Position" of 2 lots??? Can anyone tell me why?????Tags: None
-
For further clarification.
When you run your strategy, it will calculate its current "strategy" position. Lets say its 1 lot long. Should your actual account position be flat, you have the option (most would do this) to synchronize your account position to your strategy position. In this case, you could enter a buy order to get your account position in sync with your strategy.RayNinjaTrader Customer Service
Comment
-
I continue to have a problem with strategy fills?? I have created a nice system, but occasionally, here is what happens. If I have an order to go long when my conditions are met with an "enterlong", everthing is great until it reverses before kicking in and hits the "exitlong" first. Here is basically how it looks......
protected override void OnBarUpdate()
{
// Condition set 1
if condition is satisfied
{
EnterLong(DefaultQuantity,"");
}
// Condition set 2
if ((exit Condition is met))
&& (Position.MarketPosition == MarketPosition.Long)))
{
ExitLong("");
What happens is that I end up short a position if the condition 2 is met, even though I have the (Position.MarketPosition == MarketPosition.Long) in there.
I had this happen, so "flattened" everythin via the "File" menu in the control center, closed down the chart, and reopened it with a fresh strategy and it happened again??? Any idea why?????
Comment
-
Without seeing the exact rendition of code you have I do not know what is wrong, but this is a potential cause of problems on what you have posted:
if ((exit Condition is met)) <-- that already closed the if-statement. the whole &&... isn't part of the if-condition.
&& (Position.MarketPosition == MarketPosition.Long)))Josh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by suroot, 04-10-2017, 02:18 AM
|
4 responses
3,019 views
0 likes
|
Last Post
by truepenny
Today, 08:01 AM
|
||
Started by Stanfillirenfro, Today, 07:23 AM
|
1 response
4 views
0 likes
|
Last Post Today, 07:37 AM | ||
Started by cmtjoancolmenero, Yesterday, 03:58 PM
|
2 responses
22 views
0 likes
|
Last Post Today, 07:24 AM | ||
Started by olisav57, Yesterday, 07:39 PM
|
1 response
9 views
0 likes
|
Last Post Today, 07:23 AM | ||
Started by cocoescala, 10-12-2018, 11:02 PM
|
7 responses
944 views
0 likes
|
Last Post
by Jquiroz1975
Today, 07:21 AM
|
Comment