Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Squeeze Momentum Indicator in Strategy

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

    Using Squeeze Momentum Indicator in Strategy

    Hi All,

    I'm trying to use the Squeeze Momentum Indicator in a strategy, but am having difficulties getting the inputs I want. Simply put, I would like to have the Squeeze On or Squeeze Off conditions made available to a strategy. I first tried using the Strategy builder which got me most of the way there, but did not provide the option for these. I then tried following the SampleBoolSeries example to make these conditions available, but did not have any luck. I could not get the conditions to work correctly or show up as available for the strategy.

    Does anyone have any suggestions on what the simplest way to do this would be? I would have thought this would be inherent in the strategy, but I understand you cannot provide everything. I believe the data for the conditions already exist in the indicator (?), I'm just looking for some pointers on how to access them for a strategy that I can work on.

    Thank you,
    Ray

    #2
    Hello, thanks for the follow up. To expose the squeeze on/off boolean you will need to first make two bool series objects, then set the bool series to the value of "sqzOn" and "sqzOff". I would need to know what exactly you tried to do implementing the idea from SampleBoolSeries, this is the best example we have of doing this.

    Comment


      #3
      Hi Chris,

      Here is what I tried in the Indicator.

      Ray

      public class SqueezeMomentumIndicator : Indicator
      {
      private Series<bool> squeezeOn;​
      ...

      else if(State == State.Configure)
      {
      squeezeOn = new Series<bool>(this);​
      ...

      protected override void OnBarUpdate()
      {​
      If(sqzOn)
      {
      squeezeOn[0] = (true);
      }
      ....

      region Properties
      // Creating public properties that access our internal Series<bool> allows external access to this indicator's Series<bool>

      [Browsable(false)]
      [XmlIgnore]
      public Series<bool> SqueezeOn
      {
      get { return squeezeOn; }
      }​
      Last edited by raysinred; 06-29-2023, 09:26 AM.

      Comment


        #4
        Hi Ray, This looks like it would work, but you should also add an else clause to set the bool series to false:

        if(sqzOn)
        {
        squeezeOn[0] = true;
        }
        ​else
        {
        squeezeOn[0] = false;
        }

        You must also make sure you are exposing these Series as public. See here for an example:

        Comment


          #5
          Ok, I think it was the else statement that I missed. I will add this and try again.

          Do I need the exposedVariable at all?

          Since I did not get this far, how would I then call out this bool in a strategy? Can I use the Strategy builder to call this out?

          Thanks,
          Ray

          Comment


            #6
            Hello, If you are using the Strategy builder, this can only read Plots. You will need to change this concept to add two Plots instead of a series and set the plot value to either 1 when true or 0 when false. The strategy builder will be able to see these plots and you can then compare the indicator to a "Numerical Value" (0 or 1).

            Comment


              #7
              Hi Chris,

              What if I'm not using the strategy builder, and just want to call it out directly in the code within the strategy? How would that work?

              Thanks,
              Ray

              Comment


                #8
                Hi, you would create an object of the indicator and access its public Series<bool> object. E.g. using the SampleBoolSeries:

                Code:
                protected override void OnBarUpdate()
                {
                    bool bearIndication = SampleBoolSeries().BearIndication[0];
                    bool bullIndication = SampleBoolSeries().BullIndication[0];
                }

                Comment


                  #9
                  Excellent, thank you. I will give this a try.

                  Thanks,
                  Ray

                  Comment


                    #10
                    HI
                    i tried to follow and copy of what you did but i get an error. I attached script maybe you can help to figure it out why i get that error?
                    I basically wanted to expose issqueze bool so i can use it in strategy...
                    Click image for larger version

Name:	image.png
Views:	807
Size:	517.7 KB
ID:	1261916

                    Comment


                      #11
                      Hi tkaboris,

                      I cannot see what line your errors are on, but try this for the sqzOn.

                      Ray


                      if(sqzOn)
                      {
                      squeezeOn[0] = true;
                      squeezeOff[0] = false;
                      }

                      else
                      {
                      squeezeOn[0] = false;
                      squeezeOff[0] = true;
                      }​

                      Comment


                        #12
                        hi thanks.
                        So i have added squeezeOff bool too, just like for squeezeOn.
                        However in indicator i now have gray, color for i dotn know what.. its not defined..
                        Click image for larger version  Name:	image.png Views:	0 Size:	8.7 KB ID:	1261963
                        Last edited by tkaboris; 07-27-2023, 07:43 AM.

                        Comment


                          #13
                          Hello tkaboris,

                          I am showing this defined for the IsSqueezes plot in your code.

                          AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Dot, "IsSqueezes");
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by NullPointStrategies, Yesterday, 05:17 AM
                          0 responses
                          65 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