Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Using declarations
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Xml.Serialization;
- using NinjaTrader.Cbi;
- using NinjaTrader.Gui;
- using NinjaTrader.Gui.Chart;
- using NinjaTrader.Gui.SuperDom;
- using NinjaTrader.Gui.Tools;
- using NinjaTrader.Data;
- using NinjaTrader.NinjaScript;
- using NinjaTrader.Core.FloatingPoint;
- using NinjaTrader.NinjaScript.DrawingTools;
- #endregion
- //This namespace holds Indicators in this folder and is required. Do not change it.
- namespace NinjaTrader.NinjaScript.Indicators.customs
- {
- public class a1: Indicator
- {
- protected override void OnStateChange()
- {
- if (State == State.SetDefaults)
- {
- Description = @"Enter the description for your new custom Indicator here.";
- Name = "a1";
- Calculate = Calculate.OnEachTick;
- IsOverlay = false;
- DisplayInDataBox = true;
- DrawOnPricePanel = true;
- DrawHorizontalGridLines = true;
- DrawVerticalGridLines = true;
- PaintPriceMarkers = true;
- ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
- //Disable this property if your indicator requires custom values that cumulate with each new market data event.
- //See Help Guide for additional information.
- IsSuspendedWhileInactive = true;
- //
- AddPlot(Brushes.Orange, "a1");
- }
- else if (State == State.Configure)
- {
- }
- else if (State == State.DataLoaded)
- {
- }
- }
- bool flag;
- protected override void OnBarUpdate()
- {
- try
- {
- if (!flag)
- {
- flag = true;
- ChartControl.Dispatcher.InvokeAsync(() =>
- {
- initialize_createGrid();
- });
- }
- }
- catch(Exception e)
- {
- Print(e.ToString());
- }
- }
- private System.Windows.Controls.Grid myGrid;
- private void initialize_createGrid()
- {
- try
- {
- myGrid = new System.Windows.Controls.Grid
- {
- Name = "MyCustomGrdaid32" + DateTime.Now.ToString("Hms"),
- HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
- VerticalAlignment = System.Windows.VerticalAlignment.Top
- };
- int i = -1;
- System.Windows.Controls.ColumnDefinition column1 = new System.Windows.Controls.ColumnDefinition();
- myGrid.ColumnDefinitions.Add(column1);
- System.Windows.Controls.ColumnDefinition column2 = new System.Windows.Controls.ColumnDefinition();
- myGrid.ColumnDefinitions.Add(column2);
- //
- // ======= WPF TEXTBOX
- Brush br = DateTime.Now.Second % 2 == 1 ? Brushes.Green : Brushes.Red;
- var newControl = new System.Windows.Controls.TextBox { Name = "asd", Text ="WPF textbox", Width = 100, Background = br };
- myGrid.Children.Add(newControl);
- i++;
- System.Windows.Controls.Grid.SetColumn((UIElement)newControl, i);
- //################
- // ======= WinForms TEXTBOX
- // %ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsFormsIntegration.dll
- System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
- System.Windows.Forms.TextBox txtBox = new System.Windows.Forms.TextBox{ Name = "tb3", Text ="WinForms textbox", Width = 100 };
- host.Child = txtBox;
- host.Background = Brushes.Yellow;
- host.Opacity = 0.5;
- host.Name ="dde";
- host.Visibility = Visibility.Visible;
- host.Child.MouseHover += MouseEvent1;
- myGrid.Children.Add(host);
- i++;
- System.Windows.Controls.Grid.SetColumn(host, i);
- //################
- if (!this.UserControlCollection.Contains(myGrid))
- {
- this.UserControlCollection.Add(myGrid);
- }
- }
- catch (Exception e)
- {
- Print(e.ToString());
- }
- }
- private void MouseEvent1(object sender, EventArgs e)
- {
- System.Windows.Forms.MessageBox.Show("a1");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement