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

Multipeltimeframe problems

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

    Multipeltimeframe problems

    Hello good morning,
    could somebody help me I think with an easy problem I have?
    Tryed to program a multipel timeframe within the 5 Minutes and 15 Minutes stochastic
    but an error message is comomg up if I try to compile.
    No clue what this means.

    Attached the script, might be somebody can solve this for me, would be nice!

    Thanks

    Andy
    Attached Files

    #2
    Hiepel, what is the error message the comes up? Please make sure that for every ( you have a ) and same for the brackets { and }.

    It looks like the BarsArray stuff you have with the cross above is where the error is coming from. You can't just say BarsArray[1]CrossAbove(...). That would for sure result in an error. If want to check the crossabove on the stochastics for barsarray1, it would look something like this:
    Code:
    if (CrossAbove(Stochastics(BarsArray[1], 3, 5, 3).K, Stochastics(BarsArray[1], 3, 5, 3).D)
    // check the other bars array too
    You also do not need the indexers ([0]) when doing cross above/below comparisons.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Still some error codes??

      Hello Austin,

      thanks for your quick reply. I feeded in the the string like you gave me but if I try to compile the strategy following error messages I still get.

      Line 56 Column 8 and 61
      Line 57 Colum 6 and 57 Method name expected Code CS0149

      Line 56 Column 8
      Line 57 Column 5 No overload for method `Cross Above``takes `2`arguments
      Code CS1501

      Could you have a look? I attached the script for your use.

      Thanks for the great service,

      Andreas
      Attached Files

      Comment


        #4
        Hello Austin,

        resolved one problem and have now only one problem left so far.

        Script is following:

        if (CrossAbove(Stochastics(BarsArray[1],3, 5, 3).K, Stochastics(BarsArray[1], 3, 5, 3).D)&&
        CrossAbove(Stochastics(BarsArray[2], 3, 5, 3).K, Stochastics(BarsArray[2], 3, 5, 3).D)

        Failure code is:

        Line 56 Column 8
        Line 57 Column 5 No overload for method `Cross Above``takes `2`arguments
        Code CS1501

        Could you have a look why this happens?

        Many thanks

        Andreas

        Comment


          #5
          Andreas, the look back period is missing from your CrossAbove statements. Please take a look at the help guide page for CrossAbove to see what I mean - http://www.ninjatrader.com/support/h...crossabove.htm.

          This code should work fine:
          Code:
          if (CrossAbove(Stochastics(BarsArray[1], 3, 5, 3).K, Stochastics(BarsArray[1], 3, 5, 3).D, 1)&&
              CrossAbove(Stochastics(BarsArray[2], 3, 5, 3).K, Stochastics(BarsArray[2], 3, 5, 3).D, 1))
          I have added the value of 1 to each CrossAbove statement so it only looks for the crossover one bar ago.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Script works now!

            Hello Austin.

            thanks for your help. The script syntax is now ok but the logic is not doing the right thing.
            The script is buying on each candel, regardless the defintion I have in the scipt. How can this happen???

            Script is attached.

            Thanks

            Andreas
            Attached Files

            Comment


              #7
              Hi Andreas,

              I would look at your cross lookback parameter, which is currently 0. Lookbacks should be >= 1. Lookback = 1 means the cross occurrs on the bar we're currently evaluating and doesn't work exactly the same as bars ago indexing. A lookback of 7 means check all 7 most recent bars to see if a cross occurred on any of them.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Hi Ryan,
                good morning! Thanks for your reply. I tryed it already with a looback parameter of 1 but I had the same
                results. Looks like there is another bug which is avoiding the script to run the "if" parameters. If I look to the chart and trades, every candel was traded regardless the parameters.Any idea why this is?Greetings Andreas

                Comment


                  #9
                  Looks like you have a semicolon at end of if statements that would be causing this. Remove highlighted ;

                  if (CrossAbove(Stochastics(BarsArray[1],3, 5, 3).K, Stochastics(BarsArray[1], 3, 5, 3).D, 0 )&&v(CrossAbove(Stochastics(BarsArray[2], 3, 5, 3).K, Stochastics(BarsArray[2], 3, 5, 3).D, 0 )&& (Stochastics(BarsArray[1],3, 5, 3).K [0]< 20)));

                  if (CrossBelow(Stochastics(BarsArray[1],3, 5, 3).K, Stochastics(BarsArray[1], 3, 5, 3).D, 0 )&& CrossBelow(Stochastics(BarsArray[2], 3, 5, 3).K, Stochastics(BarsArray[2], 3, 5, 3).D, 0 ));
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Now no trade anymore??

                    Hello Ryan,

                    never thought that the problem is so difficult to solve. The script is now taking no trade anymore after the removal of the semicolon.

                    Script is attached. Thanks for everything do you think we get the script running?

                    Greetings from Germany

                    Andreas
                    Attached Files

                    Comment


                      #11
                      Next, you'll need to simplify and debug the script. Your conditions may be too restrictive and never true. Since you'e checking for crossovers on multiple time frames, start limiting to this to one at a time.

                      Ryan M.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bmartz, 03-12-2024, 06:12 AM
                      4 responses
                      31 views
                      0 likes
                      Last Post bmartz
                      by bmartz
                       
                      Started by Aviram Y, Today, 05:29 AM
                      4 responses
                      11 views
                      0 likes
                      Last Post Aviram Y  
                      Started by algospoke, 04-17-2024, 06:40 PM
                      3 responses
                      28 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by gentlebenthebear, Today, 01:30 AM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by cls71, Today, 04:45 AM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X