Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 03-13-2018, 05:16 AM   #1
guidoisot
Member
 
Join Date: May 2011
Posts: 77
Thanks: 55
Thanked 9 times in 7 posts
Default How to spot double tops when they occur at a given Level

I am trying to build a logic with the Strategy Builder for identifying double top patterns when they occur at a given meaningful level.
In the example shown on the attachment I am considering as a Level the price corresponding to MAX(144) and a distance of 50 bars between the two tops.
What I have written in the S. Builder does not give any signal, whereas by looking at the chart there should be some signals (chart example on the other attachment).
Can anyone explain where is the mistake in the SBuilder script?
Any suggestion on how to spot a double top patterns at a given level (for ex. POC, VAH, VAL, prior day high and low, VWAP, SMA, ..... ) would be most welcome.
Thanks.
Attached Images
File Type: png ES 06-18 (10 Minute) 2018_02_16.png (94.8 KB, 12 views)
File Type: jpg Strategy Builder looking for Double Top patterns.JPG (64.2 KB, 12 views)
Last edited by guidoisot; 03-13-2018 at 07:32 AM.
guidoisot is offline  
Reply With Quote
Old 03-13-2018, 08:01 AM   #2
NinjaTrader_Jim
NinjaTrader Customer Service
 
NinjaTrader_Jim's Avatar
 
Join Date: Nov 2016
Location: Denver, CO
Posts: 1,828
Thanks: 98
Thanked 493 times in 468 posts
Default

Hello guidoisot,

Thanks for opening the thread.

There are a couple lines that stick out, but ultimately, the code will need to be tested with prints so you can better visualize what is occurring with the logic so you can tweak it as necessary. I'll include a video demonstration for setting up debug prints in the Strategy Builder.

Debugging in the Strategy Builder - https://www.screencast.com/t/8uvjfM8h

In your conditions, you are checking if the MAX of the last 50 bars is equal to the MAX of the last 144 bars + 2 ticks. This is not likely to become true as the MAX of the last 50 bars could be high for the MAX of the last 144 bars. This value then cannot equal itself + 2 ticks. When comparing offsets to see if you are in range, I would recommend to use greater and less than conditions to see if the either end is within the 2 tick offset of the other side.

I may also suggest to save the barsAgo value returned from HighestBar() and use it in your MAX() indicator so you can look back to the MAX value from before your first found HighestBar(). For example: MAX(144)[barsAgo] will return the highest value looking back 144 bars from your first high point. If this MAX value is within range of your first high, then you have discovered a double top. Additional filtering logic may be required if this MAX value is on a downward slope. Drawing from each of these points would not be possible taking this approach, since HighestBar() cannot be given a barsAgo value to start looking back from. You could draw a line 144 bars back from the HighestBar()'s barsAgo value, however.

When designing the logic, I recommend creating conditions in small parts and using prints as described in the video above to determine if the condition is written correctly. This way, you can check your work and continue creating additional logic.

Please keep in mind, the Strategy Builder is only designed for very simple strategies. What you are trying to accomplish may be possible in the Strategy Builder to some degree, but this kind of analysis would typically be done with loops in the NinjaScript Editor.

We cannot offer services to write Strategy Builder logic or to create, modify, or debug client code. This is because we are a small team and cannot take on these sorts of tasks for all of our clients. If you are interested in those services, I can have a member of our Sales Support team provide more information on NinjaScript Consultants.

Please let us know if we can be of further assistance.
NinjaTrader_Jim is online now  
Reply With Quote
The following user says thank you to NinjaTrader_Jim for this post:
Old 03-15-2018, 10:54 AM   #3
guidoisot
Member
 
Join Date: May 2011
Posts: 77
Thanks: 55
Thanked 9 times in 7 posts
Default

Hi Jim,
Thank you for your reply. Let me start saying that I appreciated very much you explanation that you guys at support have limited resources vs the huge number of requests you receive every day. I have to admit, I did not consider this aspect.
Regarding the offset I did ask my self, while drafting the strategy, whether or not it (also) had an algebraic sign, but I thought signs applied only to the arithmetic offset (which I am not sure what it actually represents) not to percentage offset, therefore I assumed that percentage offset was an absolute offset on both sides. … I learned a new detail about the platform. Thanks.
Regarding the next paragraph I do not really understand the message. I shall have to think a bit more about it, however if you have some spare time please let me have some additional guidance on how one could save the highest bar value (maybe setting a double on the sub-panel “Variables” of the tab “input and Variables”?) and how to use it. Then also this sentence is not so easy to understand for me “For example: MAX(144)[barsAgo] will return the highest value looking back 144 bars from your first high point. If this MAX value is within range of your first high, then you have discovered a double top”.


Hi @Arkadiy_B thank you again for kindly posting at https://ninjatrader.com/support/foru...14&postcount=9 the zip of the modified indicator Volume profile.


