Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 01-06-2017, 12:15 AM   #1
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default Reset StopLoss with ATM

I have not coded a Strategy so I don't know if this is possible.

I am currently using an ATM that was setup using the Custom Strategy Parameters window. I trade the ES (e-mini) futures.

When my Limit Order is executed, both a Target and a Stop Order is initiated. My Target is 8 ticks away from the Entry Price, and my Stop Loss is 10 ticks away.

I would like my system to automatically reposition my Stop Loss to 2 ticks of profit when the ES price is 4 or more ticks profitable. As the market price continues to move in a profitable direction, I would like the Stop Loss to trail the price by 2 ticks until my Target is reached or the price turns and hits my Stop Loss.

Can this be done in the Custom Strategy Parameters window, or will I need to code a Strategy? If the latter, is there sample code that I can use to code this?

Thanks for your help,
Ron
Last edited by ronhb107; 01-06-2017 at 05:39 AM.
ronhb107 is offline  
Reply With Quote
Old 01-06-2017, 08:05 AM   #2
NinjaTrader_EricB
NinjaTrader Customer Service
 
NinjaTrader_EricB's Avatar
 
Join Date: Aug 2014
Location: Denver, CO
Posts: 860
Thanks: 39
Thanked 113 times in 111 posts
Default

Hello ronhb107

Thank you for your post,

This will be possible with an ATM Strategy, I've attached some screen shots of your desired settings.

I set the auto trail to trigger at 6-ticks in profit because I didn't see that specified in your post, but you can change it if needed.

How this will work is after 4 ticks in profit, the initial Stop Loss will move to 2-ticks above entry. From there, at 6 ticks in profit, the stop will trail the market price by 2-ticks until the target or stop are hit.

I've linked below the section of our help guide that covers ATMs.

http://ninjatrader.com/support/helpG...gement_atm.htm

In addition, our ATM 201 webinar covers these in depth, we don't have a recorded version using NinjaTrader 8 on our YouTube channel yet (Help > YouTube) but you can attend a live event if you would like, feel free to ask questions.

http://ninjatrader.com/PlatformTraining


We look forward to assisting further.
Attached Images
File Type: png ATM.PNG (58.2 KB, 3 views)
NinjaTrader_EricB is offline  
Reply With Quote
Old 01-06-2017, 03:40 PM   #3
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default

Hi Eric:

I entered the values for a Trailing Stop (see attached). Then I tested in Playback.

However, when the Stop Loss is adjusted at a 4-tick profit/trigger level (which is set to 2-ticks away from the trigger level), it gets immediately filled at the 2-tick level even tho the ES did not pull back to that level.

Am I doing something wrong?

Thanks,
Ron
Attached Images
File Type: jpg Trailing Stop.jpg (138.3 KB, 2 views)
ronhb107 is offline  
Reply With Quote
Old 01-06-2017, 04:39 PM   #4
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default

Ok, I got it to work by setting the Profit Trigger Plus to zero.

Now, if the market goes against me I will add to my position (doubling down) 4 more contracts.

The system will average the two and place a breakeven marker for 5 contracts close to my second order entry point (using the same ATM Strategy).

When the price reaches the 4-tick profit level, nothing happens (the Stop Loss of 5 contracts does not move).

How can I get the Stop Loss to be adjusted like the first entry? Alternatively, how can I get the profit Target to be adjusted 2-ticks from the averaged breakeven point?

Thanks,
Ron
ronhb107 is offline  
Reply With Quote
Old 01-09-2017, 08:35 AM   #5
NinjaTrader_EricB
NinjaTrader Customer Service
 
NinjaTrader_EricB's Avatar
 
Join Date: Aug 2014
Location: Denver, CO
Posts: 860
Thanks: 39
Thanked 113 times in 111 posts
Default

Thank you for your post,

The reason the stop isn't moving is because in your recent post, you mentioned having changed the profit trigger settings to 0. This is what would have had the stop move when 4 ticks in profit are reached.

