ChartHelper in a Strategy - NinjaTrader Programming | futures io social day trading
futures io futures trading


ChartHelper in a Strategy
Updated: Views / Replies:6,733 / 27
Created: by sam028 Attachments:5

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you dont need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 5  
 
Thread Tools Search this Thread
 

ChartHelper in a Strategy

  #1 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,572 given, 3,982 received

ChartHelper in a Strategy

Warning, this is a bit tricky/high level problem.
Some of our very good coders, @Mindset, @bukkan, @gomi, @eDanny, @Fat Tails, ... may have an idea.

I've been playing with ChartHelper.cs, which allow nice things, like calculate the price of the bar number, from the point you have clicked on a chart.
It works fine in an indicator, you can very quickly write an indicator which trap a mouse click, and then get the bar number, or the price level, and so on.
To calculate this, it use the Update() method, which seems to be called with a min and max, which can then be used to calculate the price.
It's also possible, with the Plot() method, where you have a min and a max.
But, AFAIK, these methods are not accessible in a Strategy, right ?

Any idea, to make a strategy able to get these min & max ?
Below a sample Strat, trying to get this price level.
The ChartHelper.cs is also here: ChartHelper.cs

 
Code
                            
namespace NinjaTrader.Strategy
{
    [
Description(" XY")]
    public class 
xyselect Strategy
    
{            
        private 
ChartHelper chartHelper;    
        private 
bool _found false;
        private 
double _t    0.0;
        
        protected 
override void Initialize() {
            
CalculateOnBarClose true;                        
        }
        
        protected 
override void OnStartUp() {
        }
                
        protected 
override void OnBarUpdate()
        {    
            if (!
_found) {
                
this.ChartControl.ChartPanel.MouseUp += new MouseEventHandler(chart_MouseClick);
                
chartHelper = new ChartHelper this.ChartControlthis.Barsthis.TickSize);
                
_t Instrument.MasterInstrument.TickSize;
                
_found=true;
            }            
        }
                
        private 
void chart_MouseClick(object senderMouseEventArgs e)
        {            
            
Panel chartPanel sender as Panel;    
            if (
chartPanel == null)
                return;                        
            if (
e.Clicks == && (e.Button == MouseButtons.Left) ) { 
                Print(
"e.X: "+e.X);
                Print(
"e.Y: "+e.Y);                
                Print(
"Price: "+chartHelper.ConvertYtoPrice(e.Y).ToString());
            }            
        }
        
        protected 
override void OnTermination() {        
            if(
ChartControl==null)
                return;
            
this.ChartControl.ChartPanel.MouseUp -= new MouseEventHandler(chart_MouseClick);            
            
base.Dispose();
        }        


Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following 4 users say Thank You to sam028 for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,216 since Jun 2009
Thanks: 628 given, 6,314 received
Forum Reputation: Legendary


I use channel indicator it called chart helper to draw a channel but it has a bug. When you re-open a chart it draws down channel only, I have to delete then add it back then it draws both up and down channel.

Attached Files
Register to download File Type: cs a00Channels.cs (54.8 KB, 58 views)
Reply With Quote
The following 3 users say Thank You to cory for this post:
 
  #4 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,572 given, 3,982 received

Thanks Cory, but my problem is being able to use some of its classes in a Strategy.
In an Indicator, it works as expected.

Success requires no deodorant! (Sun Tzu)
Reply With Quote
 
  #5 (permalink)
Elite Member
Paris
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 1,173 since Oct 2009
Thanks: 227 given, 4,090 received

Here's some code I wrote some time ago, it computes BarNum and Price using dichotomy on

ChartControl.GetXByBarIdx() and
ChartControl.GetYByValue()

I converted it to Strategy and looks OK

Attached Files
Register to download File Type: cs TstGetMouse.cs (3.6 KB, 146 views)
Reply With Quote
The following 5 users say Thank You to gomi for this post:
 
