Serialising thread/code samples from NT forum - NinjaTrader Programming | futures io social day trading
futures io futures trading


Serialising thread/code samples from NT forum
Updated: Views / Replies:3,026 / 2
Created: by cclsys Attachments:0

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

Serialising thread/code samples from NT forum

  #1 (permalink)
Elite Member
Sydney, NS
 
Futures Experience: Intermediate
Platform: Ninja
Broker/Data: Zen-Fire
Favorite Futures: TF,S,GC
 
cclsys's Avatar
 
Posts: 607 since Nov 2009
Thanks: 248 given, 379 received

Serialising thread/code samples from NT forum

If anyone runs into serializing issues, this thread has some good info with clear coding examples.

NinjaTrader Support Forum - View Single Post - Complete list of NinjaTrader.Gui.Design.Serializable options?

I paste it in here too (the main contribution):

Warning: I've been asked to remind all that "Unsupported" means this may break in a future release. Or might not work with other aspects of the program eg Analyzer etc. Use this insight with caution, it is not documented.


Thanks everyone.
I used .NET reflection to rip out all the Methods, Properties etc.
I can state with confidence that there are only 3 extra serialisation methods provided by Ninja above that which comes standard with .NET.
They are :-
  • NinjaTrader.Gui.Design.SerializableColor
  • NinjaTrader.Gui.Design.SerializableFont
  • NinjaTrader.Gui.Design.SerializablePen
Pen seems to work differently so get confident with the others first.

On Serialising the File Object.
Clearly not difficult to parse the properties into a Parameter & use XMLSerialise & StreamWriter to create my own serialization class. But unlike the Color & Font it doesn't appear that the Ninja properties dialog is designed to handle the File Objects properties. So hooking it up the FileOpen dialog looked like it would make the indicator too hard to install on other peoples machines. As getting an "easy to change property value" experience wa what I was going for. Its back to the drawing board.

I hope you find the code below useful.

Partial code walking you thru the step to use build-in Ninja Serialization.
Step 1 - Declare local Variables

#region Variables
// Wizard generated variables
private float yOffset = 15; // Gap up from the bottom of the Panel
private Color textColor = Color.Black;

// User defined variables (add any user defined variables below)
//----------< Text for Y Axis Labels >--------------------
StringFormat stringFormat = new StringFormat();
private SolidBrush textBrush = new SolidBrush(Color.Black);
private Font textFont = new Font("Arial", 8);
#endregion

Step 2 - Set Brush color to property

protected override void Initialize()
{
textBrush.Color = textColor;

Step 3 - Set Properties & Serialise Correctly


[Description("Y Offset of text from Bottom of Panel")]
[Category("Parameters - Font")]
[Gui.Design.DisplayName("Text Position")]
public float YOffset
{
get { return yOffset; }
set { yOffset = Math.Min(Math.Max(0,value),1000); }
}

[Browsable(false)]
public string MyFontSerialize
{
get { return NinjaTrader.Gui.Design.SerializableFont.ToString(textFont); }
set { textFont = NinjaTrader.Gui.Design.SerializableFont.FromString (value); }
}

[XmlIgnore()]
[Description("Font of Bar Numbers")]
[Gui.Design.DisplayName("Text Font")]
[Category("Parameters - Font")]
public System.Drawing.Font TextFont
{
get { return textFont; }
set { textFont = value; }
}

[Browsable(false)]
public string TextColorSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(textColor); }
set { textColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
}

[XmlIgnore()]
[Description("Color of Bar Numbers")]
[Category("Parameters - Font")]
[Gui.Design.DisplayName("Text Color")]
public Color TextColor
{
get { return textColor; }
set { textColor = value; }
}
#endregion

Step 4 - Use it Somewhere

public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
{
// ---< ensure you call the base Plot Method prior to exiting this method >---
base.Plot(graphics, bounds, min, max);

if (Bars == null || /*Plots.Count < 2 ||*/ ChartControl == null)
return;

// if (CurrentBar <= 1)
// return;

// ------------< Initialise Offsets & Graphic environment >---------------------
int barWidth = ChartControl.ChartStyle.GetBarPaintWidth(ChartCont rol.BarWidth);
int barSpace = ChartControl.BarSpace;

SmoothingMode oldSmoothingMode = graphics.SmoothingMode;
graphics.SmoothingMode = SmoothingMode.AntiAlias;

// ===< Determine where Text will be displayed.Bottom of the Price Chart >===
float y = bounds.Top + bounds.Height - yOffset - textFont.Height;
graphics.DrawString( "CB-cntBar", textFont, textBrush, bounds.Left, y, stringFormat);

float y2 = y - 15;
graphics.DrawString( "cntBar", textFont, textBrush, bounds.Left, y2, stringFormat);

// ---< For each bar that is displayed on the screen >---
for(int cntBar = ChartControl.FirstBarPainted; cntBar <= ChartControl.LastBarPainted; cntBar++)
{
// if (!ChartControl.ShowBarsRequired && cntBar < BarsRequired)
// continue;

float x = ChartControl.GetXByBarIdx(cntBar);
graphics.DrawString( (CurrentBar - cntBar).ToString(), textFont, textBrush, x, y, stringFormat);
graphics.DrawString( cntBar.ToString(), textFont, textBrush, x, y2, stringFormat);
}

//=====< Return SmoothingMode to its original value >========
graphics.SmoothingMode = oldSmoothingMode;
}

Reply With Quote
The following user says Thank You to cclsys for this post:
 
  #2 (permalink)
Elite Member
Long Beach, CA
 
Futures Experience: Advanced
Platform: Ninja Trader
Favorite Futures: Futures
 
makusan's Avatar
 
Posts: 31 since Jun 2010
Thanks: 10 given, 12 received

Unable to Save GOMI indicators-Not Serialized

From time to time I'm getting unable to save due to indicator is not "serialized", in NT7. This happens with GOMI indicators. Most recently it is the GomRecorderIndicator. Works just fine. I have it set up as instructed, then, out of the blue, at end of day when I go to save all workspaces I get serialized error message. What do I need to do to correct this error. NT tech instructs to delete .xml file?

Respectfully,
Makusan

Reply With Quote
 
  #3 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,214 received



makusan View Post
From time to time I'm getting unable to save due to indicator is not "serialized", in NT7. This happens with GOMI indicators. Most recently it is the GomRecorderIndicator. Works just fine. I have it set up as instructed, then, out of the blue, at end of day when I go to save all workspaces I get serialized error message. What do I need to do to correct this error. NT tech instructs to delete .xml file?

Respectfully,
Makusan

Use the GomRecorder thread:

https://futures.io/elite-circle/6802-gomrecorder-2-a.html

Post your question there, along with exact error messages from the log output, and exact version of GomRecorder and any other Gom* indicators you are using.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote

Reply



futures io > > > > > Serialising thread/code samples from NT forum

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert this NT code to EL, Please lizmerrill EasyLanguage Programming 8 January 20th, 2011 02:33 PM
Strategy + indicator coding - samples / examples max-td NinjaTrader Programming 19 December 2nd, 2009 05:31 AM
Need confirmation of NT code please Saroj NinjaTrader Programming 4 September 26th, 2009 01:51 PM
FF allows the THREAD STARTER to ignore posters so they can NOT post in their thread. TheRumpledOne Off-Topic 2 September 19th, 2009 01:53 AM


All times are GMT -4. The time now is 07:39 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, 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 2017-12-11 in 0.11 seconds with 19 queries on phoenix via your IP 54.226.132.197