Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Doji for a strategy question

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

    #61
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello outsource,

    To clarify, you are looking to add a check for a doji, is this correct? This would be when the close is equal to the open, is this correct?

    You want to add this check to the conditions that Jessica provided an example of, is this correct?

    Try the following:
    Code:
    Print(string.Format("{0} | thickMet: {1}", Time[0], thickMet ));
    if(!thickMet)
    {
        if ( (High[0] > High[1]) && (Low[0] < Low[1]) )
        {
            thickMet = true;
        }
    }
    else
    {
        Print(string.Format("{0} | High[0]: {1} < High[1]: {2} & Low[0]: {3} > Low[1]: {4}", Time[0], High[0], High[1], Low[0], Low[1] ));
        if ( (High[0] < High[1]) && (Low[0] > Low[1]) )
        {
            Print(string.Format("{0} | Close[0]: {1} == Open[0]: {2}");
            [COLOR="Sienna"][B]if (Close[0] == Open[0])
            {[/B][/COLOR]
                EnterLong();
           [COLOR="sienna"][B] }[/B][/COLOR]
        }
    }
    With this, if the thickMet bool is set to true on a previous run of OnBarUpdate, and the high of the current bar is less than the high of the previous bar and the low is greater than the low of the previous bar and close of the current bar is equal to the open of the current bar, then place a buy market order.

    The prints I have added as example of how you can use prints to understand behavior.
    Below is a link to a video that demonstrates this as well.


    As a tip, I recommend that you place each curly brace on its own line so that you can ensure each call is within the action block of the proper branching command (condition set).

    As another small tip, you are requiring that the (High[0] < High[1]) && (Low[0] > Low[1]) be true on two calls in a row. In other words, by requiring the thickMet to be true (which is set to true with the same condition) and by using an else if, this means after thickMet is set to true you have to wait for the next run of OnBarUpdate before the else if will be checked. Thus, that same condition has to be true twice.

    Hi,Chelsea!

    Sorry,didn`t recieve the email with your message.I`ll check what you suggest today and report back.

    Comment


      #62
      Just to clarify,as i noticed something...

      the sequence you`ve provided in this example:

      if(!thickMet)
      {
      if ( (High[0] > High[1]) && (Low[0] < Low[1]) )
      {
      thickMet = true;
      }
      }
      else
      {
      Print(string.Format("{0} | High[0]: {1} < High[1]: {2} & Low[0]: {3} > Low[1]: {4}", Time[0], High[0], High[1], Low[0], Low[1] ));
      if ( (High[0] < High[1]) && (Low[0] > Low[1]) )
      {
      Print(string.Format("{0} | Close[0]: {1} == Open[0]: {2}");
      if (Close[0] == Open[0])
      {
      EnterLong();
      }
      }
      }

      is not possible as an Outside bar cannot become an Inside bar within one current,developing bar.

      Let`s just stick with the Doji for the current bar[0].

      What i`m looking for is that the current developing bar first (for e.g.)wen up the current open,hence Close[0] > Open[0],then few second later it went down - Close[0] < Open[0]...are you with me?Ok,on the third click it went up again - Close[0] > Open[0].This is the place where i want to enter.Am i clear?

      Comment


        #63
        i`ll also chek this one for the third condition:

        if (Close[0] == Open[0])

        I think it might work,if i understand you correctly.That might be what Koganam meant as well.

        Comment


          #64
          Hi outsource,

          Depends on what you want to have happen.

          The if (Close[0] == Open[0]) statement is looking for a doji (where the open is equal to the close).

          Some might consider having any high or low distance not a true doji. If you want to make sure the high and low are also the same as the open and close use: if (High[0] == Low[0]).

          Also I had not attempted to correct the logic, I was trying to show you what the correct syntax looks like with the code suggested in post #56.

          The importance of curly braces when nesting if statements.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #65
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello outsource,

            To clarify, you are looking to add a check for a doji, is this correct? This would be when the close is equal to the open, is this correct?

            You want to add this check to the conditions that Jessica provided an example of, is this correct?

            Try the following:
            Code:
            Print(string.Format("{0} | thickMet: {1}", Time[0], thickMet ));
            if(!thickMet)
            {
                if ( (High[0] > High[1]) && (Low[0] < Low[1]) )
                {
                    thickMet = true;
                }
            }
            else
            {
                Print(string.Format("{0} | High[0]: {1} < High[1]: {2} & Low[0]: {3} > Low[1]: {4}", Time[0], High[0], High[1], Low[0], Low[1] ));
                if ( (High[0] < High[1]) && (Low[0] > Low[1]) )
                {
                    Print(string.Format("{0} | Close[0]: {1} == Open[0]: {2}");
                    [COLOR="Sienna"][B]if (Close[0] == Open[0])
                    {[/B][/COLOR]
                        EnterLong();
                   [COLOR="sienna"][B] }[/B][/COLOR]
                }
            }
            With this, if the thickMet bool is set to true on a previous run of OnBarUpdate, and the high of the current bar is less than the high of the previous bar and the low is greater than the low of the previous bar and close of the current bar is equal to the open of the current bar, then place a buy market order.

            The prints I have added as example of how you can use prints to understand behavior.
            Below is a link to a video that demonstrates this as well.


            As a tip, I recommend that you place each curly brace on its own line so that you can ensure each call is within the action block of the proper branching command (condition set).

            As another small tip, you are requiring that the (High[0] < High[1]) && (Low[0] > Low[1]) be true on two calls in a row. In other words, by requiring the thickMet to be true (which is set to true with the same condition) and by using an else if, this means after thickMet is set to true you have to wait for the next run of OnBarUpdate before the else if will be checked. Thus, that same condition has to be true twice.
            Hi,Chelsea,

            sorry,but this example doesn`t work.

            Comment


              #66
              To be prcecise,this is what i use:

              if(!thickMet)
              {
              if (Close[0] > Open[0])
              {
              thickMet = true;
              }
              }
              else
              {
              if (Close[0] < Open[0])
              {
              if (Close[0] == Open[0])
              {
              EnterLong();
              }
              }
              }

              Comment


                #67
                Hello outsource,

                To reiterate, I was not assisting with logic, I was assisting with syntax.

                Would you like a list of professional NinjaScript consultants that can assist you with the logic you are looking for?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #68
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello outsource,

                  To reiterate, I was not assisting with logic, I was assisting with syntax.

                  Would you like a list of professional NinjaScript consultants that can assist you with the logic you are looking for?
                  Do i need professional consultants for the Close[0] > Open[0] and Close[0] < Open[0] and Close[0] > Open[0] logic???

                  I don`t get it,honestly.

                  Comment


                    #69
                    Hello outsource,

                    In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.

                    As your questions are logic related, this thread will remain open for any community members that would like to assist.

                    You can also contact one of our professional NinjaScript Consultants who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #70
                      Originally posted by outsource View Post
                      Do i need professional consultants for the Close[0] > Open[0] and Close[0] < Open[0] and Close[0] > Open[0] logic???

                      I don`t get it,honestly.
                      No you do not need it for that, but how is that working for you?

                      However, as it is now evident that you are having a pretty hard time trying to do what you actually want to do, you may need that kind of help. Unfortunately, the logic of what you want to do is a tad more complex than the simplistic statements that you are writing. If you really prefer to persist on your own, all I can suggest is that you first write down and figure out the logic of what you want to do, not the mathematics of it. Once you figure out the logic, the rest is just writing pretty standard statements.

                      With only two conditions, it is easy to short-circuit the logic and get passable results: once you go beyond what is essentially a single if ... else construct, you are going to have to have a proper cascade construct.

                      Comment


                        #71
                        Originally posted by koganam View Post
                        No you do not need it for that, but how is that working for you?

                        However, as it is now evident that you are having a pretty hard time trying to do what you actually want to do, you may need that kind of help. Unfortunately, the logic of what you want to do is a tad more complex than the simplistic statements that you are writing. If you really prefer to persist on your own, all I can suggest is that you first write down and figure out the logic of what you want to do, not the mathematics of it. Once you figure out the logic, the rest is just writing pretty standard statements.

                        With only two conditions, it is easy to short-circuit the logic and get passable results: once you go beyond what is essentially a single if ... else construct, you are going to have to have a proper cascade construct.
                        I got it it was complex from your first reply,i thought some workaround was possible.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        656 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        373 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        109 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        574 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        579 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X