a little programming question - NinjaTrader | futures io social day trading
futures io futures trading


a little programming question
Updated: Views / Replies:75 / 0
Created: by futurewiz Attachments:2

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 100,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
 

a little programming question

  #1 (permalink)
Stuttgart Deutschland
 
Trading Experience: Beginner
Platform: Ninjatrader
Broker/Data: CQG
Favorite Futures: FDAX, ES
 
Posts: 54 since Nov 2012
Thanks: 37 given, 21 received

a little programming question

Hello,
maybe someone has a good idea:

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


It revolves around the display of yesterday's high or low, especially the text description.
The position of the description of the low is my starting point. this is the currently working variant.
However, if I use M1 as the timeframe, the description with the tag advancing will be out of sight and so I'm looking for ways to make the description move with it (slightly in front of the bars) in order to finally stay there for the session break line at the end of the day.
On the screenshot you can see the desater. The yesterday high line is garbage because the text descriptions are printed over and over again without deleting the previous one.

i tried to print the line after the text description to overwrite it, but you see the success.

Prigramming isn't my strong point and that's just a beauty flaw, but I find a clear screen with few lines and always knowing where I am is important for our business.

Maybe you have some tips.

A second question I would like to get rid of. Similar to the current lines I would like to display the VA high and VA low from yesterday as well. If you know an indicator that calculates the VA and only draws the lines into the new day without printing profiles.

Thank you very much for your help
futurewiz

 
Code
                            
// 

// Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//

#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    
/// <summary>
    /// Plots the high and low values from the session starting on the prior day.
    /// </summary>
    
[Description("Plots the high and low values from the session starting on the prior day.")]
    public class 
KnPriorDayHighAndLow Indicator
    
