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
Variables Reset
Collapse
X
-
Hi tranta,
Are you using the ExitLongLimit as the stop loss? (this has the profit target variable in the price calculation and an ExitLongLimit is used as a profit target)
You should set this to an IOrder so that you can update the price later.
Are you wanting both entries to be triggered before the exit long limits are submitted?
(Currently this is how your code is set. Both entry IOrders must not be null. So the orders do not have to fill, they just can't be null.
What behavior are you wanting from this script?Chelsea B.NinjaTrader Customer Service
-
Hello, Thank you for your reply. Im using ExitLongLimit as profitTarget, Strategy should enter to Long position after CCi crossabove "hranice" if hit profittarget -> flat position. If not enter to second only If price is below 30 ticks from last enter long position. and so on.
Comment
-
Hello tranta,
The first ExitLongLimit should be placed after the entryOrder is submitted and the second ExitLongLimit should be placed after the entryOrder1 is submitted.
Are you finding these are not being submitted?
What is the incorrect behavior you are experiencing?
Also, what instrument and interval are you testing this script on, because I am having difficulty getting the entry order conditions to be met.Chelsea B.NinjaTrader Customer Service
Comment
-
Hi tranta,
Using YM 06-14 5 Minute (with Entries per direction set to 100 so they are not limited) I am getting the 14 trades in the screenshot.
The reason that it does not trade often is when the crossabove happens, the close is not greater than the open.
But this strategy does trade on the YM 06-14 5 Minute.
Also attached is the output from prints I have added to the code to see what the conditions are evaluating as.
Anywhere there is a crossover the cross above prints.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello,
Attached is a screenshot of the trades made by the script on YM 06-15 5 Minute (I accidently did 1 minute on my last test) from 1/1/2014 to 6/2/2014 using the code in your post 5.
I think the issue you are referring to is that the ExitLongLimits are not being submitted.
This is because you are setting the entryOrder and entryOrder1 to null before the position becomes long.
When the entryOrder is submitted the following code is run in OnBarUpdate() and the entry order handles are set to null. This happens right away and way before the position is ever updated.
if (Position.MarketPosition == MarketPosition.Flat)
{
entryOrder1 = null;
entryOrder = null;
}
This code is best in OnPositionUpdate().Chelsea B.NinjaTrader Customer Service
Comment
-
Hi tranta,
There is nothing in this code that would prevent the second order from being placed at the same time as the first order if (High[0] < Variable0 - Diff * TickSize).
In other words, if the first condition is true, then the first part of the second condition is true too.
What code should be preventing this?
Would you like to add code to make sure that the second order is not placed at the same time as the first order?
If so move the second condition before the first condition so that entryOrder does not get set before entryOrder1.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, 04-17-2024, 06:40 PM
|
6 responses
48 views
0 likes
|
Last Post
by algospoke
Today, 06:18 PM
|
||
Started by arvidvanstaey, Today, 02:19 PM
|
4 responses
11 views
0 likes
|
Last Post Today, 04:08 PM | ||
Started by samish18, 04-17-2024, 08:57 AM
|
16 responses
61 views
0 likes
|
Last Post
by samish18
Today, 03:30 PM
|
||
Started by jordanq2, Today, 03:10 PM
|
2 responses
9 views
0 likes
|
Last Post
by jordanq2
Today, 03:23 PM
|
||
Started by traderqz, Today, 12:06 AM
|
10 responses
19 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
Comment