NexusFi: Find Your Edge


Home Menu

 





Excel Tradingjournal filled by Ninjatrader


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one fossil with 3 posts (1 thanks)
    2. looks_two SodyTexas with 2 posts (2 thanks)
    3. looks_3 DavidHP with 1 posts (1 thanks)
    4. looks_4 lsandersj with 1 posts (0 thanks)
      Best Posters
    1. looks_one Big Mike with 2 thanks per post
    2. looks_two SodyTexas with 1 thanks per post
    3. looks_3 DavidHP with 1 thanks per post
    4. looks_4 fossil with 0.3 thanks per post
    1. trending_up 2,636 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Excel Tradingjournal filled by Ninjatrader

  #1 (permalink)
 fossil 
Germany
 
Experience: Intermediate
Platform: Ninjatrader
Broker: IB and zen-Fire
Trading: NQ
Posts: 92 since Apr 2010
Thanks Given: 8
Thanks Received: 39

Iīve been searching for hours here but i canīt find an excel tradingjournal filled by Ninjatrader export. Maybe you know one please tell me.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Futures True Range Report
The Elite Circle
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
17 thanks
  #2 (permalink)
lsandersj
Bradenton, FL
 
Posts: 7 since Aug 2013
Thanks Given: 3
Thanks Received: 4

Have you looked at TJS Elite. It has a NJ import.
trading-journal-spreadsheet.com
Tell him Larry sent you/

Reply With Quote
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,534



fossil View Post
Iīve been searching for hours here but i canīt find an excel tradingjournal filled by Ninjatrader export. Maybe you know one please tell me.

The most popular one on nexusfi.com (formerly BMT) is this one:



Check end of thread, it's continually developed.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 
SodyTexas's Avatar
 SodyTexas 
Austin TX
 
Experience: Advanced
Platform: Ninjatrader, Python, & R
Broker: RJO
Trading: Futures, Spreads
Posts: 421 since Sep 2013
Thanks Given: 117
Thanks Received: 1,085


fossil View Post
Iīve been searching for hours here but i canīt find an excel tradingjournal filled by Ninjatrader export. Maybe you know one please tell me.

I have one based on Van Tharp's R-multiples, works great on live trading but horrible on market replay. It is based on this code here: Dionysus New Year Present – Ninja & Excel - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

FYI, the reason it does not work in market replay is because excel hangs when to much data is sent to it via a Interop. The solution to this is to build a RTD server, a DDE link or scratch excel for the trade log. I am taking the path of scratching excel as a trade log and building a MySQL database that will act as a trade log. From MySQL I can export the data to excel or use programs suchs as R or Matlab to play with the numbers.

Either way, I hope this code below is a good starting point for ya.

 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;