I suggest testing out the different values how and how they will affect the stop losses by using the Simulated data feed in the Connection menu. With this feed, you are able to control the trend of the simulated data so you can fully test.

There isn't a method to alter Profit targets via the ATM Strategy settings, though they can be manually modified by clicking and clicking.

I suggest reviewing our ATM 201 webinar, linked below, as it will cover how these items function.

https://www.youtube.com/watch?v=0eXP_-cfR2Q&t=6s
NinjaTrader_EricB is offline  
Reply With Quote
Old 01-09-2017, 10:05 PM   #6
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default

Hi Eric:

I tried various values and it did not make a difference.

Eric set up an ATM that will trigger on 4-ticks from the entry point with a 2-tick trailing stop.

Next, try placing a Long one-contract trade and have this get filled. Next, place another Long 4-contract trade below the first position and have the simulator trend down and hit this position. You now have 5 active contracts at an average price position.

Now, have the simulator trend up and hit 4-ticks above the averaged position.

Do you see the trailing stop adjust once the 4-tick position above the averaged price is touched?

If so, send a pic of your ATM.

Thanks,
Ron
Last edited by ronhb107; 01-09-2017 at 10:09 PM.
ronhb107 is offline  
Reply With Quote
Old 01-10-2017, 11:55 AM   #7
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default

Any luck Eric on the above test?

Ron
ronhb107 is offline  
Reply With Quote
Old 01-10-2017, 11:59 AM   #8
NinjaTrader_EricB
NinjaTrader Customer Service
 
NinjaTrader_EricB's Avatar
 
Join Date: Aug 2014
Location: Denver, CO
Posts: 860
Thanks: 39
Thanked 113 times in 111 posts
Default

Hello ronhb107,

Thank you for you reply,

I will test these items and follow up with my findings.

In the meantime, could you please also let me know if you only see this with Playback or also with the Simulated data feed in use?

Please also post a screen shot of your current settings.

We look forward to assisting further.
NinjaTrader_EricB is offline  
Reply With Quote
Old 01-10-2017, 01:41 PM   #9
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default

Hi Eric:

This occurs in both Playback and Simulated modes.

Attached is a pic of my ATM.

Ron
Attached Images
File Type: jpg ATM problem.jpg (129.1 KB, 6 views)
ronhb107 is offline  
Reply With Quote
Old 01-10-2017, 02:30 PM   #10
NinjaTrader_EricB
NinjaTrader Customer Service
 
NinjaTrader_EricB's Avatar
 
Join Date: Aug 2014
Location: Denver, CO
Posts: 860
Thanks: 39
Thanked 113 times in 111 posts
Default

Hello ronhb107,

Thank you for your post,

When attempting to test this, I notice you mention "Do you see the trailing stop adjust once the 4-tick position above the averaged price is touched?"

To clarify, orders will be filled when they reach the last traded price (by default set to have a Yellow background), not the average entry price (set by default to brown/Sienna background).

If you had been referencing the entry price, then this would be expected for orders not to fill when this is reached..

We look forward to assisting
NinjaTrader_EricB is offline  
Reply With Quote
Old 01-10-2017, 03:45 PM   #11
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default

Hi Eric:

I am not sure we are on the same page.

If both orders are filled and we now have 5 active contracts, NT will display where the breakeven point is on the chart.

I would like the system to reference the breakeven point in a manner similar to an entry point since movement above this point becomes profitable.

Now, if ATM cannot perform this then I should be looking to program this behavior in ninja script. If this is the case, do you have any code that could help me with this if ATM cannot?

Thanks,
Ron
ronhb107 is offline  
Reply With Quote
Old 01-10-2017, 04:40 PM   #12
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 527
Thanks: 36
Thanked 106 times in 101 posts
Default

Hello ronhb107,

I would suggest not having your auto breaken and auto trail stop conflict. In the screen shot uploaded at this post,

