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

How to put Price Type Captured as user input into EMA?

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

    How to put Price Type Captured as user input into EMA?

    Howdy. I am trying to add a a PriceType that the user inputs into the User Input upon adding the indicator. In the study, I am creating, there are two different MAs, that I would like to assign different price types to.

    So I initialize the price type to close via:
    Code:
            #region Variables
    
    			private PriceType myPriceType1 = PriceType.Close;
    			private PriceType myPriceType2 = PriceType.Close;		
    
            #endregion


    Then say I have something like:
    Code:
            protected override void OnBarUpdate()
            {
    
    					MAFast.Set(EMA(periodFast)[0]); 
    
    					MASlow.Set(EMA(periodSlow)[0]);
    	
            }

    And in the Properties, I am capturing the user input via:
    Code:
    	[Description("Price Type for Fast MA")]
    	[Gui.Design.DisplayName("1.)Fast MA Type")]
            [Category("Parameters")]
            public PriceType MyPriceType1
            {
                get { return myPriceType1; }
                set { myPriceType1 = value; }
            }	
    
    	[Description("Price Type for Slow MA")]
    	[Gui.Design.DisplayName("2.)Slow MA Type")]
            [Category("Parameters")]
            public PriceType MyPriceType2
            {
                get { return myPriceType2; }
                set { myPriceType2 = value; }
            }


    What I want to do, is simply put that variable captured as a user input, into the portion on onBarUpdate() Like so:
    Code:
    MAFast.Set(EMA([COLOR="Magenta"]myPriceType2[/COLOR], periodFast)[0]);

    But this doesn't work. How would I take the variable for the price type the user inputs and put it in there?

    #2
    Originally posted by forrestang View Post
    Howdy. I am trying to add a a PriceType that the user inputs into the User Input upon adding the indicator. In the study, I am creating, there are two different MAs, that I would like to assign different price types to.

    So I initialize the price type to close via:
    Code:
            #region Variables
    
                private PriceType myPriceType1 = PriceType.Close;
                private PriceType myPriceType2 = PriceType.Close;        
    
            #endregion
    Then say I have something like:
    Code:
            protected override void OnBarUpdate()
            {
    
                        MAFast.Set(EMA(periodFast)[0]); 
    
                        MASlow.Set(EMA(periodSlow)[0]);
        
            }
    And in the Properties, I am capturing the user input via:
    Code:
        [Description("Price Type for Fast MA")]
        [Gui.Design.DisplayName("1.)Fast MA Type")]
            [Category("Parameters")]
            public PriceType MyPriceType1
            {
                get { return myPriceType1; }
                set { myPriceType1 = value; }
            }    
    
        [Description("Price Type for Slow MA")]
        [Gui.Design.DisplayName("2.)Slow MA Type")]
            [Category("Parameters")]
            public PriceType MyPriceType2
            {
                get { return myPriceType2; }
                set { myPriceType2 = value; }
            }
    What I want to do, is simply put that variable captured as a user input, into the portion on onBarUpdate() Like so:
    Code:
    MAFast.Set(EMA([COLOR=Magenta]myPriceType2[/COLOR], periodFast)[0]);
    But this doesn't work. How would I take the variable for the price type the user inputs and put it in there?
    You need a conversion conditional statement for each of your Set statements, that reads the input, then sets the plot using the correct DataSeries.

    e.g.,
    Code:
    if (this.MyPriceType2 == PriceType.High) MAFast.Set(EMA(High, periodFast)[0]);
    etc

    Comment


      #3
      Hello,

      Thanks for the forum post.

      This actually most be defined before the strategy starts, therefor you would be unable to have a user select this unfortunately or have different price types for different referenced indicators as well would not be supported.

      Only option is to base of close and then use your own method to come up with the other PriceType off that input data and create it yourself and use that as a feed.

      Let me know if I can be of further assistance.

      Comment


        #4
        Thanks fellas.

        Using the conditions in there worked. It was quite a few of them though, as I was already using an enum for something else.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jonker, 04-27-2024, 01:19 PM
        3 responses
        22 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by businessman1929, 04-29-2024, 01:28 PM
        2 responses
        21 views
        0 likes
        Last Post businessman1929  
        Started by bltdavid, 03-27-2023, 05:32 AM
        18 responses
        347 views
        0 likes
        Last Post ETFVoyageur  
        Started by NM_eFe, Today, 05:15 PM
        0 responses
        5 views
        0 likes
        Last Post NM_eFe
        by NM_eFe
         
        Started by vitaly_p, Today, 05:09 PM
        0 responses
        4 views
        0 likes
        Last Post vitaly_p  
        Working...
        X