//Make sure to references the following dlls 
using Excel = Microsoft.Office.Interop.Excel; 
using System.IO;
#endregion		


		
		//Spreadseet
		private string excelFile = @"C:\Users\asoderstrom\Documents\Dropbox\NT7 Trade Log\TradeLogKinkoGC1.xlsm"; 
		private string excelSheetName = "Trade Log";
		private bool workSheetFound = false;
		private bool excelOpen=false;
		private string fullFileName;
		private string simpleFileName;
		Excel.Application excelApp;
		Excel._Workbook excelWorkBook;
		Excel._Worksheet excelSheet;
		Excel.Range excelRange;
		private int temp;
		
		//Export to spreadsheet
		private string xlLongShort;
		private string xlSymbol;
		private DateTime xlEntryTime;
		private int xlEntryQty;
		private double xlEntryPrice;
		private DateTime xlExitTime;
		private int xlExitQty;
		private double xlExitPrice;
		private double xlComission = 6.00;
		private double xlPnL;
		private double xlRmultiple;
		private double xlDollarRisk;

		Excel.Range AcctString;
		
        #endregion

        	
		
		#region updateExcel
		private void UpdateExcel()
		{
			excelRange = excelSheet.get_Range("A6","V6");
			excelRange.Rows.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftDown,false);
		
			excelSheet.Cells[6,1] = xlLongShort;
			excelSheet.Cells[6,2] = Instrument.MasterInstrument.Name;
			excelSheet.Cells[6,3] = xlEntryTime.ToString();
			excelSheet.Cells[6,4] = "=FLOOR(C6,1)";
			excelSheet.Cells[6,5] = xlEntryQty;
			excelSheet.Cells[6,6] = xlEntryPrice;
			excelSheet.Cells[6,7] = xlExitTime.ToString();
			excelSheet.Cells[6,8] = "=FLOOR(G6,1)";
			excelSheet.Cells[6,9] = xlExitQty;
			excelSheet.Cells[6,10] = xlExitPrice;
			excelSheet.Cells[6,11] = "=(G6-C6)*24";
			excelSheet.Cells[6,12] = "=I6*Comm";
			excelSheet.Cells[6,13] = xlPnL;
			excelSheet.Cells[6,14] = xlDollarRisk;
			excelSheet.Cells[6,15] = "=X6*Q7";
			excelSheet.Cells[6,16] = "=M6/O6";
			excelSheet.Cells[6,17] = "=Q7+M6";
			excelSheet.Cells[6,18] = "=(Q6-Q7)/Q7";
			excelSheet.Cells[6,19] = "=(Q6-bEquity)/bEquity";
			excelSheet.Cells[6,20] = "=MAX(Q6:bEquity)";
			excelSheet.Cells[6,21] = "=(Q6-T6)/T6";
			excelSheet.Cells[6,22] = "=IF(M6>=0,IF(V7<>0,V7+1,1),0)";
			excelSheet.Cells[6,23] = "=IF(M6<0,IF(W7<>0,W7+1,1),0)";
			excelSheet.Cells[6,24] = EquityAtRisk;
			AcctString = (Microsoft.Office.Interop.Excel.Range)excelSheet.Cells[1,11];
			EquityAtRisk = (double)AcctString.Value2;
			DrawTextFixed("hi","Ear: " + EquityAtRisk,TextPosition.BottomRight);
		}
		#endregion
		
		#region On Bar Update
        protected override void OnBarUpdate()
        {
			//Excel
			if (excelOpen == false) SetUpSpreadsheet();
			
			}
		#endregion
		
		#region On Execution
		protected override void OnExecution(IExecution execution)
		{
			//Long Trades ***************************************************************************************
			if (enterLong != null && enterLong.Token == execution.Order.Token)
			{
				if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
					{
					}
				if (execution.Order.OrderState != OrderState.PartFilled)
					{
						myEntryBar = CurrentBar;
						myBarsSinceEntry = 1;
						PLong = true;
						FToB = true;
						if(Close[0] < RiskL[0])
						{
							exitLong = ExitLong("S2C","B2O");
						}
						else
						{
							exitLongStop = ExitLongStop(0, true, execution.Order.Quantity, RiskL[0], "ATR-L", "B2O");
						}
					
						intRisk = (execution.Order.AvgFillPrice - MinCloud[0]);
						xlLongShort = "Long";
						xlEntryTime = execution.Order.Time;
						xlEntryQty = execution.Order.Quantity;
						xlEntryPrice = execution.Order.AvgFillPrice;
						enterLong = null;
					}
			}
			
			if ((exitLongStop != null && exitLongStop == execution.Order))
			{
				if (execution.Order.OrderState == OrderState.Filled && execution.Order.OrderState != OrderState.PartFilled)
				{
					PLong = false;
					xlExitTime =  execution.Order.Time;
					xlExitQty = execution.Order.Quantity;
					xlExitPrice = execution.Order.AvgFillPrice;
					xlPnL = Math.Round((((xlExitPrice - xlEntryPrice)*xlExitQty)*Instrument.MasterInstrument.PointValue),2);
					xlDollarRisk = Math.Round(((intRisk)*Instrument.MasterInstrument.PointValue),2);
					xlRmultiple = xlPnL/xlDollarRisk;
					UpdateExcel();
					exitLongStop = null;
				}
				
				if(execution.Order.OrderState == OrderState.Rejected)
				{
					exitLongStop = null;
				}
				
				
			}
			
			if(exitLong != null && exitLong == execution.Order)
			{
				if (execution.Order.OrderState == OrderState.Filled && execution.Order.OrderState != OrderState.PartFilled)
				{
					PLong = false;
					xlExitTime =  execution.Order.Time;
					xlExitQty = execution.Order.Quantity;
					xlExitPrice = execution.Order.AvgFillPrice;
					xlPnL = Math.Round((((xlExitPrice - xlEntryPrice)*xlExitQty)*Instrument.MasterInstrument.PointValue),2);
					xlDollarRisk = Math.Round(((intRisk)*Instrument.MasterInstrument.PointValue),2);
					xlRmultiple = xlPnL/xlDollarRisk;
					UpdateExcel();
					exitLong = null;
					exitLongStop = null;
				}
			}
			
			//Short Trades ***************************************************************************************
			
			if (enterShort != null && enterShort.Token == execution.Order.Token)
			{
				if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
					{
					}
				if (execution.Order.OrderState != OrderState.PartFilled)
					{
						myEntryBar = CurrentBar;
						myBarsSinceEntry = 1;
						PShort = true;
						intRisk = (MaxCloud[0] - execution.Order.AvgFillPrice);
						FToB = true;
						if(Close[0] > RiskS[0])
						{
							exitShort = ExitShort("B2C","S2O");
						}
						else
						{
						exitShortStop = ExitShortStop(0, true, execution.Order.Quantity, RiskS[0], "ATR-S", "S2O");
						}
						//Spreadsheet
						xlLongShort = "Short";
						xlEntryTime = execution.Order.Time;
						xlEntryQty = execution.Order.Quantity;
						xlEntryPrice = execution.Order.AvgFillPrice;
						enterShort = null;
					}
			}
			// Reset our stop order and target orders' IOrder objects after our position is closed.
			if ((exitShortStop != null && exitShortStop == execution.Order))
			{
				if (execution.Order.OrderState == OrderState.Filled && execution.Order.OrderState != OrderState.PartFilled)
				{
					PShort = false;
					//Spreadsheet
					xlExitTime =  execution.Order.Time;
					xlExitQty = execution.Order.Quantity;
					xlExitPrice = execution.Order.AvgFillPrice;
					xlPnL = Math.Round((((xlEntryPrice - xlExitPrice)*xlExitQty)*Instrument.MasterInstrument.PointValue),2);
					xlDollarRisk = Math.Round(((intRisk)*Instrument.MasterInstrument.PointValue),2);
					xlRmultiple = xlPnL/xlDollarRisk;
					UpdateExcel();
					exitShortStop = null;
				}
				if(execution.Order.OrderState == OrderState.Rejected)
				{
					exitShortStop = null;
				}
				if(execution.Order.OrderState == OrderState.Rejected)
				{
					exitShortStop = null;
				}
			}
			
			if(exitShort != null && exitShort == execution.Order)
			{
				if (execution.Order.OrderState == OrderState.Filled && execution.Order.OrderState != OrderState.PartFilled)
				{
					PShort = false;
					//Spreadsheet
					xlExitTime =  execution.Order.Time;
					xlExitQty = execution.Order.Quantity;
					xlExitPrice = execution.Order.AvgFillPrice;
					xlPnL = Math.Round((((xlEntryPrice - xlExitPrice)*xlExitQty)*Instrument.MasterInstrument.PointValue),2);
					xlDollarRisk = Math.Round(((intRisk)*Instrument.MasterInstrument.PointValue),2);
					xlRmultiple = xlPnL/xlDollarRisk;
					UpdateExcel();
					exitShort = null;
					exitShortStop = null;
					
				}
			}
			
			
		}
		
		#endregion
		
		#region SetUpSpreadsheet
		private void SetUpSpreadsheet()
		{
			OpenWorkbook(excelFile);
			excelSheet = (Excel._Worksheet)FindSheet(excelWorkBook, excelSheetName);
			if (excelSheet == null) 
			{
				Alert("openError", NinjaTrader.Cbi.Priority.High, "Error opening spreadsheet - check indicator parameters",
				"Alert1.wav", 10, Color.Black, Color.Yellow);
			}
			try
			{
				
				excelApp.Visible = true;
				excelApp.UserControl = true;
				excelOpen = true;					
			}
				catch
			{
				Alert("Exception formatting Excel", NinjaTrader.Cbi.Priority.High, "Error opening spreadsheet - check indicator parameters",
				"Alert1.wav", 10, Color.Black, Color.Yellow);
			}			

		}
		
		// Return the worksheet with the given name.
		private Excel.Worksheet FindSheet(Excel._Workbook excelWorkBook, string excelSheetName)
		{    
			foreach (Excel.Worksheet excelSheet in excelWorkBook.Sheets)    
			{        
				if (excelSheet.Name == excelSheetName) return excelSheet;   
			}    
			return null;
		}
		
		// Open the workbook
		private void OpenWorkbook(string FileName)
		{

		    try
            {
                excelApp = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
            }
            catch
            {
                excelApp = new Microsoft.Office.Interop.Excel.Application();
            }
			simpleFileName = Path.GetFileName(excelFile);
            try
            {
               excelWorkBook = excelApp.Workbooks.get_Item(simpleFileName);
            }
            catch
            {
                excelWorkBook = (Excel._Workbook) (excelApp.Workbooks.Open(excelFile,
					false, true, Type.Missing,Type.Missing, Type.Missing, Type.Missing,Type.Missing,
					Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing,Type.Missing));
            }
		}
		#endregion

    }
}
I removed my Entry Rules and exit rules, but keep the parts about sending trades to excel.. Keep in mind this is based on Iorder execution rules.

