NEED HELP TO WRITE MY FIRST STRATEGY - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

Started:March 29th, 2013 (07:15 AM) by benwincky Views / Replies:334 / 2
Last Reply:April 2nd, 2013 (01:24 AM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread


Old March 29th, 2013, 07:15 AM   #1 (permalink)
Brussels Belgium
Futures Experience: Beginner
Platform: Ninjatrader
Favorite Futures: Forex
Posts: 14 since Mar 2013
Thanks: 5 given, 0 received


Hello to you

I can manipulate my edit script by now

But I'm nowhere, let's be honnest. There are so many commands that you would save me time indicating me whitch set of command I could Start with for my first «own scrpit*»

I read a lot in the forum but didn't find what I want or maybe came accross without noticing that was the command Iwas looking for.

I will give and example I think this is the best way

I intend working this way

protected override void Initialize()

CalculateOnBarClose = False;

I'm not interested in bars closed though I know it is CPU intensive

I have the EURJPY a 120,55

I will write this example for a long entry but the logic would be the same if I would go short

As I enable my strategy, I want this 120,55 value stored in a «*double*» variable

(This is my first problem, I have been unable to find a way for doing so)

Let's say The EURJPY moves up 1 pip up to 120,56

At time I want to start a stop watch to 0 second

First case

The EURJPY moves up 4 more pips to 120,60 within 3 seconds, I would enter long

Second Case

3 seconds have elapsed and the EURJPY moved up to 120,59

It didn't fill my condtions to enter long and the stop watch resets to Zero

Third Case

The EURJPY went up to 120,58 and then back down to 120,57. Well, it didn't fill my conditions either


It might be a new begining of a short entry process

I went down one pip, didn't he*?

I now want the 120,58 stored in my double Variable and restart a stop wath to Zero

And If the EURJPY moved down within 3 second I enter Short.


1. How to I do To get the Actual Value of the EURJPY in a variable as I start my strategy.
2. How do I start a stop watch

Thanks in advance


Reply With Quote

Old March 29th, 2013, 07:15 AM   #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.


Old April 2nd, 2013, 01:24 AM   #3 (permalink)
Elite Member
Futures Experience: None
Platform: None Yet
Favorite Futures: Guitar
MrYou's Avatar
Posts: 402 since Jun 2011
Thanks: 611 given, 192 received

My suggestion is to forget about this "stop watch" stuff. You need to understand how charts and NinjaScript work. I can't explain it all, but below is some simple code.

Add() a 3 second chart or base your primary bars (BarsInProgress == 0) off the 3 second chart.

CalculateOnBarClose = true;

if (BarsInProgress == 0)
   if (Close[0] - Open[0] > TickSize * 3)
OR for Multi-Timeframe: Add(PeriodType.Second, 3)

if (Closes[1][0] - Opens[1][0] > TickSize * 3)

Reply With Quote
The following user says Thank You to MrYou for this post:

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > NEED HELP TO WRITE MY FIRST STRATEGY

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the best way to write a NT strategy with the wizard? mkaminski NinjaTrader 2 October 21st, 2012 12:43 PM
Need Programmer to Write Ninja Strategy hcoffin1941 NinjaTrader Programming 28 November 21st, 2011 08:44 AM
Italy-Pregnant BlackRock Sees Write-Downs Of 75-80% For Greece, Portugal And Ireland Quick Summary News and Current Events 0 November 14th, 2011 11:30 AM
How do I write a trading plan? skyfly Traders Hideout 5 May 20th, 2011 01:13 AM
How do I write the script for kaywai NinjaTrader Programming 1 January 19th, 2010 10:06 AM

All times are GMT -4. The time now is 09:38 PM.

Copyright © 2016 by 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 2016-10-24 in 0.08 seconds with 19 queries on phoenix via your IP