NexusFi: Find Your Edge


Home Menu

 





SveRenko from NT7 to NT8


Discussion in NinjaTrader

Updated
    1. trending_up 631 views
    2. thumb_up 3 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
 

SveRenko from NT7 to NT8

 
 Gibby 
BC
 
Experience: Advanced
Platform: Ninja
Broker: Amp with Zenfire and IB
Trading: ES, currencies, forex
Posts: 75 since Sep 2009
Thanks Given: 15
Thanks Received: 16

Is anyone interested in converting this NT7 bar code into NT8?
// SVERenko Bars Type - V1.0
// Display of Renko full size bars with or without session breaks
// Sylvain Vervoort
// http://stocata.org
//
using System;
using System.ComponentModel;
using System.IO;

namespace NinjaTrader.Data
{
public class SveRenkoBarsType : BarsType
{
// Compilation disable Inconsistent Naming
#pragma warning disable 169
private static bool registered = Register(new SveRenkoBarsType());
#pragma warning restore 169
// Compilation restore Inconsistent Naming

private string msg;

public override void Add(Bars bars, double open, double high, double low, double close,
DateTime time, long volume, bool isRealtime)
{
if (bars.Count < 1 || bars.Period.Value2 == 1 && bars.IsNewSession(time))
{
AddBar(bars, close, close, close, close, time, 0, isRealtime);
AddBar(bars, close, close, close, close, time, volume, isRealtime);
return;
}

Bar bar = (Bar)bars.Get(bars.Count - 1);
Bar barprev = (Bar)bars.Get(bars.Count - 2);

double tickSize = bars.Instrument.MasterInstrument.TickSize;
double rangeValue = Math.Floor(10000000.0 * bars.Period.Value * tickSize) / 10000000.0;

double renkomax = barprev.Close >= barprev.Open ? barprev.Close : barprev.Close + rangeValue;
double renkomin = barprev.Close <= barprev.Open ? barprev.Close : barprev.Close - rangeValue;

if (bars.Instrument.MasterInstrument.Compare(close, renkomax + rangeValue) >= 0)
{
bars.RemoveLastBar();
AddBar(bars, bar.Open, renkomax + rangeValue, bar.Low, renkomax + rangeValue, time, bar.Volume, isRealtime);
bool isLastNewBar = close < renkomax + 2 * rangeValue;
double newBarOpen = renkomax + rangeValue;
double newClose = Math.Min(renkomax + 2 * rangeValue, close);

do
{
AddBar(bars, newBarOpen, newClose, newBarOpen, newClose, time, isLastNewBar ? volume : 0, isRealtime);
newBarOpen = newClose;
newClose = Math.Min(newClose + rangeValue, close);
isLastNewBar = close == newClose;
}
while (bars.Instrument.MasterInstrument.Compare(close, newClose) > 0);
}
else
if (bars.Instrument.MasterInstrument.Compare(renkomin - rangeValue, close) >= 0)
{
bars.RemoveLastBar();
AddBar(bars, bar.Open, bar.High, renkomin - rangeValue, renkomin - rangeValue, time, bar.Volume, isRealtime);
double newClose = Math.Max(renkomin - 2 * rangeValue, close);
double newBarOpen = renkomin - rangeValue;
bool isLastNewBar = close > renkomin - 2 * rangeValue;
do
{
AddBar(bars, newBarOpen, newBarOpen, newClose, newClose, time, isLastNewBar ? volume : 0, isRealtime);
newBarOpen = newClose;
newClose = Math.Max(newClose - rangeValue, close);
isLastNewBar = close == newClose;
}
while (bars.Instrument.MasterInstrument.Compare(newClose, close) > 0);
}
else
UpdateBar(bars, open, high, low, close, time, volume, isRealtime);
}

public override PeriodType BuiltFrom
{
get { return PeriodType.Tick; }
}

public override Gui.Chart.ChartStyleType[] ChartStyleTypesSupported
{
get { return new Gui.Chart.ChartStyleType[] { Gui.Chart.ChartStyleType.CandleStick }; }
}

public override int GetInitialLookBackDays(Period period, int barsBack)
{
return 1;
}

public override void ApplyDefaults(Gui.Chart.BarsData barsData)
{
barsData.DaysBack = 3;
barsData.Period.Value = 10;
}

public override string ChartDataBoxDate(DateTime time)
{
return time.ToString(Cbi.Globals.CurrentCulture.DateTimeFormat.ShortDatePattern);
}

public override string ChartLabel(Gui.Chart.ChartControl chartControl, DateTime time)
{
return time.ToString(chartControl.LabelFormatTick, Cbi.Globals.CurrentCulture);
}

public override object Clone()
{
return new SveRenkoBarsType();
}

public override int DefaultValue
{
get { return 10; }
}

public override string DisplayName
{
get { return "SveRenko"; }
}

public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, Period period, Attribute[] attributes)
{
PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, period, attributes);

// Remove properties not needed for SveRenko
properties.Remove(properties.Find("BasePeriodType", true));
properties.Remove(properties.Find("BasePeriodValue", true));
properties.Remove(properties.Find("PointAndFigurePriceType", true));
properties.Remove(properties.Find("ReversalType", true));

// Names used in the data series properties
Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value", "\rRenko Tick Size");
Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value2", "\rSession Breaks (1=Y:2=N)");
return properties;
}
public override bool IsIntraday
{
get { return true; }
}

