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

Simple thing: Switch expression

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

    Simple thing: Switch expression

    Hi all, i want to use the Switch expresion to change Price types: Close, Median, Open etc.

    ive seen how to switch period types:

    switch(myPtype)
    {
    case TimeframeType.Week:
    Add(PeriodType.Week, mayorTimeframePeriods);
    break;

    case TimeframeType.Day:
    Add(PeriodType.Day, mayorTimeframePeriods);
    break;

    }

    but i don't know how to implement a price type switcher, since i haven't seen any examples on it.

    Any help will be appreciated, Thanks in advance

    #2
    Kabott,

    Thank you for your post.

    You can use the enum PriceType for your switch case.
    Code:
    switch(PriceType)
    	{
    		case PriceType.Open:
    			Add(PeriodType.Minute, 5);
    			break;
    		default : 
    			Add(PeriodType.Minute, 3);
    			break;
    	}
    http://www.ninjatrader.com/support/h...?pricetype.htm

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hey cal, thanks for the quick answer, is there a way to have them separatedly? meaning, a switch for the Price Type and an other one for the Price Type? that's what im trying to do, thanks again Cal

      Comment


        #4
        Kabott,

        Not sure I'm following along, are you wanting a switch in a switch?

        Could you elaborate more here?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Well, i wanna switch between average types and price types, for example i wanna be able to select
          which average type : EMA, TEMA, etc..
          and on which price type should be that average applied, meaning on close, on medians, on typical etc

          Parameter 1= Select Average Type (EMA, TEMA, SMA, etc)
          Parameter 2= Select Price Type (Open, Close, Low, High, etc)

          so, basically i wanna experiment with many averages and piloting variations so i wanna make a slingshot (2 ma indicator) to find the best combinations

          Comment


            #6
            Kabott,

            Take a look at the Moving Average Cross Builder link below -
            http://www.ninjatrader.com/support/f...atid=4&lpage=7

            This will show you how to create an enum that you can then use to determine which Moving Average is being used like SMA, EMA, so forth.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Thank you very much Cal, i found an example and i have mine running already XD
              but ive never seen that indicator, im guessing i may learn a lot from it!

              Thanks again Cal!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by judysamnt7, 03-13-2023, 09:11 AM
              4 responses
              59 views
              0 likes
              Last Post DynamicTest  
              Started by ScottWalsh, Today, 06:52 PM
              4 responses
              36 views
              0 likes
              Last Post ScottWalsh  
              Started by olisav57, Today, 07:39 PM
              0 responses
              7 views
              0 likes
              Last Post olisav57  
              Started by trilliantrader, Today, 03:01 PM
              2 responses
              21 views
              0 likes
              Last Post helpwanted  
              Started by cre8able, Today, 07:24 PM
              0 responses
              10 views
              0 likes
              Last Post cre8able  
              Working...
              X