{
        
#region Variables

        // Wizard generated variables
        // User defined variables (add any user defined variables below)
        //OLD private DateTime     currentDate     = Cbi.Globals.MinDate;
        
private DateTime     currentDate     DateTime.Now;
        private 
DateTime    actualBarTime;  // for Line Description Printing
        
        
private double        currentOpen        0;
        private 
double        currentHigh        0;
        private 
double        currentLow        0;
        private 
double        currentClose    0;
        private 
double        priordayOpen    0;
        private 
double        priordayHigh    0;
        private 
double        priordayLow        0;
        private 
double        priordayClose    0;
        
        private 
bool        showHigh        true;
        private 
bool        showLow            true;
        
        
        private 
bool        showTextHigh            true;
        private 
string        showDescriptionHigh        "Y-High:";
        private 
Font         textFontHigh            = new Font("Arial"8fFontStyle.Regular);
        private 
Color         textColorHigh            Color.Green;
        private 
Color         outlineColorHigh        Color.Green;
        private 
Color         areaColorHigh            Color.Transparent;
        private 
int         zopacityHigh            0;
        
        private 
bool        showTextLow                true;
        private 
string        showDescriptionLow        "Y-Low:";
        private 
Font         textFontLow                = new Font("Arial"8fFontStyle.Regular);
        private 
Color         textColorLow            Color.Red;
        private 
Color         outlineColorLow            Color.Red;
        private 
Color         areaColorLow            Color.Transparent;
        private 
int         zopacityLow                0;        
        
        
#endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        
protected override void Initialize()
        {
            
Add(new Plot(Color.GreenPlotStyle.Hash"Prior High"));
            
Add(new Plot(Color.RedPlotStyle.Hash"Prior Low"));
            
            
Plots[0].Pen.DashStyle DashStyle.Dash;
            
Plots[1].Pen.DashStyle DashStyle.Dash;
            
            
AutoScale             false;
            
Overlay                true;      // Plots the indicator on top of price
        
}

        
/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        
protected override void OnBarUpdate()
        {
            if (
Bars == null)  // noch keine Bars da --> Warten
                
return;

            if (!
Bars.BarsType.IsIntraday// wenn größere Zeiteinheit als Intraday --> Fehler
            
{
                
DrawTextFixed("error msg""KN PriorDayHL only works on intraday intervals"TextPosition.BottomRight);
                return;
            }

            
// If the current date is not the same date as the current bar then its a new session !!! nur bei Sessionwechsel ausgeführt
            
if (currentDate != Bars.GetTradingDayFromLocal(Time[0]) || currentOpen == 0)
            {
                            
                
// The current day OHLC values are now the prior days value so set
                // them to their respect indicator series for plotting
                
if (currentOpen != 0)
                {
                    
priordayHigh    currentHigh;
                    
priordayLow        currentLow;
                    
                    if (
ShowHigh)  PriorHigh.Set(priordayHigh);
                    if (
ShowLow)   PriorLow.Set(priordayLow);
                    
                    
// Draw Description
                    
                    //if (showTextHigh)
                    //DrawText("highprice"+CurrentBar,true,showDescriptionHigh+"  "+Instrument.MasterInstrument.Round2TickSize(priordayHigh).ToString()+"   -",Time[3],priordayHigh,0,textColorHigh,textFontHigh,StringAlignment.Far,outlineColorHigh,areaColorHigh,ZopacityHigh);
                    //Time[3]
                    
if (showTextLow)
                    
DrawText("lowprice"+CurrentBar,true,showDescriptionLow+"  "+Instrument.MasterInstrument.Round2TickSize(priordayLow).ToString()+"   -",Time[3],priordayLow,0,textColorLow,textFontLow,StringAlignment.Far,outlineColorLow,areaColorLow,ZopacityLow);
                }
                
                
// Initilize the current day settings to the new days data
                
currentOpen     =     Open[0];
                
currentHigh     =     High[0];
                
currentLow        =    Low[0];
                
currentClose    =    Close[0];

                
currentDate     =     Bars.GetTradingDayFromLocal(Time[0]); 
            }
            else 
// The current day is the same day
            
{
                
// When will the Text Description printed (-1 is for the first print of the new day)
                
actualBarTime Time[-50]; 
                
                
// Set the current day OHLC values
                
currentHigh     =     Math.Max(currentHighHigh[0]);
                
currentLow        =     Math.Min(currentLowLow[0]);
                
currentClose    =    Close[0];
                
                
                
                if (
showTextHigh)
                    
DrawText("highprice"+CurrentBar,true,showDescriptionHigh+"  "+Instrument.MasterInstrument.Round2TickSize(priordayHigh).ToString()+"   -",actualBarTime,priordayHigh,0,textColorHigh,textFontHigh,StringAlignment.Far,outlineColorHigh,areaColorHigh,ZopacityHigh);
                
//if (showTextLow)
                //    DrawText("lowprice"+CurrentBar,true,showDescriptionLow+"  "+Instrument.MasterInstrument.Round2TickSize(priordayLow).ToString()+"   -",actualBarTime,priordayLow,0,textColorLow,textFontLow,StringAlignment.Far,outlineColorLow,areaColorLow,ZopacityLow);
            
                
if (ShowHighPriorHigh.Set(priordayHigh);
                if (
ShowLowPriorLow.Set(priordayLow);    
            }
        }

        
#region Properties
        
        
[Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        
[XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        
public DataSeries PriorHigh
        
{
            
get { return Values[0]; }
        }

        [
Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        
[XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        
public DataSeries PriorLow
        
{
            
get { return Values[1]; }
        }
        
// ==============================================================================================================================
        
[Browsable(true)]
        [
Gui.Design.DisplayNameAttribute("1.Show Yesterday High Line")]
        [
Category("Text Yesterday High Line")]
        public 
bool ShowHigh
        
{
            
get { return showHigh; }
            
set showHigh value; }
        }
        
        
        [
Description("Text marker")]
        [
Gui.Design.DisplayName ("2.Show Yesterday High Price")]
        [
Category("Text Yesterday High Line")]
        public 
bool ShowTextHigh
        
{
            
get { return showTextHigh; }
            
set showTextHigh value; }
        }
        
        [
Description("Text before Yesterday High Price")]
        [
Gui.Design.DisplayName ("3.Show Text Description")]
        [
Category("Text Yesterday High Line")]
        public 
string ShowDescriptionHigh
        
{
            
get { return showDescriptionHigh; }
            
set showDescriptionHigh value; }
        }
        
        [
XmlIgnore()]
        [
Description("Text Font")]
        [
Category("Text Yesterday High Line")]
        [
Gui.Design.DisplayNameAttribute("4.Text Font High")]
        public 
Font TextFont
        
{
            
get { return textFontHigh; }
            
set textFontHigh value; }
        }
        
        [
Browsable(false)]
        public 
string textFontSerializeHigh
        
{
            
get { return NinjaTrader.Gui.Design.SerializableFont.ToString(textFontHigh); }
            
set textFontHigh NinjaTrader.Gui.Design.SerializableFont.FromString(value); }
        }
        
        [
XmlIgnore]
        [
Description("Text Color")]
        [
Category("Text Yesterday High Line")]
        [
Gui.Design.DisplayNameAttribute("5.Text Color High")]
        public 
Color TextColorHigh
        
{
            
get { return textColorHigh; }
            
set textColorHigh value; }
        }
        
        [
Browsable(false)]
        public 
string textColorHighSerialize
        
{
            
get { return Gui.Design.SerializableColor.ToString(textColorHigh); }
            
set textColorHigh Gui.Design.SerializableColor.FromString(value); }
        }
        
        [
XmlIgnore]
        [
Description("Text Box Area Color")]
        [
Category("Text Yesterday High Line")]
        [
Gui.Design.DisplayNameAttribute("6.Text Box Area Color High")]
        public 
Color AreaColorHigh
        
{
            
get { return areaColorHigh; }
            
set areaColorHigh value; }
        }

        [
Browsable(false)]
        public 
