importing .Net into Ninja - futures io
futures io futures trading



importing .Net into Ninja


Discussion in NinjaTrader

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

(If you already have an account, login at the top of the page)

 
Search this Thread
 

importing .Net into Ninja

(login for full post details)
  #1 (permalink)
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 181 since Aug 2009
Thanks: 103 given, 56 received

Hello

I currently am trying to write a program to do the following:

On current Bar (using Daily time frame) of the ES, find out which contract is the current contract and then which contract is the next contract.
So, if the last bar is Friday Feb 03 2012, then it would be
 
Code
string currentDate = "03 Feb 2012";
//The first day of trading on March to last day before rollover
     if ((currentDate >= "08 Dec 2011") && currentDate <= "07 March 2012")) 
string currentContract = "201203"; //March 2012 ES contract
Then the next thing I want to do is figure out that the next contract is June
 
Code
string nextContract = "201206"; //so I have to add 3 to the end

Then I want to take the current close of the current bar for 201203 and 201206 and take the difference.
if the currentDate.Close[0] > nextContract.Close[0]
    print Green Dot
else
    print Grey Dot
So, I have like 55 or so ES contracts from 1997 and wanted to figure this out. So, for each bar, it would have to check first which contract is being traded, which is the next contract, and then take the different of the current bar close of each contract, and if the currentContract > nextContract, show that as a bullish sign on the chart.

Also, I went through all 55 or so contracts the other day, and made an excel spread sheet according to contract rollover, and manually put in the Start Date, End Date, Contract Name

So, I have all of that start and stop data. Now I just need to know how to use this in Ninja Trader.
Also, I want to have this be an indicator in the bottom panel and therefore do not care if it is ES, or DJIA, or SPX, or GOOG in the upper panel as it does not depend on the upper panel data

I dont know how hard this would be.

I know that in C# (ASP.Net in this case), you can use something like this:
 
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void btnResults_Click(object sender, EventArgs e)
    {

        DateTime start = Convert.ToDateTime(txtStartDate.Text);
        
        DateTime end = Convert.ToDateTime(txtEndDate.Text);
        DateTime today = DateTime.Today;
        if ((start <= today) && (end >= today))
        {
            lblOutput.Text = "Valid";
        }
        else
            lblOutput.Text = "Not Valid";
    }
}
Also, that leads to the title of this post: I dont see the DateTime class in NinjaTrader.
I thought NinjaTrader included all of the entire .Net Libraries Framework. Maybe I am confused, but if I dont see that DateTime class in Ninja
and it is in Visual Studio 2012, how do I get it into NinjaTrader, so I can develop with it?

thanks
Spencer

Follow me on Twitter Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(169 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #2 (permalink)
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,665 since Jun 2009
Thanks: 3,786 given, 4,494 received

???
DateTime in included in "System", so you can use it directly in NinjaScript:
 
Code
                            
System.DateTime   m = new DateTime(20120209224735);; 


Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
The following user says Thank You to sam028 for this post:
 
(login for full post details)
  #3 (permalink)
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 181 since Aug 2009
Thanks: 103 given, 56 received


HI Sam

thanks. I got confused because when I just typed DateTime in NinjaTrader, no intelisense popped up.
However, when I do it in visual studio, it pops up.

So, I am used to Java more than C# and how it works with libraries. Java is very portable and I always have to add the library to eclipse, then just import com.etc.......

In .Net, everything is already in the GAC so does that mean everything accessible by Visual Studio is also accessible by NinjaTrader by default-----no need to install additional .dll's, just word it correctly

Visual Studio:
DateTime start = Convert.ToDateTime("10 May 2010");

Ninja Trader:
System.DateTime start = Convert.ToDateTime("10 May 2010");

Does this sound right since both say using System; in the top?

thanks
Spencer

Follow me on Twitter Started this thread Reply With Quote
 
(login for full post details)
  #4 (permalink)
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,665 since Jun 2009
Thanks: 3,786 given, 4,494 received

You can write
 
Code
                            
System.DateTime start Convert.ToDateTime("10 May 2010"); 

or
 
Code
                            
DateTime start Convert.ToDateTime("10 May 2010"); 

it doesn't matter, it's the same thing.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
The following user says Thank You to sam028 for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > importing .Net into Ninja


Last Updated on February 5, 2012


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
     



Copyright © 2021 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