NexusFi: Find Your Edge


Home Menu

 





Trailing and Fixed Stop


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
traderseeker
Dusseldorf Germany
 
Posts: 8 since Feb 2014
Thanks Given: 2
Thanks Received: 4

Hello

I am creating a custom strategy that utilizes two orders. The first (Entry A) has a fixed profit target and the second (Entry B) is managed only by the Stop Loss.

When Entry A hits its profit target, then the stop loss for Entry B is moved closer to the price. Specifically it will look like this:

"When Entry A hits profit target, move Entry B Stop Loss to (Entry Price - (Profit Target - Entry Price))."

Example:
Entry Price: 50
Stop Loss: 30
Entry A Target: 60

When Entry A closes at 60, then Entry B Stop loss is then moved to 40.

Currently, this is what I have:

 
Code
If ()
				//Order Entries A & B as well as Order for Initial Stop Loss
                EnterLongStop(DefaultQuantity, TrendPilotPricesLong(EntryPerc, StopPerc, TargetPerc).LongEntry[0], "LongEntryA");
                EnterLongStop(DefaultQuantity, TrendPilotPricesLong(EntryPerc, StopPerc, TargetPerc).LongEntry[0], "LongEntryB");
				SetProfitTarget("LongEntryA",CalculationMode.Price,TargetPriceLong);
				SetProfitTarget("LongEntryB",CalculationMode.Price,StopPriceLong);
As far as I can tell, that should set the initial stop prices for both orders and create the profit target for Entry A.

What I need now is to figure out how to determine if Entry A has closed at the profit target and then tell NinjaTrader to move the Entry B stop to its next price.

My problem:
  • I can not figure out how to tell NinjaTrader to check if Entry A has closed at Profit Target
  • I can not figure out how to tell NinjaTrader to move the Stop Loss for Entry B

Finally, when that happens, the stop loss will need to do one more thing. When an indicator, let's assume SMA, is above the Entry B Stop price, I want the stop order to trail the SMA. I would assume that I would do something like this:

if (SMA > StopPrice + ???)
{
SetStopLoss("LongEntryB",CalculationMode.Price,SMA-???);
}

I would like this to update at every bar.

I assume that I would need to create a variable for "StopPrice".

Naturally, I would like the stop loss to only go up. How do I insure that it does not re-set the stop price to a lower price if the SMA starts going down?

I know that this is a lot in a single post - sorry for that. I just assumed it might be easiest to get all of my questions out at the same time.

I appreciate the help that anyone is able to give.


Reply With Quote

 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks




Last Updated on March 10, 2014


© 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