Is NinjaScript only good for day trading? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Is NinjaScript only good for day trading?
Updated: Views / Replies:582 / 4
Created: by maxmorrow Attachments:1

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
 

Is NinjaScript only good for day trading?

  #1 (permalink)
Elite Member
Chicago, IL.
 
Futures Experience: Intermediate
Platform: Ninjascript, ThinkOrSwim
Favorite Futures: Stocks
 
maxmorrow's Avatar
 
Posts: 5 since Nov 2012
Thanks: 8 given, 4 received

Is NinjaScript only good for day trading?

I have coded a couple different strategies that are basically position trades that would hold a stock for a couple days and possibly a couple months. The strategies only trade during the regular 9:30-4 market hours. I am fairly happy with how everything is looking. They won't win any awards but are well thought out and fairly simple. Everything is automated from position size, multiple entries, and multiple exits/stops

Now that I am paper trading them I see that a Ninjascript can’t see what positions I hold in Interactive Brokers that were entered the previous day or days. It would make coding something like “if Position.MarketPosition == MarketPosition.Long do XYZ “ worthless since the script can not see if there was a position.

Can anyone point me in the direction of solving this? Is Ninjascript only good for day trading?

I have been looking around for awhile but haven’t really seen anyone discussing this except one post in the Ninjatrader support forum. Any suggestions, links to forum posts, any leads to chase down would be super appreciated.

Thanks


Last edited by maxmorrow; November 18th, 2014 at 11:54 PM.
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Seville, Spain
 
Futures Experience: Beginner
Platform: NinjaTrader + Dendric
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
pintope's Avatar
 
Posts: 17 since May 2014
Thanks: 5 given, 9 received


Hello @maxmorrow,

You can check the collection Performance.AllTrades. For example, last trade would be:
 
Code
Trade lastTrade = Performance.AllTrades[Performance.AllTrades.Count - 1];

The Trade object (have a look here) has properties Entry and Exit, of type IExecution, where you can check the time (property Time) the execution occurred.

To know the current position size, check Position.Quantity.

But all this from the same strategy instance. If you have separate strategy instances running and want to know all the open positions, I would use a file. Every strategy would read/write in this unique file when opening/closing a position. I have been using files in my strategies and it works nicely.

Reply With Quote
The following user says Thank You to pintope for this post:
 
  #4 (permalink)
Elite Member
Chicago, IL.
 
Futures Experience: Intermediate
Platform: Ninjascript, ThinkOrSwim
Favorite Futures: Stocks
 
maxmorrow's Avatar
 
Posts: 5 since Nov 2012
Thanks: 8 given, 4 received

Thanks @pintope

Ahh, a new thing to learn. Do you write to a text, excel, or some other kind of file? I have been reading as much as I can about C# and writing to file. Gonna take some trial and error but it makes sense. I am surprised about how little I have found about writing to file in regard to Ninjascript. I will post some more about my trials in hopes that it will help someone else in their coding. Cheers.

Reply With Quote
 
  #5 (permalink)
Elite Member
Seville, Spain
 
Futures Experience: Beginner
Platform: NinjaTrader + Dendric
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
pintope's Avatar
 
Posts: 17 since May 2014
Thanks: 5 given, 9 received

Hello @maxmorrow,

The good thing of NinjaScript is that it’s pure C#, not another platform-specific language. There are tons of books, sample code and an immense community around C#. Three cheers for that.

I write to a text file in CSV format (comma-separated values). To make it easier, I will give you some code. Check the file CSVFileManager.cs attached to this post. It’s all you need to read/write a CSV text file. I took this code from here.

Copy it to folder “C:\Users\Myself\Documents\NinjaTrader 7\bin\Custom\Strategy” (1). Take into account all the classes in this file belongs to namespace futures.io (formerly BMT), so you need to add to your strategies a “using futures.io (formerly BMT)” directive.

To write I use this code in one indicator of mine:
 
Code
using (CsvFileWriter writer = new CsvFileWriter(fileFullPath)) // (2)
{
	CsvRow row = new CsvRow();
	
	// Header.
	row.Add("Week");
	row.Add("Average");
	row.Add("StandardDeviation");
	writer.WriteRow(row);
	
	// Data.
	for (int i = 0; i < periodData["Avg"].Count; i++)
	{
		row = new CsvRow();
		row.Add(periodData["YW"][i]);
		row.Add(periodData["Avg"][i]);
		row.Add(periodData["Std"][i]);

		writer.WriteRow(row);
	}
}

And this is the code to read:
 
Code
using (CsvFileReader reader = new CsvFileReader(fileFullPath))
{
	CsvRow row = new CsvRow();
	reader.ReadRow(row); // Header (3).
	while (reader.ReadRow(row))
	{
		avg = row[1]; // (4)
		std = row[2]; // (4)
		int rowYear = int.Parse(row[0].Split(DELIMITER_CHARS)[0]);
		int rowWeek = int.Parse(row[0].Split(DELIMITER_CHARS)[1]);
		if (rowYear < currentYear || rowWeek < currentWeek) // (5)
		{
			continue;
		}
		else
		{
			break;
		}
	}
}

Notes:
(1) You could also copy it to folder “C:\Users\Myself\Documents\NinjaTrader 7\bin\Custom\Type” and your strategies will compile, but when you try to export a strategy using these classes an error occurs. You have to export the strategy along with CSVFileManager.cs.
(2) A candidate for “fileFullPath” could look like “C:\Users\Myself\Documents\Trading\Year\Month\tradesLog1.csv”. These files would be your trades logs for you to consult.
(3) Don’t forget the first line is a header and must be discarded.
(4) This is the info I’m looking for, in your case the trades info.
(5) The first column (row[0]) is my “key” field, I use a string in year/week format, like “2014/30”. You should use the instrument and something else.

I hope this will help you.

Attached Files
Register to download File Type: cs CSVFileManager.cs (4.6 KB, 5 views)
Reply With Quote
The following 4 users say Thank You to pintope for this post:

Reply



futures io > > > > > Is NinjaScript only good for day trading?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trading ES for success -PA Day after Day pipandrun Elite Trading Journals 615 April 13th, 2015 02:16 AM
can't day trading when is good time to trade lexxmd Traders Hideout 6 September 25th, 2014 03:09 PM
is AmiBroker a good option not only for analysis but for day trading ? andby AmiBroker 15 October 24th, 2012 11:10 PM
Strategic Day Trading Room. Great, Good or Bad? tickvix Currency Futures 2 May 5th, 2012 07:48 AM
Have a good Memorial Day Big Mike Off-Topic 7 May 31st, 2010 06:42 PM


All times are GMT -4. The time now is 11: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-14 in 0.10 seconds with 20 queries on phoenix via your IP 54.227.51.103