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

double to int ?

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

    double to int ?

    Hello .. I'm exerimenting here.
    I would like to plot a ROC (Rate of change) of a MA, in this case a VMA.
    But I'm geting confounded with data types.
    Not that proficient with C#
    Thanks .. here's the sample code.

    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    double ma = VMA(Close,9,9)[0];
    double myroc = ROC(ma,5) ;
    RocMA.Set(myroc);
    Errors
    The best overloaded method match for 'NinjaTrader.Indicator.Indicator.ROC(int Argument '1': cannot convert from 'double' to 'int'

    Also .. once this indicator is completed.. what would the code look like to refer to it from another indicator/strategy?

    Thanks

    #2
    imported post

    a) try double myroc = ROC((int) ma,5);
    b) something like
    Code:
    myDoubleValue = NameOfYourIndicator(whatever-parameters-your-indicator-has)[0];

    Comment


      #3
      imported post

      Dierk Droth wrote:
      a) try double myroc = ROC((int) ma,5);
      Hi
      That gives 'Cannot implicitly convert type 'Ninjatrade.indicator.ROC' to 'double'

      Comment


        #4
        imported post

        Please try
        Code:
        double myroc = ROC((int) ma,5)[0];

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mgco4you, Today, 09:46 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        3 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        6 views
        0 likes
        Last Post Rapine Heihei  
        Started by f.saeidi, Today, 08:01 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X