  #6 (permalink)
Elite Member
Paris
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 1,173 since Oct 2009
Thanks: 227 given, 4,090 received

I might add that both the ChannelHelper.cs and the a00Channels.cs look to me as the Pepe Hershey Indicators PP_ChartHelper and PP_Channels, see here , except that there no mention to Pepe any more.

As a developer I find it rather uncool, so I'll grab this opportunity to make public mention of this awsome series of Indicators, and thank Pepe if he wanders here one day.

Pepe, your work was truly inspirational to me and helped me tremendously to deal with mouse/keyboard interaction with the Ninja charts. It really was an eye-opener.

Thanks again !

Reply With Quote
The following 7 users say Thank You to gomi for this post:
 
  #7 (permalink)
Elite Member
Paris
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 1,173 since Oct 2009
Thanks: 227 given, 4,090 received

I downloaded the NT7 version of Pepe package I could find on ET ( Forums - Software Used to Trade Jack Hershey Methods) and it reloaded up and down channels on chart recreation.

Reply With Quote
The following 4 users say Thank You to gomi for this post:
 
  #8 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,572 given, 3,982 received

Thanks @gomi.

I already had this piece of code, but I was trying to see if there was a simpler way to convert the Y value to a price.
As it seems there is not, I think I will have to modify this one (but I need to understand it first, not really an amateur's one ).
As this indicator/strategy can give the low of a bar if the mouse click is done below, it might be able to also give the high of the same bar. If I can have an Y' of low, and an Y'' for the high, with a know low and high, I should be able to translate my Y into a price.


Very clear for me now, let's see tomorrow morning...





gomi View Post
Here's some code I wrote some time ago, it computes BarNum and Price using dichotomy on

ChartControl.GetXByBarIdx() and
ChartControl.GetYByValue()

I converted it to Strategy and looks OK


Success requires no deodorant! (Sun Tzu)
Reply With Quote
 
  #9 (permalink)
Elite Member
Paris
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 1,173 since Oct 2009
Thanks: 227 given, 4,090 received

If you're willing to get an y outside of the bar, anywhere on the chart, here's what you can do:

 
Code
                            
        private bool GetBarnumPriceFromMouseClick(ref int barnumref double priceint mousexint mousey)
        {    
            
barnum=IntegerDichotomy0,CurrentBar,GetX,mousex);
            
            
price=IntegerDichotomyConvert.ToInt32(MIN(CurrentBar)[0]/this.TickSize),Convert.ToInt32(MAX(CurrentBar)[0]/this.TickSize),MinusGetY,-mousey)*this.TickSize;
            
            return 
true;
        } 

Reply With Quote
The following 3 users say Thank You to gomi for this post:
 
  #10 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,572 given, 3,982 received


Thanks, it works like a charm !!!


gomi View Post
If you're willing to get an y outside of the bar, anywhere on the chart, here's what you can do:

 
Code
                            
        private bool GetBarnumPriceFromMouseClick(ref int barnumref double priceint mousexint mousey)
        {    
            
barnum=IntegerDichotomy0,CurrentBar,GetX,mousex);
            
            
price=IntegerDichotomyConvert.ToInt32(MIN(CurrentBar)[0]/this.TickSize),Convert.ToInt32(MAX(CurrentBar)[0]/this.TickSize),MinusGetY,-mousey)*this.TickSize;
            
            return 
true;
        } 


Success requires no deodorant! (Sun Tzu)
Reply With Quote

Reply



futures io > > > > > ChartHelper in a Strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Call ATM Strategy on an automated strategy to control position jsengxx NinjaTrader Programming 7 May 31st, 2016 05:51 PM
Utility To Transpose Optimized Strategy Values From Excel Output to Actual Strategy mercuryfx NinjaTrader 5 April 7th, 2012 04:59 PM
Ninjatrader7 ATM Strategy combine with Strategy Wizard Ninja Script schuster21 NinjaTrader Programming 4 July 4th, 2011 05:39 PM
Ninja Strategy multi-timeframe issue/Strategy to indicator nw123 NinjaTrader Programming 2 December 20th, 2009 07:24 PM


All times are GMT -4. The time now is 09:57 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-12 in 0.13 seconds with 20 queries on phoenix via your IP 54.221.93.187