NexusFi: Find Your Edge


Home Menu

 





Strategy + indicator coding - samples / examples


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one mrticks with 7 posts (0 thanks)
    2. looks_two max-td with 7 posts (6 thanks)
    3. looks_3 MXASJ with 3 posts (3 thanks)
    4. looks_4 cclsys with 2 posts (0 thanks)
    1. trending_up 19,608 views
    2. thumb_up 9 thanks given
    3. group 2 followers
    1. forum 19 posts
    2. attach_file 1 attachments




 
Search this Thread

Strategy + indicator coding - samples / examples

  #1 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

hi all,
here is a source with lots of examples how to get to several solutions in indicator + strategy-coding :

Reference Samples - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

hope that helps!

max-td
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Build trailing stop for micro index(s)
Psychology and Money Management
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Futures True Range Report
The Elite Circle
Deepmoney LLM
Elite Quantitative GenAI/LLM
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
43 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #2 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

here some snippets for

StopLoss
ProfitTarget
TrailStop

in strategys

 
Code
                            
    protected override void Initialize()

        {
            
// Submit stop-loss and profit target orders


            
SetStopLoss(CalculationMode.Ticks5);

            
SetProfitTarget(CalculationMode.Ticks10);

           
SetTrailStop(CalculationMode.Ticks40);
            
            
CalculateOnBarClose true;
            

        } 

http://ww25.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetProfitTarget&subid1=20240327-2225-1809-b061-3ed9273f6df0

http://ww25.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetTrailStop&subid1=20240327-2225-18fe-b1c0-b13adf94b713

http://ww25.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetStopLoss&subid1=20240327-2225-198d-b0b8-f603ecb482bd


Attention :
The SetTrailStop() method can NOT be used concurrently with the SetStopLoss() method for the same position, if both methods are called for the same position (fromEntrySignal) the SetStopLoss() will always take precedence. You can however, use both methods in the same strategy if they reference different signal names.

max-td
Started this thread Reply With Quote
Thanked by:
  #3 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927


Also, especialy for beginners, i recommend the NinjaTrader- online-events
to do the first steps into creating strategys with the NT-wizard :

Automated Strategy Developement :

What:
Software Training Session
When: Usually once per week
Online Trading. [AUTOLINK]NINJATRADER[/AUTOLINK]. Online events.
Duration: Approximately 60 mins
Cost: Free to everyone
Develop your strategy concept, construct it, historically test it, optimize it, simulation test it and then live deploy it through your live brokerage account with NinjaTrader’s strategy development tools. This session is designed to provide a high-level overview of the following areas:
  • Create a strategy in the Strategy Wizard
  • Create entry and exit conditions and invoke actions
  • Backtest using the Strategy Analyzer
  • Understand the backtest results
Plan to attend this session if you want to maximize your efficiency in utilizing NinjaTrader for automated strategy development. After completing the Automated Strategy Development Level I training session, you will:
  • Know the process for constructing a strategy using the Strategy Wizard
  • Know how to create entry and exit conditions
  • Know how to backtest a strategy
  • Know how to view the performance results of a backtested strategy
Participation is free so please attend if you are a first-time visitor, new user or an existing user. These sessions are always informative and keep you up-to-date on any enhancements and features we add to our strategy development features.


Online Trading. [AUTOLINK]NINJATRADER[/AUTOLINK]. Online events.

and then start through

max-td
Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 
cclsys's Avatar
 cclsys 
Sydney, NS
 
Experience: Intermediate
Platform: Ninja
Broker: Zen-Fire
Trading: TF,S,GC
Posts: 605 since Nov 2009
Thanks Given: 248
Thanks Received: 393

Max, do you (or anyone else) have a sample strategy that doesn't use fixed tick trailing stops?

Also, how do you keep track of profit/loss within the strategy to perhaps change nr. of contracts, ratio of profit-to-loss etc.?

Also, does anyone have a good example of a multiple entry and exit strategy?

I must confess I have been stumped/frustrated by the brevity and simplicity of the examples provided and also the lack of shared strategies anywhere just to have a basic template with most of the above (and other) options to key off of. If you don't know C+ coding, the error messages are very hard to figure out so I have tended to stay away. But now I want to use strategies to test key ideas even if I don't particularly want to run them for generating income. Working only in indicators is too complicated at this point and really doesn't work for testing purposes.

Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

sorry cclsys, i dont have such stuff.
but if there are other folks out there - feel welcome to post + collect advanced strategy-snippets here also !

max-td
Started this thread Reply With Quote
  #6 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

Here are some videos showing how to start to learn programming / programming a strategy in NT for beginners / learners :

Created by Camtasia Studio 3

Created by Camtasia Studio 3

max-td
Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 
jdella's Avatar
 jdella 
Concord, NH USA
 
Experience: Intermediate
Platform: Ninja trader
Broker: AMP/CQG
Trading: ES
Posts: 182 since Jun 2009
Thanks Given: 140
Thanks Received: 115

Thanks Max, those videos made it look easy . Can the same be done to create indicators?

Reply With Quote
  #8 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

with this condition-stuff that is not possible in the indicator-wizard.
the indi-wizard is more about plotting lines + such things - the visualizations.

max-td
Started this thread Reply With Quote
  #9 (permalink)
 
cclsys's Avatar
 cclsys 
Sydney, NS
 
Experience: Intermediate
Platform: Ninja
Broker: Zen-Fire
Trading: TF,S,GC
Posts: 605 since Nov 2009
Thanks Given: 248
Thanks Received: 393


max-td View Post
Here are some videos showing how to start to learn programming / programming a strategy in NT for beginners / learners :

Created by Camtasia Studio 3

Created by Camtasia Studio 3

Yup, can't wait for high speed. Right now, videos are out of my league!

Visit my NexusFi Trade Journal Reply With Quote
  #10 (permalink)
 
mrticks's Avatar
 mrticks 
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks Given: 16
Thanks Received: 10



max-td View Post
here some snippets for

StopLoss
ProfitTarget
TrailStop

in strategys

 
Code
                            
    protected override void Initialize()

        {
            
// Submit stop-loss and profit target orders


            
SetStopLoss(CalculationMode.Ticks5);

            
SetProfitTarget(CalculationMode.Ticks10);

           
SetTrailStop(CalculationMode.Ticks40);
            
            
CalculateOnBarClose true;
            

        } 
http://ww25.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetProfitTarget&subid1=20240327-2225-1809-b061-3ed9273f6df0

http://ww25.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetTrailStop&subid1=20240327-2225-18fe-b1c0-b13adf94b713

http://ww25.ninjatrader-support.com/HelpGuideV6/helpguide.html?SetStopLoss&subid1=20240327-2225-198d-b0b8-f603ecb482bd

Hi max-td,

Is it possible to use all three in the same strategy? I have put stopLoss, trailStop and profitTarget in some strategies but when I backtest the trail stop doesn't take effect. When I check the entries and exits on the chart it looks like the stop loss is taking effect but the profit target and trail stop are ignored. Does that make sense to you? I'll post my code later on if you'd like to take a look?

Reply With Quote




Last Updated on December 2, 2009


© 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