Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multi time frame stochastics

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

    multi time frame stochastics

    Hi, I'm trying to have a strategy where:
    Step 1: if stochastics D is < 70 in the lower time frame
    && Stochastics K crossabove stochastics D in lower time frame
    && Stochastics K > Stochastics D in longer time frame

    enter long

    I've used the multitimeframe example provided by NT, but it keeps complaining everytime that I try to save that it is missing ) on step 1 above and ; on the other lines. I guess I'm not quite sure where the BarsArray[1] fits in the code below.
    Any help is appreciated.

    Here is my code:
    protected override void Initialize()
    {
    Add(PeriodType.Minute, 1);
    Add(PeriodType.Minute, 5);
    CalculateOnBarClose = true;
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if ((Stochastics(BarsArray[1],3, 8, 3).D[0] < 70)
    && CrossAbove(BarsArray[1],Stochastics(3, 8, 3).K, Stochastics(3, 8, 3).D, 1)
    && (Stochastics(BarsArray[2],3, 8, 3).K[0] > Stochastics(3, 8, 3).D[0]))

    {

    EnterLong(DefaultQuantity, "Long1");
    }

    }

    #2
    Hi John, if you want to supply a custom IDataSeries / bars array to calculate your indicator method on that would always be the first input parameter in the overload, the below snippet is changed to reflect this and should compile fine -

    Code:
    if ((Stochastics(BarsArray[1],3, 8, 3).D[0] < 70)
    && CrossAbove(Stochastics(BarsArray[1], 3, 8, 3).K, Stochastics(BarsArray[1], 3, 8, 3).D, 1)
    && (Stochastics(BarsArray[2] ,3, 8, 3).K[0] > Stochastics(BarsArray[2], 3, 8, 3).D[0]))
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the info Bertrand. I cut and paste that into my code and it compiled good.

      I don't see BarsArray in the UI. Is it possible to use the BarsArray within the UI Wizard or only in the CLI?

      Thanks,
      JR

      Comment


        #4
        Glad to hear John, correct any MultiSeries code will need to be done via custom programming in the editor, unfortunately not an option for the wizard interface (on our suggestion list to look into though).
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks Bertrand.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Aviram Y, Today, 05:29 AM
          0 responses
          1 view
          0 likes
          Last Post Aviram Y  
          Started by quantismo, 04-17-2024, 05:13 PM
          3 responses
          25 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          7 responses
          34 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cls71, Today, 04:45 AM
          0 responses
          6 views
          0 likes
          Last Post cls71
          by cls71
           
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          216 views
          1 like
          Last Post PaulMohn  
          Working...
          X