public override double GetPercentComplete(Bars bars, DateTime now)
{
throw new ApplicationException("GetPercentComplete not supported in " + DisplayName);
}

public SveRenkoBarsType() : base(PeriodType.Custom1) {}

public override string ToString(Period period)
{
return String.Format("SveRenko {0} Ticks", period.Value);
}

/// <summary>
/// write debug to log file
/// </summary>
// Use this to store wanted debug information in a file Renko.log in the NinjaTrader log folder
// string msg = string.Concat("myValue1: ", myValue1.ToString(), "\r\nmyValue2: ", myValue2.ToString());
// Debug(time, bars.Count, msg);

void Debug(DateTime time, int bar, string msg)
{
// local variables
string path = string.Concat(Cbi.Core.UserDataDir.ToString(), @"log\Renko.log");
FileInfo file = new FileInfo(path);

// ensure file exists
if (!file.Exists)
{
using (StreamWriter sw = file.CreateText())
{
try
{
sw.WriteLine(string.Concat("===== ", DateTime.Now.ToString(), " ====="));
sw.Flush();
}
catch (Exception ex) { }
sw.Close();
}
}

// write debug entry
using (StreamWriter sw = File.AppendText(path))
{
try
{
sw.WriteLine("{0} : {1} \r\n{2}", time, bar, msg);
sw.Flush();
}
catch (Exception ex) { }
sw.Close();
}
}
}
}

Started this thread
Thanked by:

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
Quantum physics & Trading dynamics
The Elite Circle
Better Renko Gaps
The Elite Circle
 
 
 
bobwest's Avatar
 bobwest 
Western Florida
Site Moderator
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES, YM
Frequency: Several times daily
Duration: Minutes
Posts: 8,172 since Jan 2013
Thanks Given: 57,523
Thanks Received: 26,292


Gibby View Post
Is anyone interested in converting this NT7 bar code into NT8?

I hope someone will give you a hand with this. In the meantime, here are some suggestions that may improve your chances:

1, (And by far the most important) -- If you want some programming help, do not ever just print out the code in a post window. Why? Because it does not indent the lines properly, and it produces a huge blob of text that no one can read and that no one is going to try to figure out.

This is not your fault. It is the fault of the software, but take my word for it as a long-time programmer, the code as you are showing it is unreadable. This is actually worse than it seems, because when you copy/paste the code into the post window, it looks like it's indented OK. It just renders like this big mess when you hit Submit.

Instead, either export the indicator code in a zip file, or better yet, locate the .cs file (if you don't know what I'm talking about, just use the .zip export), and attach that file, without printing it, to your request. Why? Because anyone who is going to work on the indicator will need it as a file, not as text they have to copy off the screen, so make it easier for them.

2. Since you are an Elite member, you have access to the free NT7 to 8 thread, so you can make your post there and have a better chance of it being looked at. Here"s the link:


3. Show someone who is reading your post some reason why they should want to help. Usually traders like cool things on charts, so one thing you could do would be to put up a screen shot showing that this is a cool indicator that does something interesting, Or, you could simply add a description of what it does and why you think it's something that is useful. If you don't do something to engage someone else's interest, all you're doing is asking them to do some extra work for you without telling them why they should care. Not the best idea.

I hope you are successful in getting your code converted. These ideas may help you.

Bob.

When one door closes, another opens.
-- Cervantes, Don Quixote
Thanked by:

 



Last Updated on July 27, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts