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

  #1 (permalink)
 vickisb 
Sarasota FL
 
Experience: Intermediate
Platform: Ninja Trader
Trading: ES
Posts: 59 since Feb 2017
Thanks Given: 36
Thanks Received: 22

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?
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
ZombieSqueeze
Platforms and Indicators
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
41 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)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


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)
Follow me on Twitter 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,527 since Oct 2009
Thanks Given: 4,171
Thanks Received: 6,018


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
 
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

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: 230
Thanks Received: 631


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
 
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


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: 230
Thanks Received: 631


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,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


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)
Follow me on Twitter 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,527 since Oct 2009
Thanks Given: 4,171
Thanks Received: 6,018


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
 
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


ATM strategies working individually.


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