Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              574 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              333 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X