Market Depth on Chart  [SOLVED]

User avatar
admin
Posts: 79
Joined: 13 Jul 2005
Has thanked: 41 times
Been thanked: 122 times

Market Depth on Chart

Postby admin » 31 Jul 2012

Market Depth on Chart

Code: Select all

using System;
using System.Drawing;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
    [SameAsSymbol(true)]
    [RecoverDrawings(false)]
    public class _Market_Depth_on_Chart_ : IndicatorObject
    {
        private draw_DOM_level m_draw_dom_level1;
        private draw_DOM_level m_draw_dom_level2;

        private double m_value11;

        private IPlotObjectStr Plot1;

        public _Market_Depth_on_Chart_(object ctx) :
            base(ctx){
            updatespeed_seconds = 0.1;
        }

        [Input]
        public double updatespeed_seconds { get; set; }

        protected override void Create(){
            m_draw_dom_level1 = new draw_DOM_level(this);
            m_draw_dom_level2 = new draw_DOM_level(this);
            Plot1 = AddPlot(new StringPlotAttributes("Status", Color.Red));
        }

        protected override void StartCalc(){
            m_draw_dom_level1.Data = new Lambda<DOMPrice[]>(back => Bars.DOM.Ask);
            m_draw_dom_level1.maxsize = new Lambda<Double>(_bb => m_value11);
            m_draw_dom_level1.From = Color.FromArgb(255, 0, 0);
            m_draw_dom_level1.To = Color.FromArgb(80, 0, 0);

            m_draw_dom_level2.Data = new Lambda<DOMPrice[]>(back => Bars.DOM.Bid);
            m_draw_dom_level2.maxsize = new Lambda<Double>(_bb => m_value11);
            m_draw_dom_level2.From = Color.FromArgb(0, 0, 255);
            m_draw_dom_level2.To = Color.FromArgb(0, 0, 80);
        }

        protected override void CalcBar(){
            if (!Bars.LastBarOnChart)
                return;

            ExecControl.RecalcLastBarAfter(TimeSpan.FromSeconds(updatespeed_seconds));

            if (Bars.DOM.Connected){
                m_value11 = 0;

                foreach (var domPrice in Bars.DOM.Ask)
                    m_value11 = Math.Max(m_value11, domPrice.Size);
                foreach (var domPrice in Bars.DOM.Bid)
                    m_value11 = Math.Max(m_value11, domPrice.Size);

                m_draw_dom_level1.Call();
                m_draw_dom_level2.Call();

                Plot1.Set("OK", Color.White);
            }
            else{
                Plot1.Set("Level2 data is not avaliable", Color.Red);
            }
        }
    }
}
These users thanked the author admin for the post (total 2):
LaurentiusJoshM

tekram
Posts: 96
Joined: 26 May 2009
Has thanked: 6 times
Been thanked: 18 times

Re: Market Depth on Chart

Postby tekram » 31 Jul 2012

Thank you.

Market depth is not supported for some data feed, such as TS?

IB data disconnect seemed to have reset indicator with System.NullReferenceException.
Attachments
MDepthError_2012-08-01_003123.gif
MDepthError_2012-08-01_003123.gif (13.66 KiB) Viewed 1353 times

User avatar
4trading
Posts: 47
Joined: 29 Jun 2010
Location: Texas
Has thanked: 22 times
Been thanked: 3 times

Re: Market Depth on Chart

Postby 4trading » 01 Aug 2012

tekram wrote:Thank you.

Market depth is not supported for some data feed, such as TS?

IB data disconnect seemed to have reset indicator with System.NullReferenceException.


TS supports Level II with a data subscription. IB data is working with this indicator OK for me.

User avatar
Henry MultiСharts
Posts: 8507
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2732 times

Re: Market Depth on Chart

Postby Henry MultiСharts » 01 Aug 2012

tekram wrote:Thank you.

Market depth is not supported for some data feed, such as TS?

IB data disconnect seemed to have reset indicator with System.NullReferenceException.

Hello tekram,

Market Depth data can be obtained only for the data feeds that are also supported as brokers in MultiCharts and provide DOM data through the API.

User avatar
CrazyNasdaq
Posts: 262
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 77 times
Been thanked: 80 times

Re: Market Depth on Chart

Postby CrazyNasdaq » 06 Aug 2012

Market Depth on chart 2 is interesting, but it does not recognize the numbers of decimals of the instrument. Which is the line of code to modify ?
Attachments
Depth of Market 2 NET.gif
Depth of Market 2 NET.gif (60.51 KiB) Viewed 1356 times

bluejack
Posts: 42
Joined: 02 Aug 2012
Has thanked: 25 times
Been thanked: 27 times

Re: Market Depth on Chart  [SOLVED]

Postby bluejack » 06 Aug 2012

CrazyNasdaq wrote:Market Depth on chart 2 is interesting, but it does not recognize the numbers of decimals of the instrument. Which is the line of code to modify ?

I fixed it. The problem was that the price format was not considering the price scale of a symbol.

(Import the attached .pln File with PowerLanguage Editor => Import...)
Attachments
DOMOnChart_bluejack.pln
(3.59 KiB) Downloaded 326 times
These users thanked the author bluejack for the post (total 5):
Henry MultiСhartsTIKITRADERLaurentiusJoshMrjelles

User avatar
Laurentius
Posts: 90
Joined: 01 Jan 2011
Location: Europe
Has thanked: 138 times
Been thanked: 36 times

Re: Market Depth on Chart

Postby Laurentius » 20 Nov 2012

I see that Henry have given a kind of answer, but just have to ask anyway. Meaning since Market Depth on Chart is an indicator attached to the chart, is it not possible to have market depth from the "non broker" data feed provider? I would prefer market depth from a good data feed provider instead of my brokers.

Thanks,
Laurentius

User avatar
Henry MultiСharts
Posts: 8507
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2732 times

Re: Market Depth on Chart

Postby Henry MultiСharts » 21 Nov 2012

Laurentius wrote:is it not possible to have market depth from the "non broker" data feed provider? I would prefer market depth from a good data feed provider instead of my brokers.

Hello Laurentius,

That is not possible. Which_Data_Sources_Can_Be_Used_to_Plot_Depth_of_Market_(DOM)_Window
These users thanked the author Henry MultiСharts for the post:
Laurentius

samuelhogg
Posts: 1
Joined: 07 Apr 2013

Re: Market Depth on Chart

Postby samuelhogg » 07 Apr 2013

I downloaded the SE version yesterday to give MC a trial, I really like what I see.

Is this still the case regarding market depth?
Can I only see the depth of my broker and not the market? I am currently using IQFeed.

Samuel

Henry MultiСharts wrote:
Laurentius wrote:is it not possible to have market depth from the "non broker" data feed provider? I would prefer market depth from a good data feed provider instead of my brokers.

Hello Laurentius,

That is not possible. Which_Data_Sources_Can_Be_Used_to_Plot_Depth_of_Market_(DOM)_Window

User avatar
Henry MultiСharts
Posts: 8507
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2732 times

Re: Market Depth on Chart

Postby Henry MultiСharts » 08 Apr 2013

samuelhogg wrote:I downloaded the SE version yesterday to give MC a trial, I really like what I see.
Is this still the case regarding market depth?
Can I only see the depth of my broker and not the market? I am currently using IQFeed.
Samuel

Yes, this behavior has not been changed.


Return to “User Contributed Studies”