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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X