NexusFi: Find Your Edge


Home Menu

 





Dynamic Stop Loss


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
wallsteetking
MN
 
Posts: 25 since Feb 2011
Thanks Given: 4
Thanks Received: 0

Hi i am writing a code in nijatrader when I setup the stop loss I can only have a fixed stop loss price for example 10 ticks. However, what I want my stop loss to be is 2 candles prior low. instead of a fixed stop loss.

for example. Ninjatrade enters a Long trade the stop loss should be 2 candles prior low. this way the stop loss can be 5 ticks or 15 ticks. its always changing

Does anyone know how to write that kind of stop loss code in ninjatrader . thank you for your time


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
No book, only a stair: journaling fills where price move …
Cryptocurrency
Building a free browser DOM/SMC simulator - need some ad …
Platforms and Indicators
What we know about Binances $6.3bn hack - BBC News
Cryptocurrency
AI for Traders — Agents, Memory, Tools & Real-Worl …
Elite Quantitative GenAI/LLM
 
  #3 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,216
Thanks Received: 2,090



wallsteetking View Post
Hi i am writing a code in nijatrader when I setup the stop loss I can only have a fixed stop loss price for example 10 ticks. However, what I want my stop loss to be is 2 candles prior low. instead of a fixed stop loss.

for example. Ninjatrade enters a Long trade the stop loss should be 2 candles prior low. this way the stop loss can be 5 ticks or 15 ticks. its always changing

Does anyone know how to write that kind of stop loss code in ninjatrader . thank you for your time

Try this one



if
(Position.MarketPosition == MarketPosition.Long)
{

if enter condition

{

SetStopLoss(CalculationMode.Price, Low[2]);
}
}


Visit my NexusFi Trade Journal Reply With Quote




Last Updated on March 7, 2011


© 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