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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 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