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
Possible to say enter trade X bars after indicator does Y
Collapse
X
-
Possible to say enter trade X bars after indicator does Y
Looking to say enter trade X bars after MACD cross unless MACD crosses back within that 8 bar period. Is this possible using the Strategy Builder?Tags: None
-
Hello demo166130,
Thanks for your post.
This could be possible by setting a few bools for 1) when you are waiting for the number of bars to be met, and 2) for each bar that you have waited.
When your waiting bool is true and the last bool that you set for X bars is true, then you can call your Enter method.
If a cross in the other direction occurs, set these bools back to false.
An example for using bools to count would be as follows:
Code:if(NeedToCount == true && BoolCounted2 == true) BoolCounted3 = true; if(NeedToCount == true && BoolCounted1 == true) BoolCounted2 = true;
JimNinjaTrader Customer Service
-
Im catching your drift but it goes over my head when you start mentioning C#. Which input parameters would I use within the strategy builder to say what your code says?
Comment
-
Hello demo166130,
I have created a demonstration showing how bools can be set up in the Strategy Builder to count how many bars ago something had happened.
Demo - https://drive.google.com/file/d/1pPx...w?usp=drivesdk
Please let me know if I can be of further assistance.JimNinjaTrader Customer Service
Comment
-
I really appreciate you taking the time to try and explain this to me. Think it'll require a few more watches before what's going on actually sinks in.
Got a couple questions, what derives the meaning given to terms like 'BoolWaited1Bar', is this preset within the programme language?
Just to confirm this would set an entry to take place 3 bars after the SMA cross takes place, providing the SMA doesn't cross back again?
If I wanted to use the same logic, only when the Fast SMA crosses Below the SlowSMA go Short instead of long, would this have to be written out again using another 6 sets? (This might be a dumb question).
Regards,
Alex
Comment
-
Hello Alex,
The variable names are names I chose to give them meaning.
Yes, this will enter long 3 bars after the cross from Set 5 is seen. If the other cross is seen (Set 6) the variables are reset and counting stops.
You should use separate variables and use separate logic to handle another type of cross, but if you wanted to use a different cross than what I defined, you could change Set 5.
My best recommendation for learning NinjaScript is to set up test logic in small cases and to use the Playback Connection and the Simulated Data Feed to control your tests. Once you confirm some set of logic works, I would then recommend expanding on it.
Let us know if you have any additional questions.JimNinjaTrader Customer Service
Comment
-
Thanks for clearing that up. So how do the variables have any effect on the strategy if you derive their meaning yourself? As in how will the system know you are telling it to take a trade 8 bars after the indicator provides the signal if names like BoolWaited3Bars don't actually have any meaning?
You mentioned using seperate variables to create a series in which we wait X bars to take a trade the other direction. So a variable like BoolWaited3BarsShort would be fine?
A part of the strategy I was also hoping to create is to exit trade after 8 bars. Is this more simple to integrate?
Comment
-
Hello demo166130,
Perhaps I could have explained better: the logic in which the the bools are used defines the meaning for the strategy. The name chosen is to provide an visual aid so as the strategy developer, I know what I want that bool to represent and how I should use it.
You mentioned using separate variables to create a series in which we wait X bars to take a trade the other direction. So a variable like BoolWaited3BarsShort would be fine?
There is not an easier way to count within the Strategy Builder, but may be easier to program by hand in an unlocked strategy.
If creating the logic is difficult and you are interested in services to have the logic or Strategy code written for you, we could have a representative of our EcoSystem reach out with information on NinjaScript consultants who would be happy to write a custom strategy by your request.
Please let us know if we can be of further assistance.JimNinjaTrader Customer Service
Comment
-
It would be great if you could have an EcoSystem representative make contact to discuss things. There are a number of indicators it would be interesting to know if were possible to be made to work in conjunction with a mchanical strategy. Look forward to hearing from someone in due course.
Thanks
Comment
-
Hello demo166130,
Thank you for your reply.
You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more:You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third-party services for NinjaTrader, all pricing and support information will need to be obtained through the consultant.
The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem, LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
Let me know if I may be of further assistance.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by WHICKED, Today, 12:45 PM
|
1 response
10 views
0 likes
|
Last Post Today, 01:08 PM | ||
Started by samish18, Today, 01:01 PM
|
0 responses
5 views
0 likes
|
Last Post
by samish18
Today, 01:01 PM
|
||
Started by WHICKED, Today, 12:56 PM
|
0 responses
8 views
0 likes
|
Last Post
by WHICKED
Today, 12:56 PM
|
||
Started by Spiderbird, Today, 12:15 PM
|
2 responses
11 views
0 likes
|
Last Post
by Spiderbird
Today, 12:48 PM
|
||
Started by FrazMann, Today, 11:21 AM
|
2 responses
8 views
0 likes
|
Last Post Today, 12:38 PM |
Comment