NexusFi: Find Your Edge


Home Menu

 





NinjaScript Coding


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Trader.Jon with 3 posts (0 thanks)
    2. looks_two bnichols with 3 posts (2 thanks)
    3. looks_3 TheWizard with 2 posts (0 thanks)
    4. looks_4 gulabv with 2 posts (2 thanks)
      Best Posters
    1. looks_one MXASJ with 8 thanks per post
    2. looks_two Mindset with 2 thanks per post
    3. looks_3 gulabv with 1 thanks per post
    4. looks_4 bnichols with 0.7 thanks per post
    1. trending_up 8,316 views
    2. thumb_up 16 thanks given
    3. group 11 followers
    1. forum 19 posts
    2. attach_file 1 attachments




 
Search this Thread

NinjaScript Coding

  #11 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800


crazyhorse2393 View Post
Hi,

I'm new to this forum but would like to ask a question that maybe you all could help me with. I've been trading on but mostly off for the last 5 years. I recently got back into it and have been working on a semi-automated strategy with a programmer in Australia. I've been very satisfied with his work and his rates.

Here's the thing. I have no background or skill in programming so I would be starting from 0. Realistically speaking, what would be required in order for me to become a competent but not expert programmer. By that I mean writing code that accomplishes what I am intending. I have a feeling that my current situation makes the most sense when I look at it from a time investment/reward scenario. However, I'd like to know how a person would go from knowing nothing to becoming a comptent programmer. Having read through quite a few threads I get the sense that a few people here have Ph.D.'s in mathematics. What level of math skill is required for intermediate level programming.

Thanks,

Competence is relative. You can probably author enough in Ninja with becoming a .NET jock. That said, the thought processes you will learn by studying programing outside of Ninja will help you with Ninja or any other platform you end up with. I'm new to coding after a 20 year break and far from expert, but you might want to set your self up with a learning plan that addresses both your desire to be better at Ninja/Trading Code and at learning C#/.NET/OOP in general.

A learning plan might look like this for Step One:

Get a copy of this: Amazon.com: Head First C#, 2E: A Learner's Guide to Real-World Programming with Visual C# and .NET (Head First Guides) (9781449380342): Andrew Stellman, Jennifer Greene: Books
Download Visual Studio 2010 Express: Microsoft Express Downloads - Visual Studio Express and SQL Server Express
Check out what free training Microsoft offers here: Development for Beginners | Training, Videos, Tools, Resources, Learning | MSDN

While taking a look at Ninja strategies and indicators as you go along.

If you are still keen and moving foreward after that, consider this: Amazon.com: Head First Object-Oriented Analysis and Design (9780596008673): Brett D. McLaughlin, Gary Pollice, Dave West: Books

Which is for Java but if you got through the first book you should have no trouble reading the code and getting the concepts.

Step Three might be this: Amazon.com: Head First Design Patterns (9780596007126): Elisabeth Freeman, Eric Freeman, Bert Bates, Kathy Sierra: Books or if you are a complete geek this: Amazon.com: Design Patterns: Elements of Reusable Object-Oriented Software (0785342633610): Erich [AUTOLINK]Gamma[/AUTOLINK], Richard Helm, Ralph Johnson, John M. Vlissides: Books . The former is Java, the latter C (and a lot of UML), but again if you get past Step 1 and 2 you will get it.

Somewhere in that process you might consider an upgrade from the free Visual Studio Express version to Visual Studio Professional so you can take advantage of the power of VS to code in Ninja. Some complete hack started a thread on that here:

This website is home to (nearly) two years of collective wisdom, discovery, trial, and error. There is some amazing code here, and some absolute crap (I have some absolute crap posted here still. Sorry guys!). But there are also a lot of people here willing to share and willing to help IF you yourself are willing to put in the time.

Give youself learning targets. If you can get through the excercises in that first book while also playing around with Ninja and learning the basics here by, say, 30 June 2011... you are making good progress.

Anyway, some random thoughts from a complete hack who believes in continuous education .

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #12 (permalink)
mcgene4xpro
Ontario
 
Posts: 3 since Oct 2009
Thanks Given: 1
Thanks Received: 0

I am newbie here and i thank you because you already answered my question..

Thanks again

Reply With Quote
  #13 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291


And now I can cut,paste and amend code to do most of what I want to do.
Download all the indicators you like and then play with the code to understand what does what and how.

I did read a book on C# but really I don't get inheritance and polymorphism, etc. So occasionally it will take me a month to work out why my indicator works but the log gives me an error of an object reference not set to an instance of an object, blah blah.

You have to be analytical and a little anal - A is not the same as a.

The very BEST thing I did - was get a Consultant to code up something that I had always wanted right at the very start which involved all of the core things that I knew I would want eg mouse capture, toolbar buttons, drawing on the chart, etc.

It was expensive but I have never stopped since then and I have been able to amend my prime indicator until it's unrecognisable from it's beginnings. Now I sell the odd indicator myself and provide a no to this forum for free.

So in summary

1. You just have to be reasonably intelligent to learn C#/NS.
2. Use other people's/NT code to learn from.
3. Use msdn reference site for C#.
4. Understand it will take many many hours to get proficient.
5. Enjoy the frustrations - they are part of the learning curve.
6. Ask communities such as this for help when you are bleeding from banging your head against the wall.

Reply With Quote
Thanked by:
  #14 (permalink)
 crazyhorse2393 
Boston Ma USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: EUR/USD
Posts: 5 since Dec 2010
Thanks Given: 1
Thanks Received: 1

Thank-you all for the well thought out replies. I'm going to give it a shot so we'll see how it goes.

Started this thread Reply With Quote
  #15 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184


