Skip to content

Instantly share code, notes, and snippets.

View DexterHaslem's full-sized avatar
💭
why are you taking advice from a site that goes down weekly?

Dexter M Haslem DexterHaslem

💭
why are you taking advice from a site that goes down weekly?
View GitHub Profile
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
namespace NinjaTrader.Indicator
{
var guiAssembly = Assembly.LoadFile(@"C:\Users\DHaslem\Documents\nt8-git\NinjaTrader.Custom\bin\Debug\NinjaTrader.Custom.dll");
var drawType = guiAssembly.GetExportedTypes().FirstOrDefault(t => t.FullName == "NinjaTrader.NinjaScript.DrawingTools.Draw");
var methods = drawType.GetMethods();
foreach (var method in methods)
Console.WriteLine(method.Name + "(" + string.Join(",", method.GetParameters().Select(p => p.Name)) + ")");
Console.Write((methods.Length - 4) * 3);
/////////////////////////////
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace asdf
{
class CheckCase
ChartDot myDot;
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
{
//myDot = Draw.Dot(this, "myDot", true, Time[0], Close[0], Brushes.Orange);
myDot = Draw.Dot(this, "myDot", true, 0, Close[0], Brushes.Orange);
}
else if (myDot != null && CurrentBar > 2)
@DexterHaslem
DexterHaslem / gist:1348944
Created November 8, 2011 19:53
debug print streaming web request
let printStreamingWebReq (url : string, postContent : string) =
let req = WebRequest.Create url :?> HttpWebRequest
req.Method <- "POST"
req.Proxy <- null
let postDataEncoded = ASCIIEncoding.ASCII.GetBytes(postContent)
let len : int64 = int64 postDataEncoded.Length
req.ContentLength <- len
let reqStream = req.GetRequestStream()
reqStream.Write(postDataEncoded, 0, postDataEncoded.Length)
use response = req.GetResponse()
open System
type bar =
{ Symbol : string; Timestamp : DateTime;
Open : string; High : string; Low : string; Close : string;
Volume: int;
}
// F.US.DGH12 20111201 0107 110020 110020 110020 110020 1
let parse_bar (line : string, delim : char) =
@DexterHaslem
DexterHaslem / gist:2648306
Created May 9, 2012 19:45
depth first search (kill ur stack)
public static IEnumerable<T> DepthFirstSearch<T>(IEnumerable<T> start, Func<T, IEnumerable<T>> selector, Func<T, bool> predicate)
{
var results = new List<T>();
foreach (T item in start)
{
if (predicate != null && predicate(item))
results.Add(item);
else if (predicate == null)
results.Add(item);
var subItems = selector(item);
public static IEnumerable<T> FlattenTree<T>(IEnumerable<T> list, Func<T, IEnumerable<T>> subitems)
{
foreach (T child in list)
{
yield return child;
foreach (T other in FlattenTree(subitems(child), subitems))
yield return other;
}
}
@DexterHaslem
DexterHaslem / gist:3084661
Created July 10, 2012 16:54
runtime indicator
protected override void OnBarUpdate()
{
string indicator = "EMA";
Type indicatorType = Type.GetType("NinjaTrader.Indicator." + indicator);
IndicatorBase indicatorBase = (IndicatorBase) Activator.CreateInstance(indicatorType);
Print(indicatorBase.GetHashCode() + ":" + indicatorBase.GetType().FullName);
indicatorBase.BarsRequired = BarsRequired;
indicatorBase.CalculateOnBarClose = CalculateOnBarClose;
indicatorBase.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicatorBase.MaximumBarsLookBack = MaximumBarsLookBack;
:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.CodedUITestFramework". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.TestTools.UITest.Common". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.TestTools.UITest.Extension". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
c:\W