Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to modify an indicator variable from a strategy file

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

    How to modify an indicator variable from a strategy file

    As the title suggests, I am trying to modify an indicator public variable from my strategy file to make the indicator change it's behavior slightly, but it does not allow me to do anything without a reference error.

    When I try assigning a public variable of my indicator, it says "Object reference not set to instance of an object". I have tried making the variables ninja script properties, making a wrapper and using get / set method around a private variable, and just declaring the class variables themselves as public but none seem to be working because of the object reference error. I am working with simple boolean value variables.

    Indicator has code like:
    public class PriceActionTrend : Indicator
    {

    public bool LookingForOneMinBos = true;
    ...
    }


    Strategy Code:
    Declared in class:
    private PriceActionTrend OverallTrend;

    ​In State.Configure:
    OverallTrend = PriceActionTrend(60, false, 20, 2, 10);

    In OnBarUpdate:
    OverallTrend.LookingForOneMinBos = false; // THIS does not work, get error.

    #2
    Ah man, so I'm not 100% sure how it got fixed, but after I tried enabling debug mode and using visual studio debugger live and stepping through, it just didn't crash anymore when I tried to assign the variable values directly (OverallTrend.LookingForOneMinBos = false - this now works in my strategy file.

    In my indicator the variables are still just public variables of the class as I outlined in my original post. They are NOT ninjascript property variables. I do have a multi-timeframe strategy but that seems to have nothing to do with how it is suddenly working, very weird. My indicator is still being created the same way in Configure state and I use AddChartIndicator, as I always had.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    133 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 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
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X