NexusFi: Find Your Edge


Home Menu

 





profit target turns into trailing stop loss


Discussion in NinjaTrader

Updated
    1. trending_up 3,404 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

profit target turns into trailing stop loss

  #1 (permalink)
peaceNlove
Canada
 
Posts: 2 since Aug 2013
Thanks Given: 1
Thanks Received: 0

Hey I am working an an automated strategy and hoping to become an Elite member on this site should the strategy work.

I am wondering if it is possible to write a piece of code that is a profit target like order that turns into a trailing stop should the price of the instrument meet the profit target. What I hope to do with this is maximize the profitability of each position. I have done some back tests and found that sometimes the price continues to fall after the profit target is met and the position is closed.

In other words instead of having the activated profit target close the position, it turns into a trailing stop where the initial profit target number becomes the top of the trailing stop.

Currently I have this code and I hope that its possible to simply switch the profit target line with the described action.

protected override void Initialize()
{
SetStopLoss ("", CalculationMode.Percent, 0, false);
SetProfitTarget ("", CalculationMode.Percent, 0);

CalculateOnBarClose = true;
}

Hope this makes sense, thanks for your time/ patience

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
38 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #3 (permalink)
 dynoweb 
McKinney, TX
 
Experience: Intermediate
Platform: ThinkOrSwim, NinjaTrader
Broker: TD Ameritrade (soon to be Schwab) & NinjaTrader
Trading: The indexes, ES, YM, NQ & RTY
Posts: 171 since Aug 2012
Thanks Given: 216
Thanks Received: 157



peaceNlove View Post
Hey I am working an an automated strategy and hoping to become an Elite member on this site should the strategy work.

I am wondering if it is possible to write a piece of code that is a profit target like order that turns into a trailing stop should the price of the instrument meet the profit target. What I hope to do with this is maximize the profitability of each position. I have done some back tests and found that sometimes the price continues to fall after the profit target is met and the position is closed.

In other words instead of having the activated profit target close the position, it turns into a trailing stop where the initial profit target number becomes the top of the trailing stop.

Currently I have this code and I hope that its possible to simply switch the profit target line with the described action.

protected override void Initialize()
{
SetStopLoss ("", CalculationMode.Percent, 0, false);
SetProfitTarget ("", CalculationMode.Percent, 0);

CalculateOnBarClose = true;
}

Hope this makes sense, thanks for your time/ patience

I'm not sure if I remember the correct combination but I believe that the SetStopLoss and the SetTrailingStop can't be used at the same time and I think that's what you're really wanting to do.

What you can do is to use code to inspect the price, if the target is reached, then change your trailing stop variable value to the target - x ticks (for a long) so it doesn't close immediately when hitting the target. Then on each tick update, check if the price hits the stop and exit your position. You will not be able to do this in the strategy back tester since it only triggers the on bar update at the close of the bar not on each tick, but you'll get a close approximation if your time frame or tick count is low.

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
peaceNlove
Canada
 
Posts: 2 since Aug 2013
Thanks Given: 1
Thanks Received: 0

Great! thanks for your input.

Reply With Quote




Last Updated on August 22, 2013


© 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