Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using indicator in a strategy

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

    Using indicator in a strategy

    Hi

    I have a bespoke indicator that, in theory, produces a signal that I can then utilise within a strategy.

    In my indicator I have the following code to create the signal:
    ************************************
    //produces an external signal we can use
    private double _percentageMove = 0; //member variable

    This then gets a values assigned to it :
    _percentageMove = b2t; // value to be sent to external strategy

    Where b2t equals a double value eg 23.9, 1.235 etc

    I have a Property created :
    public double PercentageMove
    {
    get { Update();
    return _percentageMove; }
    }

    *************************************************
    and in the strategy I have some very simple code to print the value out

    double bp = Elliot3rdWaveV1005(20,5,10000,20,0,0,0,0).Percenta geMove;
    if(bp > 0)
    Print("BP = " + bp + " | | " + Time[0]);
    else
    Print(" BP = " + bp + " | | " + Time[0]);

    However the only value I get is zero.

    It is as though the indicator is not running and therefore the value never changes, but I can see the indicator behaving as it should.

    Any help or thoughts to what I am missing is appreciated as always...

    #2
    Hello,

    Thank you for the post.

    From this example I can see that you are setting the private variable rather than the public property, could you try changing the following:

    Code:
    _percentageMove = b2t;
    to

    Code:
    PercentageMove = b2t;

    Also, this may depend if you are calling the indicator its self from OnBarUpdate or not. Are you currently only calling this public property or do you have any other usages?

    You could try adding a dummy call like the following to ensure the hosted indicator gets called historically:

    Code:
    double myDummy = MyIndicatorName()[0];
    double percent = MyIndicatorName().PercentageMove;
    this would ensure OnBarUpdate is called to assign the value.

    We have a comment about this in kind of an odd spot in the helpguide as it relates to adding Indicators from Strategies as well: http://ninjatrader.com/support/helpG...ightsub=hosted

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    58 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    34 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    195 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    359 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    281 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X