string AreaColorHighSerialize
        
{
            
get { return Gui.Design.SerializableColor.ToString(areaColorHigh); }
            
set areaColorHigh Gui.Design.SerializableColor.FromString(value); }
        }        
        
        [
XmlIgnore]
        [
Description("Text Box Outline Color")]
        [
Category("Text Yesterday High Line")]
        [
Gui.Design.DisplayNameAttribute("7.Text Box Outline Color High")]
        public 
Color OutlineColorHigh
        
{
            
get { return outlineColorHigh; }
            
set outlineColorHigh value; }
        }

        [
Browsable(false)]
        public 
string OutlineColorHighSerialize
        
{
            
get { return Gui.Design.SerializableColor.ToString(outlineColorHigh); }
            
set outlineColorHigh Gui.Design.SerializableColor.FromString(value); }
        }
        
        [
Description("Zone Opacity")]
        [
Category("Text Yesterday High Line")]
        [
Gui.Design.DisplayNameAttribute("8.Text Box Opacity High")]
        public 
int ZopacityHigh
        
{
            
get { return zopacityHigh; }
            
set zopacityHigh value; }
        }
        
        
        
        
        
// ==============================================================================================================================
        
        
        
[Browsable(true)]
        [
Category("Text Yesterday Low Line")]
        [
Gui.Design.DisplayNameAttribute("10.Show Yesterday Low")]
        public 
bool ShowLow
        
{
            
get { return showLow; }
            
set showLow value; }
        }
        
        
        
        [
Description("Text marker")]
        [
Gui.Design.DisplayName ("2.Show Yesterday Low Price")]
        [
Category("Text Yesterday Low Line")]
        public 
bool ShowTextLow
        
{
            
get { return showTextLow; }
            
set showTextLow value; }
        }
        
        [
Description("Text before Yesterday Low Price")]
        [
Gui.Design.DisplayName ("3.Show Text Description")]
        [
Category("Text Yesterday Low Line")]
        public 
string ShowDescriptionLow
        
