Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help using pivots in a strategy

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

    Help using pivots in a strategy

    I’m hoping one of you experienced programmers can help me with this. I’m working with the indicator CMIPivotsDaily_V73 in a strategy and I’m trying to create a user input to substitute for R1, R2, etc. at the appropriate place in the code for an Exit condition, so that I can chose which pivot I want to target from the strategy dialog when I launch it. To a novice coder like me without formal training, it would seem straightforward to create a user defined string variable to use in the substitution, but when I try to compile my code for this I get the CS0117 error: “NinjaTrader.Indicator.CMIPivotsDaily_V73 does not contain a definition for ‘pivot Target’.

    What do I need to do? Here are the relevant code bits:

    #region Variables
    privatestring pivotTarget = @"Pivot"; // Temorary default. Actual input choices: R3, R2, R1, PP, S1, S2, S3

    // Condition set 2 for Long Exit
    if (High[0] >= CMIPivotsDaily_V73(10, false, PlotAlignPD.Left, HLCCalculationMode.CalcFromIntradayData, true, 15).“pivotTarget”[0])
    {
    ExitLong("ExitLongPivot", "EnterLong");
    }

    #region Properties
    [Description("Choices: R3 R2 R1 PP S1 S2 S3")]
    [Category("Parameters")]
    publicstring PivotTarget
    {
    get { return pivotTarget; }
    set { pivotTarget = value; }
    }

    #2
    That won't fly.

    You could try using a switch instead. If your string says R2, then use a code branch that goes CMIPivotsDaily_V73(10, false, PlotAlignPD.Left, HLCCalculationMode.CalcFromIntradayData, true, 15).R2[0].
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I was hoping there'd be a short cut! But ok, good to know that. I'll use switch. Thanks, Josh.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      63 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      35 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      54 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      61 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      48 views
      0 likes
      Last Post CarlTrading  
      Working...
      X