NexusFi: Find Your Edge


Home Menu

 





how to write an indicator that enters a trade


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one trendisyourfriend with 4 posts (8 thanks)
    2. looks_two forrestang with 4 posts (9 thanks)
    3. looks_3 vickisb with 3 posts (0 thanks)
    4. looks_4 sam028 with 3 posts (3 thanks)
      Best Posters
    1. looks_one forrestang with 2.3 thanks per post
    2. looks_two trendisyourfriend with 2 thanks per post
    3. looks_3 sam028 with 1 thanks per post
    4. looks_4 chipwitch with 1 thanks per post
    1. trending_up 4,160 views
    2. thumb_up 22 thanks given
    3. group 5 followers
    1. forum 15 posts
    2. attach_file 1 attachments




 
Search this Thread

how to write an indicator that enters a trade

  #11 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


trendisyourfriend View Post
Did you explore the ATM Strategy Methods ? Everything you have mentionned in your last post can be done within a Ninjascript strategy outside of the indicator environment. The strategy and Add-on environments are the suggested way by Ninjatrader for this type of work.

I'm using indicators and orders methods for things which can hardly be done with something else, like adding custom button on the ChartTrader which have risk management functions, or replicate orders from one machine to one or more Ninja located somewhere else, or hedge positions between different accounts/instruments.
So that's far beyond what an ATM can do.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
 
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
  #12 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047


sam028 View Post
I'm using indicators and orders methods for things which can hardly be done with something else, like adding custom button on the ChartTrader which have risk management functions, or replicate orders from one machine to one or more Ninja located somewhere else, or hedge positions between different accounts/instruments.
So that's far beyond what an ATM can do.

I am new to this, you've obviously been using NT's trade stuffs longer than I have.

But, are you sure you're not confusing the general non-code based, ATM stuff the end user has access to on 'chart trader'... with the ability to use standard NT code to place ATM trades?



I.e.,

Strategy logic is like:
 
Code
if(Close[0] > Open[0])
    EnterLongLimit(int quantity, double limitPrice, string signalName)

ATM logic is like:
 
Code
if(Close[0] > Open[0])
    AtmStrategyCreate(OrderAction action, OrderType orderType, double limitPrice, double stopPrice, TimeInForce timeInForce, string orderId, string strategyTemplateName, string atmStrategyId, Action<Cbi.ErrorCode, string> callback)

Both above actions will place orders into the market. From there, you can do whatever you want w/those orders. Adjust them, cancel them, change them, do something else after filled, access information in other accounts, etc.


In both cases, you accomplish a similar thing, and in both cases you have access to everything in NT's universe... account positions, pnl per trade, all the history of the bars, etc... The primary difference being the ability or ease to manipulate the positions after it is placed.

What would stop you from creating an ATM-based order entry, and still add buttons, hedge, or do whatever else you want to do?

---EDIT----
In thinking about it... one thing I think strategy-logic gives you... is a lot of helper methods/functions created by NT that may make things a bit simpler to create. Using ATM code, I can see how you might need to manually write some of your own helper methods, but I am still wondering what things you CANNOT do w/ATM logic?

E.g., a strategy-logic method is setTrailStop()... to recreate this functionality using ATM-logic, you'd need to write your own trailStop logic, and update your order when necessary.

Reply With Quote
Thanked by:
  #13 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,171
Thanks Received: 6,018



forrestang View Post
---EDIT----
In thinking about it... one thing I think strategy-logic gives you... is a lot of helper methods/functions created by NT that may make things a bit simpler to create. Using ATM code, I can see how you might need to manually write some of your own helper methods, but I am still wondering what things you CANNOT do w/ATM logic?

E.g., a strategy-logic method is setTrailStop()... to recreate this functionality using ATM-logic, you'd need to write your own trailStop logic, and update your order when necessary.

....

That's my understanding too. Usig ATM-logic the user can still move the orders as he wishes manually while still having the script control them just as well which is not the case with the unmanaged/managed approach.

Reply With Quote
Thanked by:
  #14 (permalink)
 vickisb 
Sarasota FL
 
Experience: Intermediate
Platform: Ninja Trader
Trading: ES
Posts: 59 since Feb 2017
Thanks Given: 36
Thanks Received: 22

I don't know enough to know how to use this info. Do you have any templates that I could use to copy and tweak?


sam028 View Post
A very partial skeleton but the main methods are here:

private Account myaccount;
...
Order myOrder = new Order();
myOrder = myaccount.CreateOrder(Instrument, ...);
myccount.Submit(new[] { myOrder });


Started this thread Reply With Quote
  #15 (permalink)
 vickisb 
Sarasota FL
 
Experience: Intermediate
Platform: Ninja Trader
Trading: ES
Posts: 59 since Feb 2017
Thanks Given: 36
Thanks Received: 22

The third-party product I have used to be a strategy, then they reworked it to be an indicator. The advantage I saw right away is that when you manually close the trade you don't have then remember to re-enable the strategy.

I have written strategies that use ATMs. I am interested in a) how to do the same thing within an indicator and b) how to have buttons on the top of the chart to quickly change some of the parameters. Please see the attached screen shot.




trendisyourfriend View Post
Why not use the strategy framework? It is there for this exact reason. With a strategy you can turn it On/Off without reloading your chart.

I have been using these methods with great success and ease.
https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?atmstrategycreate.htm


Started this thread Reply With Quote
  #16 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,171
Thanks Received: 6,018


vickisb View Post
The third-party product I have used to be a strategy, then they reworked it to be an indicator. The advantage I saw right away is that when you manually close the trade you don't have then remember to re-enable the strategy.

I have written strategies that use ATMs. I am interested in a) how to do the same thing within an indicator and b) how to have buttons on the top of the chart to quickly change some of the parameters. Please see the attached screen shot.






I would recommand to ask your question directly on the Ninjatrader forum.

https://forum.ninjatrader.com/forum/ninjatrader-8/indicator-development/1134941-looking-to-add-order-entry-buttons-to-chart-trader

Reply With Quote




Last Updated on June 8, 2022


© 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