Mindset View Post
And now

5. Enjoy the frustrations - they are part of the learning curve.
...

6. Ask communities such as this for help when you are bleeding from banging your head against the wall.

Dah ... I enjoy the '''aaahhh''' when the frustration ends .,.. NOT the frustration itself

Bleeding is good ... increases circulation to the brain

Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
  #16 (permalink)
 
bnichols's Avatar
 bnichols 
Dartmouth NS
 
Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker: IB / IQFeed / Kids
Trading: Forex, stocks
Posts: 637 since Feb 2010
Thanks Given: 64
Thanks Received: 460

To expand upon what MXASJ said about NT scripting, for traders who have never programmed (and programmers like me who have never been able to get through a book on programming or sit through a programming course) I found NT's indicator & strategy wizards great for learning trade scripting (Tools > New NinjaScript > [Indicator | Strategy]).

The script editor is a relatively uncomplicated environment for learning C# basics compared, say, to MS Visual Studio, but still implements useful features of a development environment (e.g., Intellisense, auto-error checking, outlining, some auto-formatting) (Tools > Edit NinjaScript > [Indicator | Strategy]). Even the Help function is pretty good.

Once you have some idea how wizards work you can create simple programs that do something useful, allowing you to study indicators and strategies and test your own ideas without worrying too much about the details. Viewing the code generated by the wizard (either from the wizard or the editor) helps you learn about the C# language by example, which as others have pointed out is how some of us learn quickest.

Best of all the application to trading is obvious & immediate, as opposed to wasting time IMO puzzling over esoterica; e.g., learning how to write binary sorts and prime number calculators or similar, worst case in some pseudo programming language.

Once you have some idea about how trading scripts work, and how C# works, you can unlock non-system scripts (make them editable) and have your way with them.

One caveat is that if you create a script in the NT environment, by default it is placed in the [NTPath]/Custom/bin directory along with all active indicators / strategies. When you invoke Compile in the editor all existing scripts are (re)compiled at the same time and you can't move on (i.e., create a new script) until all scripts created to date compile without errors. On the other hand, as others have said, recovering from a snafu is an effective way to learn something about system internals even if dealing with internals can make you prematurely grey

The bottom line is, while NT wizards have their own learning curve it's extremely short compared to becoming a full-blown programmer, and you start writing trade-appropriate programs from the get-go.

Visit my NexusFi Trade Journal Reply With Quote
  #17 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184


bnichols View Post
To expand upon

..about system internals even if dealing with internals can make you prematurely grey .

Or habitually have a bloody head from smacking on the wall ... lol

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
  #18 (permalink)
 
TheWizard's Avatar
 TheWizard 
Houston, TX
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Optimus Futures, AMP, CQG
Trading: 6E
Posts: 1,731 since Jun 2009
Thanks Given: 517
Thanks Received: 4,224

I need help with some coding.. It's done for the most part, but I'm trying to do something I don't know how to code.

When the signal is given for a long, I want to enter at the HIGH of the bar prior to the signal bar.
Or (option #2) Enter at the High + 1 tick of the bar prior to the signal bar.

When the signal is given for a short, I want to enter at the LOW of the bar prior to the signal bar.
Or (option #2) Enter at the Low -1 tick of the bar prior to the signal bar.

I don't know how to code that and the Strategy creation wizard isn't much help. Can anyone help? Something like this:

ex: If long condition met:
EnterLong High[1]; (enter long at the high of the previous bar)

or EnterLong High[1]+1 tick; (or enter long at the high + 1 tick, of the previous bar)

ex: If short condition met:
EnterShort Low[1]; (enter short at the low of the previous bar)
EnterShort Low[1] -1 tick: (or enter short at the low -1 tick, of the previous bar)

Thank you for your consideration and time.

I'll be happy to share the strategy, once I get it working!

After all, it's what you learn AFTER you know it all, that counts!
Attached Thumbnails
Click image for larger version

Name:	Automated example.jpg
Views:	93
Size:	104.2 KB
ID:	152385  
Reply With Quote
  #19 (permalink)
 
gulabv's Avatar
 gulabv 
Dallas, TX
 
Experience: Beginner
Platform: Ninjatrader
Broker: Zen-Fire
Trading: ZN, 6E
Posts: 286 since May 2010
Thanks Given: 161
Thanks Received: 169

@TheWizard,

I do not know how those HybridRenko bars work but assuming the high and low are correct representation of the bar the following code should work for long signal:

EnterLongStop(High[1], "Long Entry")

Code for short signal:

EnterShortStop(Low[1], "Short Entry")


The code above will submit orders for the quantity value setup in your strategy property window.
The first argument in the code above is the price to enter at.
The second argument in the code above is the signal name (change it to whatever you like) to identify the order.

Let me know if that works for you!

Reply With Quote
Thanked by:
  #20 (permalink)
 
TheWizard's Avatar
 TheWizard 
Houston, TX
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Optimus Futures, AMP, CQG
Trading: 6E
Posts: 1,731 since Jun 2009
Thanks Given: 517
Thanks Received: 4,224



gulabv View Post
@TheWizard,

I do not know how those HybridRenko bars work but assuming the high and low are correct representation of the bar the following code should work for long signal:

EnterLongStop(High[1], "Long Entry")

Code for short signal:

EnterShortStop(Low[1], "Short Entry")


The code above will submit orders for the quantity value setup in your strategy property window.
The first argument in the code above is the price to enter at.
The second argument in the code above is the signal name (change it to whatever you like) to identify the order.

Let me know if that works for you!

Thank you. I'll give it a try.

After all, it's what you learn AFTER you know it all, that counts!
Reply With Quote




Last Updated on August 3, 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