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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    58 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
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X