Also, I am sorry about removing a lot of the code, but I really can't share too much. However, if you are experienced in building trade systems than there is plenty information here to get you started building a log that exports to excel.

If you have any questions feel free to ask.

Cheers,

Sody

"The great Traders have always been humbled by the market early on in their careers creating a deep respect for the market. Until one has this respect indelibly engraved in their makeup, the concept of money management and discipline will never be treated seriously."
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 
SodyTexas's Avatar
 SodyTexas 
Austin TX
 
Experience: Advanced
Platform: Ninjatrader, Python, & R
Broker: RJO
Trading: Futures, Spreads
Posts: 421 since Sep 2013
Thanks Given: 117
Thanks Received: 1,085

If there is a lot of interest in this, I can build a generic on based on MA crosses. Let me know.

Sody

"The great Traders have always been humbled by the market early on in their careers creating a deep respect for the market. Until one has this respect indelibly engraved in their makeup, the concept of money management and discipline will never be treated seriously."
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
 fossil 
Germany
 
Experience: Intermediate
Platform: Ninjatrader
Broker: IB and zen-Fire
Trading: NQ
Posts: 92 since Apr 2010
Thanks Given: 8
Thanks Received: 39


Big Mike View Post
The most popular one on nexusfi.com (formerly BMT) is this one:



Check end of thread, it's continually developed.

Mike

Hey Mike thanks

it is a great thread but way to complicated for me. I need somethig easy and stupid you knwo.

Cheers
Axel

Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 fossil 
Germany
 
Experience: Intermediate
Platform: Ninjatrader
Broker: IB and zen-Fire
Trading: NQ
Posts: 92 since Apr 2010
Thanks Given: 8
Thanks Received: 39


SodyTexas View Post
If there is a lot of interest in this, I can build a generic on based on MA crosses. Let me know.

Sody

Thanks!

Started this thread Reply With Quote
  #8 (permalink)
 
DavidHP's Avatar
 DavidHP 
Isla Mujeres, MX
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Ninjatrader / Optimus Futures / AmpFutures
Trading: ES / 6E / 6B / CL
Frequency: Every few days
Duration: Minutes
Posts: 1,609 since Aug 2009
Thanks Given: 11,327
Thanks Received: 2,743


SodyTexas View Post
If there is a lot of interest in this, I can build a generic on based on MA crosses. Let me know.

Sody

Great idea

Thanks

Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on June 14, 2014


© 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