http://ninjatrader.com/support/forum...88&postcount=9

From the screen shot above, At 4 ticks in profit your trailing stop will engage and trail the current market price by 2 ticks. However, at 4 ticks in profit your breakeven will be set to 1 above entry. What do you want to happen at 4 ticks in profit; your stop to be 1 tick better than breakeven or trail the market by 2 ticks?

To answer your question about having stop losses adjusted like the first entry, you should not submit new order to an active ATM.

You will want to right click on your SuperDOM>Properties. Change ATM Strategy selection mode to KeepSeelectedAtmStrategyTemplateOnOrderSubmission. Under this selection every time you enter a new position at a new price it will default back to the ATM strategy parameters rather than grouping targets/stops all at one price level.

See ATM Selection Mode section of our Helpguide:
http://ninjatrader.com/support/helpG...ction_mode.htm

I look forward to your reply.
NinjaTrader_AlanP is offline  
Reply With Quote
Old 01-11-2017, 12:56 PM   #13
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default

Eric:

First, I prefer to group the strategies as a continuous series of entries. This way it will adjust the stops and targets for the number of contracts.

My suggestion is that the ATM strategy looks at the Breakeven on every trade until closed. Thus an initial entry would be the same as breakeven, but as other positions are added, the ATM will always refer to the breakeven level, not the new entry level, for determining where the trailing stop is triggered. This is an averaging technique that works well for me.

So either ATM can handle this approach or is modified to allow using breakeven (with a checkbox). If this is not possible, then let's focus on coding a Strategy that will do this.

Thanks,
Ron

PS. see attached pic for revised ATM
Attached Images
File Type: jpg ATM property.jpg (158.3 KB, 3 views)
ronhb107 is offline  
Reply With Quote
Old 01-11-2017, 02:41 PM   #14
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 527
Thanks: 36
Thanked 106 times in 101 posts
Default

Hello ronhb107,

To have the initial entry remain at breakeven, even for contracts scaled in, then you should disregard my previous suggestion about KeepSelectedAtmStrategyTemplateOnOrderSubmission.

Thus, with the setting SelectActiveAtmStrategyOnOrderSubmission, and scaling into a position with the Active ATM selected, once the profit trigger set in your trailing stop is hit, a trailing stop with an order quantity equal to your initial entry order plus additional scaled in orders will be grouped and trail the market.

The breakeven line displayed in the chart has no reference to how the ATM strategy operates, its just visual.

I would suggest testing your ATM using the simulated data feed and a SuperDom to understand its behavior.

Please let us know if you need further assistance.
NinjaTrader_AlanP is offline  
Reply With Quote
Old 01-11-2017, 09:00 PM   #15
ronhb107
Junior Member
 
Join Date: Apr 2016
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default

Hi Alan:

It is apparent that the ATM will not operate as I need if it ignores the Breakeven point.

Therefore, I suggest we concentrate on coding a Strategy that will operate using the Breakeven point.

Can you provide examples that will help me code the Strategy I need?

The requirement is that the coded strategy can be accessed from the ATM Strategy dropdown. I want to manually enter the trade, then have the coded strategy manage the trailing stop. It should show up on the chart.

Thanks,
Ron
Last edited by ronhb107; 01-12-2017 at 06:07 AM.
ronhb107 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reset Variables upon stoploss Stem1 General Development 2 05-10-2014 02:47 PM
Missing ATM strategies after db reset mcatmull Platform Technical Support 1 12-23-2013 12:00 PM
How to reset a stoploss within OnBarUpdate() sburtt Strategy Development 11 05-31-2013 07:23 AM
How do you reset the stoploss price/offset value? ninjamouse Strategy Development 4 01-02-2012 01:26 PM
ATM % stoploss db2009 Platform Technical Support 2 02-24-2009 06:57 PM


All times are GMT -6. The time now is 12:56 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.