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 7,326 views
    2. thumb_up 22 thanks given
    3. group 5 followers
    1. forum 15 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 vickisb 
Sarasota FL
 
Experience: Intermediate
Platform: Ninja Trader
Trading: ES
Posts: 83 since Feb 2017
Thanks Given: 45
Thanks Received: 27

I have a 3rd party indicator that auto-trades. I didn't realize you could do that with an indicator instead of a strategy. I'm a hack, but have written both. How would I write an indicator that trades? Is it as simple as putting the commands in an indicator instead of a strategy?

And then how would I put some of the parameters on the screen as buttons, e.g., On/Off, Long, Short, ATM to use, etc, so I can change them on the fly?

If anyone has one I could use as a model, I would appreciate getting my hands on it!

Vicki


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
Wood Mackenzie Drops $200 Oil Forecast -- Airspace Expir …
Prediction Markets & Event Contracts
Post-Summit Scorecard: $36M in May 15 Bets Settle Near-Z …
Prediction Markets & Event Contracts
Iran Fired a Missile at Israel Last Night. The $8M June …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
8 thanks
Darmok and Jalad at Tanagra
1 thanks
  #2 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,758 since Jun 2009
Thanks Given: 3,828
Thanks Received: 4,644


vickisb View Post
I have a 3rd party indicator that auto-trades. I didn't realize you could do that with an indicator instead of a strategy. I'm a hack, but have written both. How would I write an indicator that trades? Is it as simple as putting the commands in an indicator instead of a strategy?

And then how would I put some of the parameters on the screen as buttons, e.g., On/Off, Long, Short, ATM to use, etc, so I can change them on the fly?

If anyone has one I could use as a model, I would appreciate getting my hands on it!

Vicki

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 });


Success requires no deodorant! (Sun Tzu)
Reply With Quote
  #3 (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,581 since Oct 2009
Thanks Given: 4,267
Thanks Received: 6,208


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


Reply With Quote
  #4 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
Legendary Urban Samurai
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,345 since Jun 2010
Thanks Given: 357
Thanks Received: 1,059

I've never tried sticking any of the ATM methods into an indicator? I JUST started playing with the NT provided ATM framework myself a few days ago, so my knowledge is limited.

But, if you want to be able to manipulate orders on the fly, you will want to create orders with the ATM methods as suggested by trendisyourfriend.

I have a similar thing working right now, but I'm still working on it. It simply places and replaces orders in a range. But I have it in a strategy, not an indicator.

Typicaly strategies, do not allow you to manipulate orders after they are placed, its all run internally by the strategy. But orders created via ATM methods allow you to manipulate the orders.


Reply With Quote
  #5 (permalink)
 
chipwitch's Avatar
 chipwitch 
Nashville, TN
 
Experience: Beginner
Platform: NinjaTrader
Broker: NinjaTrader, Continuum Data
Trading: MES for now... baby steps
Posts: 322 since Feb 2022
Thanks Given: 235
Thanks Received: 636


forrestang View Post
I've never tried sticking any of the ATM methods into an indicator? I JUST started playing with the NT provided ATM framework myself a few days ago, so my knowledge is limited.

But, if you want to be able to manipulate orders on the fly, you will want to create orders with the ATM methods as suggested by trendisyourfriend.

I have a similar thing working right now, but I'm still working on it. It simply places and replaces orders in a range. But I have it in a strategy, not an indicator.

Typicaly strategies, do not allow you to manipulate orders after they are placed, its all run internally by the strategy. But orders created via ATM methods allow you to manipulate the orders.

I'm 99% sure you cannot do ATM trades from within a script. You can do what they call "managed" or "unmanaged" trades in a script. You can do a bracket pretty easily with managed trail stops (using the NT method) or stop limits and targets. If you want to change an order, for example, that will be an unmanaged trade and they warn only experienced coders should do these. There's actually a lot to it if you think about it... every order needs to wait for the confirm and then consider that before "closing" a position lest you actually be opening one instead. That sort of thing.


Reply With Quote
Thanked by:
  #6 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
Legendary Urban Samurai
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,345 since Jun 2010
Thanks Given: 357
Thanks Received: 1,059


chipwitch View Post
I'm 99% sure you cannot do ATM trades from within a script. You can do what they call "managed" or "unmanaged" trades in a script. You can do a bracket pretty easily with managed trail stops (using the NT method) or stop limits and targets. If you want to change an order, for example, that will be an unmanaged trade and they warn only experienced coders should do these. There's actually a lot to it if you think about it... every order needs to wait for the confirm and then consider that before "closing" a position lest you actually be opening one instead. That sort of thing.

It depends...

Are you talking about a strategy or an indicator?

Also, it depends on if you are talking about the trades being placed by strategy-logic, or ATM-logic?

The two are different... E.g., the strategy-logic trades, will run trades from bar zero, to the current bar, and places those trades, and create a strategy-position.

ATM-logic trades, do not run on prior bars, and start in real-time... so when using this logic, both the unmanaged and managed methods you typically use, do not apply here. See THIS link and they kind of talk about it here.

I've got one working right now. I'm gonna post a video of it, running on replay data, and show you what I mean.

I just got into this ATM stuff a few days ago. I knew what I wanted TO DO, but I didn't know what it was. I wished someone could have told me to look into the ATM section, would have saved me the several hours spent reading the docs trying to figure it out


Reply With Quote
Thanked by:
  #7 (permalink)
 
chipwitch's Avatar
 chipwitch 
Nashville, TN
 
Experience: Beginner
Platform: NinjaTrader
Broker: NinjaTrader, Continuum Data
Trading: MES for now... baby steps
Posts: 322 since Feb 2022
Thanks Given: 235
Thanks Received: 636


forrestang View Post
It depends...

Are you talking about a strategy or an indicator?

Also, it depends on if you are talking about the trades being placed by strategy-logic, or ATM-logic?

The two are different... E.g., the strategy-logic trades, will run trades from bar zero, to the current bar, and places those trades, and create a strategy-position.

ATM-logic trades, do not run on prior bars, and start in real-time... so when using this logic, both the unmanaged and managed methods you typically use, do not apply here. See THIS link and they kind of talk about it here.

I've got one working right now. I'm gonna post a video of it, running on replay data, and show you what I mean.

I just got into this ATM stuff a few days ago. I knew what I wanted TO DO, but I didn't know what it was. I wished someone could have told me to look into the ATM section, would have saved me the several hours spent reading the docs trying to figure it out

Good to know, thanks! I looked all over for that and couldn't find it!


Reply With Quote
Thanked by:
  #8 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,758 since Jun 2009
Thanks Given: 3,828
Thanks Received: 4,644


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

There are multiple reasons, like having a sexier ChartTrader with a more advanced logic, or having a manual entry which is then managed by a strategy more complex than what an ATM can do.
You can do whatever you want from an indicator, but all is not necessarily supported and documented (but it works).


Success requires no deodorant! (Sun Tzu)
Reply With Quote
  #9 (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,581 since Oct 2009
Thanks Given: 4,267
Thanks Received: 6,208


sam028 View Post
There are multiple reasons, like having a sexier ChartTrader with a more advanced logic, or having a manual entry which is then managed by a strategy more complex than what an ATM can do.
You can do whatever you want from an indicator, but all is not necessarily supported and documented (but it works).

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.


Reply With Quote
  #10 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
Legendary Urban Samurai
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,345 since Jun 2010
Thanks Given: 357
Thanks Received: 1,059


ATM strategies working individually.


Reply With Quote




Last Updated on June 8, 2022


© 2026 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 - Downloads - Top
no new posts