Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,279 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    19 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Tim-c, Today, 02:10 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    5 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    51 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Working...
    X