{
            
get { return showDescriptionLow; }
            
set showDescriptionLow value; }
        }
        
        [
XmlIgnore()]
        [
Description("Text Font")]
        [
Category("Text Yesterday Low Line")]
        [
Gui.Design.DisplayNameAttribute("4.Text Font Low")]
        public 
Font TextFontLow
        
{
            
get { return textFontLow; }
            
set textFontLow value; }
        }
        
        [
Browsable(false)]
        public 
string textFontSerializeLow
        
{
            
get { return NinjaTrader.Gui.Design.SerializableFont.ToString(textFontLow); }
            
set textFontLow NinjaTrader.Gui.Design.SerializableFont.FromString(value); }
        }
        
        [
XmlIgnore]
        [
Description("Text Color")]
        [
Category("Text Yesterday Low Line")]
        [
Gui.Design.DisplayNameAttribute("5.Text Color Low")]
        public 
Color TextColorLow
        
{
            
get { return textColorLow; }
            
set textColorLow value; }
        }
        
        [
Browsable(false)]
        public 
string textColorLowSerialize
        
{
            
get { return Gui.Design.SerializableColor.ToString(textColorLow); }
            
set textColorLow Gui.Design.SerializableColor.FromString(value); }
        }
        
        [
XmlIgnore]
        [
Description("Text Box Area Color")]
        [
Category("Text Yesterday Low Line")]
        [
Gui.Design.DisplayNameAttribute("6.Text Box Area Color Low")]
        public 
Color AreaColorLow
        
{
            
get { return areaColorLow; }
            
set areaColorLow value; }
        }

        [
Browsable(false)]
        public 
string AreaColorLowSerialize
        
{
            
get { return Gui.Design.SerializableColor.ToString(areaColorLow); }
            
set areaColorLow Gui.Design.SerializableColor.FromString(value); }
        }        
        
        [
XmlIgnore]
        [
Description("Text Box Outline Color")]
        [
Category("Text Yesterday Low Line")]
        [
Gui.Design.DisplayNameAttribute("7.Text Box Outline Color Low")]
        public 
Color OutlineColorLow
        
{
            
get { return outlineColorLow; }
            
set outlineColorLow value; }
        }

        [
Browsable(false)]
        public 
string OutlineColorLowSerialize
        
{
            
get { return Gui.Design.SerializableColor.ToString(outlineColorLow); }
            
set outlineColorLow Gui.Design.SerializableColor.FromString(value); }
        }
        
        [
Description("Zone Opacity")]
        [
Category("Text Yesterday Low Line")]
        [
Gui.Design.DisplayNameAttribute("8.Text Box Opacity Low")]
        public 
int ZopacityLow
        
{
            
get { return zopacityLow; }
            
set zopacityLow value; }
        }
        
        
        
#endregion
    
}
}

#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    public 
partial class Indicator IndicatorBase
    
{
        private 
KnPriorDayHighAndLow[] cacheKnPriorDayHighAndLow null;

