Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing OCHL from where?

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

    Referencing OCHL from where?

    Learning: I would like to make a simple strategy, e.g. when (x) bars (DelayBars) have elapsed from the SessionOpen (Pacific Time 21:00:00), if Price is (x) ticks higher (LongTicks) than the SessionOpen, go long, and if Price is (x) ticks lower (ShortTicks) than the SessionOpen, go short.

    Do I use the DataSeries?

    Conditions: ToTime(Time[DelayBars])>= ToTime(21,0,0)
    Close[0] == DefaultInput(int)(Open[0] + LongTicks*TickSize

    etc. for short.

    Thank you.

    #2
    Hello rcollen,

    Thank you for your post.

    You could do it this way instead:
    Code:
    if(Bars.BarsSinceSession >= DelayBars
    && Close[0] < CurrentDayOHL().CurrentOpen[0] - ShortTicks)
    {
    // place your short order(s)
    }


    Please let me know if I may be of further assistance.

    Comment


      #3
      PatrickH,

      Yes. I see. Thank you very much.

      If I were to call this trade "FirstTrade" and make either the long or short execution of this trade the only FirstTrade type per session, how would I code this restriction? Moving further into the day with this strategy, I would want other conditions to determine more different types of trades.

      Thanks

      Comment


        #4
        Hello rcollen,

        Thank you for your response.

        Create a bool that must be false to check the condition, once the first order is submitted - set the bool to true. You can then check for the bool as true in any other conditions.

        Comment


          #5
          Thank you. I understand your concept, but I cannot find the appropriate variables in the Strategy Wizard to do this. A little more help please.

          Comment


            #6
            Hello rcollen,

            Thank you for your response.

            I have created a video on this item, you can view this video at the following link: http://screencast.com/t/JSRFdKa3s

            Comment


              #7
              PatrickH,

              WOW! Magnificient! My hat's off to NT Customer Service !!!!!! Thank you. Will this screencast remain available to me for a while?

              Comment


                #8
                Yes, this will remain for some time. It is based on storage limit, but this is the most recent video so it will not be removed for some time.

                Comment


                  #9
                  Patrick - As I said, I am learning here. I tried your suggestions and have attached a screenshot of the code. I am getting the Error Message CS1955 and cannot figure out what is happening.
                  Attached Files

                  Comment


                    #10
                    Hello rcollen,

                    Thank you for your response.

                    Bars.BarsSinceSession is called without parenthesis. So Bars.BarsSinceSession() is not correct, change this to Bars.BarsSinceSession.

                    You can find details on Bars.BarsSinceSession at the following link: http://www.ninjatrader.com/support/h...ncesession.htm

                    Please let me know if you have any questions.

                    Comment


                      #11
                      PatrickH - Thank you very much for your help here. I think that I have coded properly (attached) and the strategy did compile correctly. I expect the strategy to take one trade each day after a minimum of 6 bars has elapsed from the opening of each daily session (9:00 PM PST). Either enter long if price is 20 ticks above the opening price, or enter short if price is 20 ticks below the opening price. I have coded the StopOut to be at $-200 and the profit target to be at $+1000. The strategy analyzer does not show that this is occurring. What did I do wrong?
                      Attached Files

                      Comment


                        #12
                        Hello rcollen,

                        Thank you for your response.

                        Instead of if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= -200), use if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) <= -200).

                        Comment


                          #13
                          PatrickH - I am making great progress on this with your assist. Thank you. I have all the important content understood.

                          Please look at the attached screenshot. I am not sure where the single remaining syntax problem comes from.
                          Attached Files

                          Comment


                            #14
                            This must be a simple syntax issue, but I have tried many solutions, and nothing works. I am using OnBarUpdate Method, and not Initialize. Is that the problem?
                            Please look at the attached .cs file. I cannot compile it.
                            Attached Files

                            Comment


                              #15
                              Hello,

                              Thank you for the question.

                              I will be attaching the corrected file to this post, but I would also like to tell you what was causing the errors.

                              First, the most major error that will prevent you from seeing any other errors is the structure of the file. You are missing a closing brace at the end of OnBarUpdate, so we need to add a } to close OnBarUpdate. This will correct the overall structure, if you were to compile there would still be additional errors.


                              Next you have multiple conditions which are not valid syntax currently, there are a few errors here possibly from copying and pasting, I will explain:

                              First the statements that include Position.MarketPosition are invalid as you have not compared against MarketPosition, currently the statements are:

                              Code:
                              Position.MarketPosition == [B]Position[/B].MarketPosition.Short
                              but would need to be

                              Code:
                              Position.MarketPosition == MarketPosition.Short
                              Next, Each of these conditions look like they used to be single conditions because there is a closing parenthesis at the end of the first statement before the AND symbol, this needs to be removed to allow the AND to be processed. Also there is an opening parenthesis in each of these statements after the & that needs removed.

                              Next, the condition AND requires two & signs or would be: &&, the current conditions lack a second and which throws an error.

                              Here is an example complete condition from what you had, I have corrected the errors in this statement:

                              Code:
                              // Condition set 3
                               if(Position.MarketPosition == MarketPosition.Short &&(Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) <= -200));
                              {
                              	    ExitShort("ExitShortSO", "Short");
                              }
                              Additionally there are some comparisons using the single equals sign = which is for assigning, when you need the double equals sign == which means equals.

                              I look forward to being of further assistance.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              571 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              330 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              548 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              549 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X