Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ProfitTarget as difference between entry price and indicator value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ProfitTarget as difference between entry price and indicator value

    Hi,

    I'm working on coding a strategy and having trouble with the profit target. Also couldn't find any similar threads.

    I'll use a made up up scenario for the sake of explaining. Let's say we enter a short trade when NQ is at 13,500.00 and the EMA is currently at 13,400.00. That would be a 400 tick difference.

    How would I code such a scenario where I want to use that amount as the profit target or set the profit target as entry price minus indicator value like the example above? Or even a multiple like....1.5 times the difference between entry price and current EMA value like Entry(13,500) - EMA (13,400) = 400 ticks*1.5= 600tick profit target.

    Thanks for any guidance. I've been trying to code this the following way to no avail....

    SetProfitTarget(CalculationMode.Ticks, (Position.AveragePrice-EMA[0]*1.5);

    #2
    Hello Deep_ITM_Puts,

    With Set methods, use CalculationMode.Price to set the order to a specific price and not to a distance in ticks.
    https://ninjatrader.com/support/help...ofittarget.htm

    Use a different variable name than EMA as this is already used for the EMA indicator and causes ambiguity.

    private EMA myEMA;

    myEMA = EMA(13);

    Print out 'Position.AveragePrice - myEMA[0] * 1.5' to see if this is the value you are looking for.
    Code:
    if (Position.MarketPosition != MarketPosition.Flat)
    {
    Print(string.Format("{0} | Position.AveragePrice: {1} - myEMA[0]: {2} * 1.5 = {3}", Time[0], Position.AveragePrice, myEMA[0], (Position.AveragePrice - myEMA[0] * 1.5)));
    }
    https://ninjatrader.com/support/foru...121#post791121

    Reset set methods before placing a new entry by calling the set method with a number of ticks, as these cannot be unset.

    Below is a link to an example ProfitChaseStopTrailSetMethodsExample_NT8 which demonstrates.
    https://ninjatrader.com/support/foru...269#post802269

    I am also including a link to a forum post with helpful resources on getting started with C# and NinjaScript.
    https://ninjatrader.com/support/foru...040#post786040
    Last edited by NinjaTrader_ChelseaB; 05-05-2022, 03:46 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    64 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    139 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X