Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Regression Channel to Trail Stop, but it's rounding?

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

    Using Regression Channel to Trail Stop, but it's rounding?

    Hello! I'm developing a strategy in Strategy Builder. I plan to unlock the code once I have the logic in place to add customizations, but am working in strategy builder for now since I am new to developing with NinjaScript.

    I'd like to set and trail a stop using the Regression Channel indicator. I often get an error that the order cannot be placed above market, but on instruments with lower values (like CL), I've noticed that the orders are always rounded to a whole value without anything after the decimal. The value is being pulled from the regression channel indicator, does this indicator not pull values beyond a decimal?


    #2
    Thank you for the reply, Brandon. I am using Set methods.

    It's happening specifically on instruments with lower values (like Crude Oil) with stops and if I used the same indicator as a target. It's always a whole number. If the channel is at 86.2, it will set the target to 86.00 which could be on the wrong side of the market.

    If I should be getting specific values from the Regression Channel indicator, I will continue looking for my error.

    Comment


      #3
      Brandon,

      On a new bar, I would like to have the stop loss price recalculated to an indicator and have unlocked the code to work with it further. It appears that the strategy builder included Convert.ToInt32 which is where the rounding is coming from.

      I have a variable for Midprice that I'd like to update on a new bar an have placed the conditions in a set. What method would you suggest in place of Convert.ToInt32 to allow rounding to the hundredths place?

      Midprice = Convert.ToInt32(RegressionChannel1.Middle[0]);

      Comment


        #4
        So better yet, let's say I have a condition to update the "Midprice" variable.

        How can I set the variable to an indicator's value without having it rounded to the whole number? I need to be able to use hundredths places.

        Comment


          #5
          Getting closer... I've defined the Midprice variable to be a double rather than an int + Midprice = RegressionChannel1.Middle[0];
          I think I can work with this.​

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          52 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          43 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          48 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X