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

Programming Ques on multi timeframes

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

    #16
    Originally posted by dukeb View Post
    I guess I do not understand. The highlighted data in my previous post compared with the stoch on the graph that was attached do not match. A diamond on the 20min chart was also place at this time. The stoch was > 25 which would mean it should not have been allowed through the if stmt.
    What am I not understanding? How can the code be correct?
    Regards,
    Duke
    The code is NOT correct.

    When BIP=1, both statements return 16.xxxx and therefore this true.

    Code:
    if ((Stochastics(3, 5, 2).K[0] < 25) && (Stochastics(BarsArray[1],3, 5,2).K[0] < 25 ))
    1 of 2 things will fix it:

    Code:
    if ((Stochastics(BarsArray[0],3, 5, 2).K[0] < 25) && (Stochastics(BarsArray[1],3, 5,2).K[0] < 25 ))



    OR

    Code:
    protectedoverridevoid OnBarUpdate()
    {
    if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
    return;
    if (BarsInProgress==1)
    return;[SIZE=2][FONT=Courier New]
    [/FONT][/SIZE]

    Comment


      #17
      Hi Sledge,
      The reason we want index=0 in this case is because every third bar = an hour bar. At that time we evaluate. Is this correct? If so, then there is no current hour bar to evaluate before the 3 previous 20 min bars. Correct? An hour bar is only passed on the close. If there is no close, nothing is passed to the if statement for evaluation. Correct?
      Duke

      Comment


        #18
        Originally posted by dukeb View Post
        Hi Sledge,
        The reason we want index=0 in this case is because every third bar = an hour bar. At that time we evaluate. Is this correct? If so, then there is no current hour bar to evaluate before the 3 previous 20 min bars. Correct? An hour bar is only passed on the close. If there is no close, nothing is passed to the if statement for evaluation. Correct?
        Duke
        You do get both calls because your every 3rd bar is the 60 min. (BIP==0 and BIP==1).

        In this case, you really don't need any action on the 60 minute bar, which is causing all your confusion.

        I'm not sure in what case there would be no close on a 60 minute bar.

        Comment


          #19
          I guess what I am trying to say is that since I am checking on the close of a bar an hourly bar closes on the close of a 3rd 20 min bar. That being said, there would be no hourly bar that would be closing for the 1st 2 20 min bars. By checking bip==0 we would always be sure to catch the 20 min bar on index=0 and the 60min bar on index=1.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ZeroKuhl, Yesterday, 04:31 PM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by cupir2, Yesterday, 07:44 PM
          2 responses
          17 views
          0 likes
          Last Post cupir2
          by cupir2
           
          Started by tkaboris, Today, 06:27 AM
          3 responses
          11 views
          0 likes
          Last Post tkaboris  
          Started by franatas, Today, 01:53 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cummish, Yesterday, 08:43 PM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X