OnMouseMove pass X Y..........don't know how - NinjaTrader Programming | futures io social day trading
futures io futures trading


OnMouseMove pass X Y..........don't know how
Updated: Views / Replies:3,136 / 14
Created: by vvhg Attachments:0

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 donít 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
 
Thread Tools Search this Thread
 

OnMouseMove pass X Y..........don't know how

  #1 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received

OnMouseMove pass X Y..........SOLVED!

I'm lost!

What I want to do is:

1. passing the mouse coordinates for every move (while mouse within active chart) into variables.
2. correcting the Y variable by n ticks.

I have no idea as to how that whole OnMouseMove works as my coding skills are VERY limited, and I haven't even got the slightest idea how to get the size of a tick converted into a y distance.

The background to this is that I want to create an indicator that "attaches" small horizontal lines to the crosshair at +/- n ticks from the horizontal crosshair line.

I'd be really grateful for any help.

vvhg

PS: If I try this without help, I probably end up writing the worst virus imaginable!

Hic Rhodos, hic salta.

Last edited by vvhg; March 22nd, 2011 at 03:11 PM.
Reply With Quote
 
  #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)
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,570 given, 3,982 received


Did you already read this thread ?
The code in ChartHelper.cs can give you some clues on how to do that.

As you know, the MouseEvent is already catch, when you use a the Cross Hair cursor, so be careful .

Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following user says Thank You to sam028 for this post:
 
  #4 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received

Thanks a lot .

Yes, I did read the thread, that's what triggered my idea in the first place. You are capturing the xy of clicks there, right?
My C# abilitiesare very limited though, so I can't modify it for mouse movement without the click.
Thanks for the warning, I will be careful, especially as I haven't got a clou what you are talking about, I just have the feeling this is waaaay out of my league.

All I know is, I basically want to do sth similar to what you posted in the thread you linked to. The difference is that I want to position the levels relative to the mouse location.

Thanks again for your help.

Hic Rhodos, hic salta.
Reply With Quote
 
  #5 (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,570 given, 3,982 received

Just getting the X Y is easy then, just trap the mouse move with:
 
Code
                            
 protected override void OnStartUp() {
...
  
thisChartControl.ChartPanel.MouseMove += new MouseEventHandler(MouseEventM);
...
}

private 
void MouseEventM(object sender,MouseEventArgs e) {    
  Print(
"x: "+e.Y+" y: "+e.Y);

and don't forget:
 
Code
                            
 protected override void OnTermination() {
  
this.ChartControl.ChartPanel.MouseMove -= MouseEventM;


Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following 5 users say Thank You to sam028 for this post:
 
  #6 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received

I can't thank you enough!

Nearly there now, the only problem is that I seem to get very strange values from ChartHelper:
chartHelper.CalcTickHeight() returns sth like -2147483648. And if I multiply it by 20 the result is zero. Any ideas? Or do you need the code?

vvhg

Hic Rhodos, hic salta.
Reply With Quote
 
  #7 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received

I still can't get any values from ChartHelper that make any sense. Perhaps one of the coders that are better than me (not very hard at all!) can have a look?

Here is my disgraceful copy/paste artwork(probably good for a laugh at least) :
 
Code
#region Using declarations
using System;
using System.Reflection;
using System.Windows.Forms;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
            /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class Crosshair : Indicator
    {
        #region Variables
        // Wizard generated variables
           private bool _found = false;
        private ChartHelper chartHelper; 
        
        private int x = 100;
        private int th = 0;
    
        private double price    = 0.0;
        private int offset1up = 20;
        private int yMouse = 0;
        private double corr1 = 0;
            
        private int yMouse2 = 100; 
        private StringFormat                stringFormat        = new StringFormat();
        private SolidBrush                    textBrush            = new SolidBrush(Color.Green);
        private SolidBrush                    textBrush2            = new SolidBrush(Color.Red);
        private Font                        textFont            = new Font("Arial", 30);
        
        // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void OnStartUp() 
        {
        
          this.ChartControl.ChartPanel.MouseMove += new MouseEventHandler(MouseEventM);
        
            
        }
        
        protected override void Initialize()
        {
            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
           
            CalculateOnBarClose = false;        //### Run on every Tick 
            Overlay                = true;    
            PaintPriceMarkers   = false;
            DisplayInDataBox    = false;
            
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
       protected override void OnBarUpdate()
        {
            if (!_found) {
               
                chartHelper = new ChartHelper ( this.ChartControl, this.Bars, this.TickSize);
               
                _found=true;
            }            
            
                
            
        }
                
        private void MouseEventM(object sender,MouseEventArgs e)
            {   
                if(th==0)
            {
                Update();
            }
              
        th=chartHelper.CalcTickHeight();
        
            //Print("tickh"+th);
                yMouse=    e.Y;
                Print("yMouse...."+yMouse);
                price=chartHelper.ConvertYtoPrice(e.Y);
                Print("price...."+price);
                ChartControl.ChartPanel.Invalidate();
                
        } 
        
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            
            
            
            
            yMouse2=yMouse-th*offset1up;
            int ff =th*offset1up;
            Print("th...."+th);
            Print("yMouse2...."+yMouse2);
            // Plot the line
            float textHeight = ChartControl.Font.GetHeight();
            
                
                    graphics.DrawString("__________", ChartControl.Font, textBrush, bounds.Right -x,yMouse2-textHeight , stringFormat);
                
    
        }
    
        protected override void OnTermination() 
        {
          this.ChartControl.ChartPanel.MouseMove -= MouseEventM;
        }

vvhg

Hic Rhodos, hic salta.
Reply With Quote
 
  #8 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received

SOLVED!!!

vvhg

Hic Rhodos, hic salta.
Reply With Quote
 
  #9 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,214 received


vvhg View Post
SOLVED!!!

vvhg

What was the solution, to help others in the future.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #10 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received


As stated above I could'nt get anything sensible from ChartHelper, so I calculated TickHeight (as y value) via
 
Code
ChartControl.GetYByValue(this,priceA);
and
 
Code
ChartControl.GetYByValue(this,priceB);
So I had two prices I knew and the corresponding y values. That was really all I needed.

vvhg

Hic Rhodos, hic salta.
Reply With Quote
The following user says Thank You to vvhg for this post:

Reply



futures io > > > > > OnMouseMove pass X Y..........don't know how

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
Food Costs Rising as Coke, Chipotle Pass on Commodity Increases kbit News and Current Events 0 July 25th, 2011 12:04 PM
OK Go - This Too Shall Pass - Rube Goldberg Machine version - Official eboarder Jokes 1 February 25th, 2011 10:09 AM
How to pass information to a live strategy aviat72 NinjaTrader Programming 5 August 30th, 2010 09:08 PM
BHP's Potash Bid Likely to Pass Regulatory Review Quick Summary News and Current Events 0 August 19th, 2010 01:10 AM
Financial Reform Still Expected To Pass Despite New Hurdles Quick Summary News and Current Events 0 June 28th, 2010 11:10 PM


All times are GMT -4. The time now is 12:18 AM.

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-10 in 0.11 seconds with 19 queries on phoenix via your IP 54.90.207.75