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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      51 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      275 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X