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

ToTime[0] and Bollinguer problem

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

    ToTime[0] and Bollinguer problem

    Hello everyone, this indicator works with bollinger it is simple. It powered by CalculateonbarClose = false . I put the code here :


    if(ToTime(Time[0]) > ToTime(14, 30, 00) && ToTime(Time[0]) < ToTime(15, 30, 00))
    {
    if (Close[0] > Bollinger(stddev,period).Upper[0] && Close[1] < Bollinger(stddev,period).Upper[0])
    {

    if(can_llong == true)
    {
    DrawArrowUp(CurrentBar.ToString(), true, 0, GetCurrentAsk(), Color.DodgerBlue);
    can_long = false;
    can_short = true;
    }
    }
    if (Close[0] < Bollinger(stddev,period).Lower[0] && Close[1] > Bollinger(stddev,period).Lower[0])
    {


    if(can_short == true)
    {
    DrawArrowDown(CurrentBar.ToString(), true, 0, GetCurrentBid(), Color.Fuchsia) ;
    can_short = false;
    can_long = true;
    }
    }
    All you have to do is :
    Check that when Time is correct, if it crosses Bollinger puts an arrow and then touch Bollinger but could not go back to an arrow.

    The problem I have found and it is very strange. When I put in 14:30:00 to 22:30:00 works fine. But when I put in 14:30:00 to 15:30:00 NOT WORK ....
    Click image for larger version

Name:	1 CAPPP.jpg
Views:	1
Size:	221.4 KB
ID:	904625
    Click image for larger version

Name:	2 CAPP.jpg
Views:	1
Size:	222.0 KB
ID:	904626
    Here I attached two images


    You know any other way to do the same, but in different ways for this to work properly

    ThankYou very much!

    #2
    Hello fisagol,

    Thanks for your post.

    Can you clarify what instrument and time frame you are using when you apply the code?

    In order to test, please provide your entire code, preferably as an attachment. You can find the source file in Documents>NinjaTrader7>bin>Custom>Indicators>

    If you would rather not post the entire code in public, please feel free to send in to PlatformSupport[at]Ninjatrader[dot]Com with a link to this thread in the subject line and Atten:Paul
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      The instrument that I test fails randomly and as I said before is the FDAX and CL , the timeframe is 5min

      And the indicator is this: BollingerNew.cs

      Really do not understand because it fails because the functionality is correct , besides the error it is very strange given that only occurs in certain time periods

      If you prefer you can say exactly when the indicator fails it can check with the Market Replay
      Last edited by fisagol; 01-20-2016, 01:18 PM.

      Comment


        #4
        Hello fisagol,

        Thanks for your reply.

        I added your indicator and the bollinger (set to your settings) to a 5 minute chart of the CL 03-16 as well as a chart of the FDAX 03-16. I modified your indicator to only operate between 14:30 and 15:30.

        I've attached the CL chart and as you can see your indicator does display on the chart but is limited by the end of session time (15:00 in my time zone).

        The indicator on the instrument FDAX does not display because, in my time zone, the hours of 14:30 to 15:30 are not when the FDAX trades.

        So you might look at the session times for these contracts to understand why the indicator does not operate or does not completely operate as you expect.
        Attached Files
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Perfect serve the same example, ( I speak from now on your schedule ) in the CL you have proven limited time from 14:30 to 15:00. Test it to make now 14:30-17:00 or 14:30-20:00 in the same day at 20/1/2016 and you'll see the arrow mysteriously no longer appears. that's the mistake I 'd say, is very strange.

          Comment


            #6
            Hello fisagol,

            Thanks for your reply.

            The reason that the arrow disappears has to do with the logic of your code as regards to the logic states of puclong and pucshort. When the code is run the first time everything is initialized correctly but when you reload the data the logic states of puclong and pucshort remain as they currently are and would not be reinitialized, so subsequent runs with your alternating logic would effectively appear to move the arrows.

            To resolve, what I recommend is to add as the first line under OnBarUpdate() is:

            if (CurrentBar == 0)
            {
            puclong = true;
            pucshort = true;
            }

            This way when ever you reload or the data is reloaded, it will started from the same logic state on the first bar loaded. This should keep the arrows from disappearing under subsequent runs.

            I did not evaluate your code for correct functionality of when it places the arrows as this is up to you and your conditional logic.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I change this and I put in code that you say me but the error persist. Randomly , depending on what time of completion set , the arrow is shown or not shown.

              For all testings I've done, it seems that at some time put the bool x = not detected and ignored, as if it is no longer initialized . I do not understand that it may fail
              Last edited by fisagol; 01-21-2016, 12:56 PM.

              Comment


                #8
                I initialized with another bool true value when you first enter the OnBarUpdate put everything true . But I put a snitch and still not within the if. Deputy code

                BollingerNew.cs

                Comment


                  #9
                  Hello fisagol,

                  Thanks for your reply.

                  What I recommend is that you begin following the debugging path that uses print statements in your code so that you understand what code is being executed and when. The print statments send their output to the output window (Tools>output window) This is the only way to resolve the code issue. If you remove all of them and just leave price/bollinger checks and the draw arrow statements you will see that the arrows are drawn.

                  We have provided some helpful debug tips in this reference: http://ninjatrader.com/support/forum...ead.php?t=3418
                  Paul H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by AveryFlynn, Today, 04:57 AM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Started by Max238, Today, 01:28 AM
                  4 responses
                  37 views
                  0 likes
                  Last Post Max238
                  by Max238
                   
                  Started by r68cervera, Today, 05:29 AM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by geddyisodin, Today, 05:20 AM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by timko, Today, 06:45 AM
                  2 responses
                  14 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Working...
                  X