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
The problem with the number of reverses
Collapse
X
-
The problem with the number of reverses
Hello, help please, I made a strategy with the reverse position when triggered stop loss, but it so happened that now the position is flipped each time it is triggered stop until closed by take profit, please tell me how to make the reverse worked only once at the closing of the stop loss?Tags: None
-
Originally posted by Kovalev View PostHello, help please, I made a strategy with the reverse position when triggered stop loss, but it so happened that now the position is flipped each time it is triggered stop until closed by take profit, please tell me how to make the reverse worked only once at the closing of the stop loss?
you can simply use this free NinjaTrader developer technology and build your own strategies. Please see the MTDS7 Strategy Development Kit – Trade Engine
MTDS7 Strategy Development Kit Automated Algorithmic Trading Framework API advanced strategy development foundation for NinjaTrader. Build Your Automated Trading Systems Developed with the MTDS7 Strategy Development Kit in NinjaTrader 7 Unmanaged Mode for Professional reliability and execution.
MTDS7 was purpose built for live trading & Rapid Strategy Creation in just 2 lines of code with unrivaled features the first and only of it’s kind and it’s 100% FREE for sim trading unlimited! - you can download it here 100% always free and use the ready to trade,edit, modify sample open source ninjatrader strategies.
http://microtrends.co/ninjatrader-downloads#MTDS
-
Hello Kovalev,
If you would like help with your existing NinjaScript strategy could you please provide the script you are currently working on? It would be difficult to say what may be happening without seeing what you are currently trying.
If this is a wizard strategy, you could also include screen shots of the wizard steps as that would be helpful.
You can export a strategy using the following steps: http://ninjatrader.com/support/helpG...nt7/export.htm
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Yes of course, here it is
conditions of entry example ofAttached Files
Comment
-
Hello Kovalev,
Thank you for posting the example that helps.
I wanted to clarify, you said that you want the reversal to happen only once after the stoploss is closed(filled?). Did you mean that you only want it to reverse one time and then prevent the reversal from being able to happen again? Could you explain further what action is currently happening? It may help if you post an image of the results you are currently seeing as well.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hello Kovalev,
Thank you for the image.
To prevent further trading after 1 reversal, you would need to account for that with logic.
You could do something as simple as using an int counter or a bool variable. Because you're entering in one of two directions you would likely need to check if the direction has previously been used by setting a variable to a specific value. You could then check this value in your entries conditions and prevent them if the variable is set.
Can you confirm, is this what you had intended per your image or stop trading completely once the reversal occurs?
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hello Kovalev,
I will provide a very simple example of what I am referring to below, you could choose how you want to implement this further in your own script. Mainly you just need to set a variable to know the condition has already happened, once it has you can change the outcome of your logic if so.
Code:[B]private bool reversedToLong = false; private bool reversedToShort = false;[/B] protected override void OnOrderUpdate(IOrder order) { // Handle entry orders here. The entryOrder object allows us to identify that the order that is calling the OnOrderUpdate() method is the entry order. if (entryOrder != null && entryOrder == order) { // Reset the entryOrder object to null if order was cancelled without any fill if (order.OrderState == OrderState.Cancelled && order.Filled == 0) { entryOrder = null; } } if ((entryOrder == null) && (order.Name == "MyLongStop") && (order.OrderState == OrderState.Filled) [B]&& !reversedToShort[/B]) { entryOrder = EnterShortLimit(1, order.StopPrice, "Short"); r[B]eversedToShort = true;[/B] } if ((entryOrder == null) && (order.Name == "MyShortStop") && (order.OrderState == OrderState.Filled) [B]&& !reversedToLong[/B]) { entryOrder = EnterLongLimit(1, order.StopPrice, "Long"); [B]reversedToLong = true;[/B] } }
You would need to experiment to see what works best for what you are trying to achieve, this would just be a general example and may not produce the desired result. This specific example is more or less to demonstrate a concept of defining a condition and variable for that condition.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Johndc, Today, 04:39 AM
|
0 responses
2 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
8 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
12 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
5 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
Comment