        private static 
KnPriorDayHighAndLow checkKnPriorDayHighAndLow = new KnPriorDayHighAndLow();

        
/// <summary>
        /// Plots the high and low values from the session starting on the prior day.
        /// </summary>
        /// <returns></returns>
        
public KnPriorDayHighAndLow KnPriorDayHighAndLow()
        {
            return 
KnPriorDayHighAndLow(Input);
        }

        
/// <summary>
        /// Plots the high and low values from the session starting on the prior day.
        /// </summary>
        /// <returns></returns>
        
public KnPriorDayHighAndLow KnPriorDayHighAndLow(Data.IDataSeries input)
        {
            if (
cacheKnPriorDayHighAndLow != null)
                for (
int idx 0idx cacheKnPriorDayHighAndLow.Lengthidx++)
                    if (
cacheKnPriorDayHighAndLow[idx].EqualsInput(input))
                        return 
cacheKnPriorDayHighAndLow[idx];

            
lock (checkKnPriorDayHighAndLow)
            {
                if (
cacheKnPriorDayHighAndLow != null)
                    for (
int idx 0idx cacheKnPriorDayHighAndLow.Lengthidx++)
                        if (
cacheKnPriorDayHighAndLow[idx].EqualsInput(input))
                            return 
cacheKnPriorDayHighAndLow[idx];

                
KnPriorDayHighAndLow indicator = new KnPriorDayHighAndLow();
                
indicator.BarsRequired BarsRequired;
                
indicator.CalculateOnBarClose CalculateOnBarClose;
#if NT7
                
indicator.ForceMaximumBarsLookBack256 ForceMaximumBarsLookBack256;
                
indicator.MaximumBarsLookBack MaximumBarsLookBack;
#endif
                
indicator.Input input;
                
Indicators.Add(indicator);
                
indicator.SetUp();

                
KnPriorDayHighAndLow[] tmp = new KnPriorDayHighAndLow[cacheKnPriorDayHighAndLow == null cacheKnPriorDayHighAndLow.Length 1];
                if (
cacheKnPriorDayHighAndLow != null)
                    
cacheKnPriorDayHighAndLow.CopyTo(tmp0);
                
tmp[tmp.Length 1] = indicator;
                
cacheKnPriorDayHighAndLow tmp;
                return 
indicator;
            }
        }
    }
}

// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
    public 
partial class Column ColumnBase
    
{
        
/// <summary>
        /// Plots the high and low values from the session starting on the prior day.
        /// </summary>
        /// <returns></returns>
        
[Gui.Design.WizardCondition("Indicator")]
        public 
Indicator.KnPriorDayHighAndLow KnPriorDayHighAndLow()
        {
            return 
_indicator.KnPriorDayHighAndLow(Input);
        }

        
/// <summary>
        /// Plots the high and low values from the session starting on the prior day.
        /// </summary>
        /// <returns></returns>
        
public Indicator.KnPriorDayHighAndLow KnPriorDayHighAndLow(Data.IDataSeries input)
        {
            return 
_indicator.KnPriorDayHighAndLow(input);
        }
    }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public 
partial class Strategy StrategyBase
    
{
        
/// <summary>
        /// Plots the high and low values from the session starting on the prior day.
        /// </summary>
        /// <returns></returns>
        
[Gui.Design.WizardCondition("Indicator")]
        public 
Indicator.KnPriorDayHighAndLow KnPriorDayHighAndLow()
        {
            return 
_indicator.KnPriorDayHighAndLow(Input);
        }

        
/// <summary>
        /// Plots the high and low values from the session starting on the prior day.
        /// </summary>
        /// <returns></returns>
        
public Indicator.KnPriorDayHighAndLow KnPriorDayHighAndLow(Data.IDataSeries input)
        {
            if (
InInitialize && input == null)
                throw new 
ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

            return 
_indicator.KnPriorDayHighAndLow(input);
        }
    }
}
#endregion 

Attached Files
Register to download File Type: cs KnPriorDayHighAndLow.cs (18.0 KB, 1 views)
Reply With Quote

Reply



futures io > > > > a little programming question




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

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Programming (programming without coding) LukeGeniol Platforms and Indicators 11 September 16th, 2016 12:49 PM
Just a Fun little hypotherical question ashfsderse Traders Hideout 3 July 23rd, 2016 01:33 PM
Programming my first strategy - need a little review roreilly NinjaTrader Programming 4 August 5th, 2014 12:42 PM
3 Little Things That Aren't So Little Quick Summary News and Current Events 0 November 2nd, 2011 08:40 AM
A little programming help plz mpe66 NinjaTrader Programming 31 July 27th, 2011 09:16 AM


Tags
bar update, barstype, code, data, data series, dataseries, error, futures, indicator, indicators, instrument, market analyzer, namespace, ninja, ninjascript, ninjatrader, ohlc, programming, strategies, tick, timeframe, update, values

All times are GMT -4. The time now is 01:56 AM. (this page content is cached, log in for real-time version)

Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432 WhatsApp Business, 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 2019-06-18 in 0.17 seconds with 16 queries on phoenix