I hope you don’t mind if I copy to you this post regarding the strategy I was going to develop. It is because such strategy could be conveniently related to your dPOC indicator about which I found out just these days. Actually, I suppose that POC would be a much more interesting level, rather than MAX(144), for double checking its confluence with a divergence. It appears to me that you you are very familiar with NT scripting, would you perhaps like joining this thread and offer some help in building its sample strategy? I suppose you might include your indicator dPOC in it and/or also refer the whole strategy to POC.
Thank you.
Last edited by guidoisot; 03-15-2018 at 10:56 AM.
guidoisot is offline  
Reply With Quote
Old 03-16-2018, 10:51 AM   #4
NinjaTrader_Jim
NinjaTrader Customer Service
 
NinjaTrader_Jim's Avatar
 
Join Date: Nov 2016
Location: Denver, CO
Posts: 1,828
Thanks: 98
Thanked 493 times in 468 posts
Default

Hello guidoisot,

Yes, you would use a variable created in the Inputs and Variables tab of the Strategy Builder and then you would set that variable to the output from HighestBar() in an action under the Condition and Actions tab. In an Action, you can set a variable value under Misc > Set MyVariable.

Quote:
Then also this sentence is not so easy to understand for me “For example: MAX(144)[barsAgo] will return the highest value looking back 144 bars from your first high point. If this MAX value is within range of your first high, then you have discovered a double top”.
We can consider the following for a barsAgo reference:
  • MAX(144)[0] will look at the MAX value going 144 bars back from the current bar.
  • MAX(144)[3] will look at the MAX value going 144 bars back from 3 bars ago.
  • MAX(144)[barsAgo] will look at the MAX value going 144 bars back starting from the current bar minus the value of barsAgo. If barsAgo is 5, then we would look at the MAX value going 144 bars back from 5 bars ago.

I also should have been clearer in my response. It is not possible to set a barsAgo reference as a variable in the Strategy Builder. Considering this, I do not think this can be accomplished with the Strategy Builder and custom programming will be necessary.

If there is anything else we can do to help out, please let us know.
NinjaTrader_Jim is online now  
Reply With Quote
The following user says thank you to NinjaTrader_Jim for this post:
Old 03-16-2018, 01:05 PM   #5
guidoisot
Member
 
Join Date: May 2011
Posts: 77
Thanks: 55
Thanked 9 times in 7 posts
Default

Thank you Jim.
I will try over the weekend to see whether I will be able to get, at least partially, the signals I started this thread for.
I have been also looking at whether one could exploit the free Price Action Swing (PAS) indicator for this, but it appears that PAS cannot be used, neither for getting market analyzer signals, nor for automated strategies.
The same seems to apply to the other free divergence indicators I know of, such as:
D3SpotterV3B2 Updated by @GeorgeW or
Divergence Input Series for NT8 by @aligator , ( …. however this last one, with its gradient colored bars, seems to be a good option for manual executions, because I understand it can give early messages that a divergence is almost fully developed).
The same applies also to the divergence indicator for sale by Moore Tech, LLC @toptrader.

I have mentioned some forum members who worked on divergence indicators, because they may wish either to contribute here, or they may prefer to offer their help as programming services, in such case please either pm me or post a quote here (…. maybe other forum members would like to share the cost) for creating an indicator and a market analyzer that can spot double tops/bottoms "when they occur at a given meaningful Level".

Thanks.
guidoisot is offline  
Reply With Quote
Old 03-19-2018, 12:36 PM   #6
gubbar924
Senior Member
 
Join Date: Aug 2011
Posts: 148
Thanks: 27
Thanked 52 times in 41 posts
Default

this indicator seems to already have done a lot of the leg work, perhaps you can just modify as needed

https://ninjatrader.com/support/foru...atid=7&lpage=3
gubbar924 is offline  
Reply With Quote
The following user says thank you to gubbar924 for this post:
Old 03-20-2018, 04:28 AM   #7
guidoisot
Member
 
Join Date: May 2011
Posts: 77
Thanks: 55
Thanked 9 times in 7 posts
Default

Thank you indeed for the interesting suggestion.
I am now looking at the indicator script on the editor, but I realize that it is written with a language I do not really understand enough.
If I remember correctly from my times when I had been studying some basic programming (Fortran, for about a quarter, few decades ago ...) the logic of the code of a program can be sketched using a corresponding block chart called "flow chart". Maybe having this indicator flow chart in front of me would let me understand better what this script is doing and how I could possibly modify it in order to apply it also to other patterns (double tops or bottoms).

@NinjaTrader_PatrickH
- do you have and could you perhaps post the flow chart of this script that you have created?
- Alternatively, as regards license issues, is it possible for Ninjatrader users to copy and paste the code of the indicators posted here on the forum on a web tool like this one: https://code2flow.com/#pricing , just in order to get for our own personal use the corresponding flow charts?
- for the future do you think it would be helpful for Ninjatrader users not so proficient in C# to be able to access also the flow charts of the Ninjatrader scripts posted here on the forum, for ex. a starting point could be those scripts derived from Stocks and Commodities Magazine publications.
Thank you.
Last edited by guidoisot; 03-20-2018 at 04:38 AM.
guidoisot is offline  
Reply With Quote
Old 03-20-2018, 08:55 AM   #8
NinjaTrader_Jim
NinjaTrader Customer Service
 
NinjaTrader_Jim's Avatar
 
Join Date: Nov 2016
Location: Denver, CO
Posts: 1,828
Thanks: 98
Thanked 493 times in 468 posts
Default

Hello guidoisot,

There can be a lot that goes into modifying an indicator so it can do exactly what you would like it to. We can provide some introductory materials for NinjaScripts, but we could not offer direction for specific modifications to customize a script. (We do not have the bandwidth to direct clients to make their own modifications. NinjaScripts will require some programming background, as well as time for trial-and-error testing and debugging. Additionally, we cannot offer C# programming education in the Support Department.)

I'll include some indicator tutorials as well as some basic programming concepts if you would like to learn C# and make the modifications on your own. This information is publicly available. If you would like to go more indepth, I would recommend viewing external C# resources to build your programming background.

Indicator tutorials NT7 - https://ninjatrader.com/support/help...indicators.htm

Basic Programming Concepts NT7 - https://ninjatrader.com/support/help...g_concepts.htm

Code Breaking Changes NT8 - https://ninjatrader.com/support/help...ng_changes.htm

The source code for the indicator is openly available. If you would like to paste the source code in a tool that creates a flow chart, you may do so. Since NinjaScripts are based on C#, there is a certain expectation that if someone wants to modify the script, they can read and understand the code enough to make the necessary modifications. 3rd party flow chart tools are openly available on the internet and you may use any of those available if they can assist with your understanding of the script.

If you would like, we can also have a representative for our EcoSystem reach out with additional information on NinjaScript Consultants who would be happy to make any modifications at your request. Please let me know if this interests you.
NinjaTrader_Jim is online now  
Reply With Quote
Old 03-28-2018, 06:17 AM   #9
guidoisot
Member
 
Join Date: May 2011
Posts: 77
Thanks: 55
Thanked 9 times in 7 posts
Default

Attached is nice double top at VAH with divergence occurring right now

I am looking for an indicator telling me this both with an alert and on on the market analyzer..
Can any programmer develop a custom script that can do this?
Ready to pay a mutually agreed price for this "indicator with market analyzer"
Anyone willing to do that, please post here on this thread your quote and terms.
Only prerequisite condition on my side is that I would like to attend via remote session while the script is being developed.
If other forum members would like to join and share the cost, the remote sessions, and the script, just join the thread and ask to do so.
Attached Images
File Type: png NQ 06-18 (750 Volume) 2018_03_28.png (199.2 KB, 12 views)
Last edited by guidoisot; 03-28-2018 at 06:32 AM.
guidoisot is offline  
Reply With Quote
Old 03-28-2018, 06:23 AM   #10
guidoisot
Member
 
Join Date: May 2011
Posts: 77
Thanks: 55
Thanked 9 times in 7 posts
Default

few minutes later it did actually go down to visit POC.
Looks good.
Attached Images
File Type: png NQ 06-18 (750 Volume) 2018_03_28.png (207.2 KB, 22 views)
guidoisot is offline  
Reply With Quote
Old 03-28-2018, 07:06 AM   #11
NinjaTrader_ChristopherD
NinjaTrader Customer Service
 
NinjaTrader_ChristopherD's Avatar
 
Join Date: Nov 2011
Location: Denver, CO
Posts: 270
Thanks: 9
Thanked 53 times in 48 posts
Default

Hello guidoisot

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.

This 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.
NinjaTrader_ChristopherD is offline  
Reply With Quote
Old 07-04-2018, 04:09 AM   #12
guidoisot
Member
 
Join Date: May 2011
Posts: 77
Thanks: 55
Thanked 9 times in 7 posts
Default

Quote:
Originally Posted by guidoisot View Post
I am trying to build a logic with the Strategy Builder for identifying double top patterns when they occur at a given meaningful level.

...

Any suggestion on how to spot a double top patterns at a given level (for ex. POC, VAH, VAL, prior day high and low, VWAP, SMA, ..... ) ?
Thanks.

I noticed it already exists a similar indicator for another platform https://www.forexfactory.com/showthread.php?t=713972

Can anyone try to develop something similar for NT8?


@gubbar924
thanks for referencing in your post the HS indicator, but unfortunately I do not have programming skills allowing me to follow up starting from it.

@algotrading
maybe you would like to add such an indicator to the list of free indicators on your website?
Last edited by guidoisot; 07-04-2018 at 04:14 AM.
guidoisot is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Momentum level double GainForex Strategy Development 5 08-19-2015 01:28 PM
Execution not Occur rana.irfan Strategy Development 3 07-03-2013 06:31 AM
Double Tops/Bottoms bbucha_stk Platform Technical Support 1 01-18-2012 04:28 PM
Find Double Tops from the current bar td_910 Indicator Development 2 12-17-2011 12:39 PM
double tops/bottoms using donchian channels zq655 Platform Technical Support 2 04-20-2008 02:42 PM


All times are GMT -6. The time now is 01:31 PM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.