Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Pivot Value for StopLoss and Profit

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

    Using Pivot Value for StopLoss and Profit

    I initially used the strategy builder to enter a trade when price closes above an indicator value. I am having some issues setting the profit and stop based on values from that same indicator. I am wanting to use the value from camarilla pivot R3 for profit and camarilla S4 for stop loss. I have unlocked the code to try and make the SetProfitTarget() to be CamarillaPivot.R3, but im getting an error. I have copied the code here. I am sure its something silly. Please help!

    `

    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class ESLongS3 : Strategy
    {
    private CamarillaPivots CamarillaPivots1;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "ESLongS3";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    CamarillaPivots1 = CamarillaPivots(Close, PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20);
    SetProfitTarget(CalculationMode.Price, (CamarillaPivots1.R3));
    SetStopLoss(CalculationMode.Price, (CamarillaPivots1.S4));

    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (CrossAbove(Close, CamarillaPivots1.S3, 1))
    {
    EnterLong(1, @"LongS3");
    }

    }
    }
    }



    #2
    Hello charliefoxtrot,

    Welcome to the NinjaTrader forums!

    Unfortunately, in the Strategy Builder Set methods cannot be set to dynamic prices such as series or indicator plot values.
    Instead, use an exit order such as 'Exit long position with a limit order' within the actions 'Do the following' section of the Condition Builder.

    Below is a link to an example.
    Hello support team, I have 2 dataseries, a 1minute to detect the ATR value. Now I would like to set the stoploss and profit target based on the actual ATR Value Example: Stoploss 2xATR Profittarget 3xATR value 1. How can this be done with builder, I have no coding experience 2. Later I would like to have the possibility to


    Or alternatively, unlock the script and you can manually code setting set methods within OnBarUpdate().
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    89 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X