Bar Viewer - Great Tool for Debugging Studies

User avatar
orad
Posts: 121
Joined: 14 Nov 2012
Has thanked: 50 times
Been thanked: 20 times

Bar Viewer - Great Tool for Debugging Studies

Postby orad » 01 Feb 2015

You can specify any .NET object for browsing, and customize it to your needs. This indicator uses Jeff Key's Object State Browser that you will need to download and reference in your study.

Update: Since the above link is broken, I put the file in the attachment.

Image

BarViewer.Indicator.cs

Code: Select all

// Add a reference to Jeff Key's Object State Browser control.
// Download it from http://www.sliver.com/dotnet/statebrowser/

using System;
using System.Windows.Forms;
using sliver.Windows.Forms;

namespace PowerLanguage.Indicator
{
[SameAsSymbol(true), MouseEvents(true)]
public class BarViewer : IndicatorObject
{
public BarViewer(object _ctx) : base(_ctx) { }

protected override void Create()
{
}

private bool _isInitialized;

protected override void StartCalc()
{
RunOnce(ref _isInitialized, () => {
MessageBox.Show("Open Expert Commentary and CTRL-Click on a bar to view its properties.",
"BarViewer Indicator", MessageBoxButtons.OK, MessageBoxIcon.Information);
});
}

protected override void CalcBar()
{
if (ExpertCommentary.AtCommentaryBar)
{
this.ShowStateBrowserForm(Bars);
}
}

protected override void OnMouseEvent(MouseClickArgs args)
{
if (args.buttons == MouseButtons.Left && args.keys == Keys.Control)
{
this.ShowStateBrowserForm(args.point);
}
}

private StateBrowserForm _stateBrowser;

private void ShowStateBrowserForm(object objectToBrowse)
{
if (this._stateBrowser == null || this._stateBrowser.IsDisposed)
{
this._stateBrowser = new StateBrowserForm();
}
var osb = this._stateBrowser;
osb.ObjectToBrowse = objectToBrowse;
osb.BoldMemberNames.AddRange(new []{ "OpenValue", "HighValue", "LowValue", "CloseValue", "TimeValue" });
osb.BoldMemberTypes.AddRange(new []{ typeof(ISeries<double>) });
osb.ShowDataTypes = false;
osb.ShowNonPublicMembers = false;
osb.ShowStaticMembers = true;
osb.TopLevel = true;
osb.TopMost = true;
osb.Show();
osb.BringToFront();
}

private void RunOnce(ref bool flag, Action action)
{
if (!flag)
{
action();
flag = true;
};
}

protected override void StopCalc()
{
this._stateBrowser.Close();
this._stateBrowser.Dispose();
}

}
}

Cheers,
orad
Attachments
sliver.Windows.Forms.StateBrowser.zip
(14.44 KiB) Downloaded 177 times
ObjectStateBrowser.png
(98.64 KiB) Downloaded 1199 times
Last edited by orad on 08 Mar 2019, edited 1 time in total.

AlphaCat
Posts: 69
Joined: 09 Jul 2013
Been thanked: 9 times

Re: Bar Viewer - Great Tool for Debugging Studies

Postby AlphaCat » 04 Feb 2015

Very nice, thanks for posting.


Return to “User Contributed Studies”