Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NOOB: Info on buy/sell order for EOD data

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

    NOOB: Info on buy/sell order for EOD data

    Im using EOD data and am trying to write a simple strategy. Lets say i have a setup that is like this:

    If previous days high is higher then two days i want to place a long order today buyng when/if todays bar penetrates yeasterdays high (the problem is i only have EOD data but this should still be very possible to do). Then i want my exit to be the closing price 3days after my entry.

    In code this would be something like this:
    protected override void OnBarUpdate()
    {
    if(High[1]>High[2])
    EnterLong(); //I cant use this one can i???

    Now i just want my simple exit to exit 3days after the order is done at the Closing price from that day.

    #2
    Im stuck, plz someone point me in the right direction?

    Comment


      #3
      Hi zwoop,

      I have a reply for you that I need to confirm with a colleague, you can expect an answer shortly.
      TimNinjaTrader Customer Service

      Comment


        #4
        Hi zwoop,

        First, with EOD data, the entry will always be one day late if your condition contains the current day, this is because the data doesn't exist until the end of the day.

        Second, all of this can be done with the Strategy Wizard, so I suggest starting there.
        Here a good tutorial - http://www.ninjatrader-support.com/H...tml?Overview34

        if(High[1]>High[2]) will indeed satisfy your first condition

        CrossAbove can be used for your secondary condition.
        More info at - http://www.ninjatrader-support.com/H...tml?CrossAbove


        Using EnterLong() in that way is fine.
        More info at - http://www.ninjatrader-support.com/H...html?EnterLong


        You can use BarsSinceEntry() for your exit condition
        More info at - http://www.ninjatrader-support.com/H...BarsSinceEntry

        Once you become more familiar with this, and have access to something other than EOD data, you may want to consider the following - http://www.ninjatrader-support2.com/...ead.php?t=6652
        and - http://www.ninjatrader-support.com/H...ameInstruments
        TimNinjaTrader Customer Service

        Comment


          #5
          Thanks i do everything in code not the wizard.
          Is there any way for me to pring out information from my strategy while it is running? Like if i want to see how many bars that gaps up if last days bar closed in the top 10% of its range lets say. Can i count this condition in a variabel an then output that somewhere?

          Comment


            #6
            Hi zwoop,

            You can use Print() statements for this...
            More info at - http://www.ninjatrader-support.com/H...ide.html?Print

            You can either write the calculation in the print statement, or calculate with a variable, then Print(variablename);
            TimNinjaTrader Customer Service

            Comment


              #7
              Just cant get a hold of in what order the bars come in and the buy/sell prices are set. Can you just plz show the code for a very simpe system that will clear things up.

              If yesterday closed up i want to buy today at the opening price IF todays opening price is higher then yeasterdays close. Then i want to sell at todays close. This is done on EOD data.

              When i see the code for this everything should fall into place. Thanks.

              Comment


                #8
                When running EOD, the last bar you are able to process is already "yesterday" because that is the bar that just closed. To access it just use a daily chart and do:
                Code:
                if (Close[0] > Open[0])
                     EnterLong();
                That entry order will go to the open of the next day which is the open of today.

                If you are using EOD intervals there is no way you can check the opening price of the future to make your determinations of trades here. You can either enter it based on yesterday's EOD data or wait until the next day and use intraday data to determine if the new open > previous close.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Ok the thing is i want to run some tests that are not a whole trading system. I just want to get statistics on different patterns before i start with a system. That is why im interested in comparing this type of "future" prices. Is there any support in Ninja to do other studys not using the strategy simulator so that i can acces my eod data more freely?

                  Comment


                    #10
                    Hi zwoop,

                    Unfortunately, accessing future data on historical data, is not supported.
                    TimNinjaTrader Customer Service

                    Comment


                      #11
                      Ok thanks for the patients Think im slowling starting to learn now!

                      As for testing stuff in ninja trader, shold not this simple code do exactly what i want? First i want to check if the day befor today closed up compared to two days ago then i want to check if today opend higher then todays close. If this is the case i want to count how many times todays closed higher/lower/unchanged. Than when the whole time period is done i want to print the results to the output window...

                      protected override void OnBarUpdate()
                      {
                      if((Close[1]>Close[2]) && (Open[0]>Close[1])){
                      BarColor = Color.Yellow;
                      if(Close[0]>Open[0])
                      upp1++;
                      else if(Close[0]<Open[0])
                      down1++;
                      else
                      unChanged1++;
                      }

                      if (Bars.CurrentBar == Bars.Count-2){
                      Print("++ UPP: "+ upp1/(upp1+down1+unChanged1)*100 +"%");
                      }
                      }

                      Feels simpe but nnothing happens when i run this so i guess i doing something worng.

                      Comment


                        #12
                        Hi zwoop,

                        I have a reply for you that I need to confirm with a colleague, you can expect an answer shortly.
                        TimNinjaTrader Customer Service

                        Comment


                          #13
                          Hi zwoop,

                          I'd be happy to take a closer look, but first, please answer the following...

                          Is this in an indicator or a strategy?

                          Can you check the Log tab of the Control Center for errors when you run the code, you may be experiencing the error described here - http://www.ninjatrader-support2.com/...ead.php?t=3170

                          Did you declare upp1, down1 and unChanged1?
                          TimNinjaTrader Customer Service

                          Comment


                            #14
                            The error was that i did have BarsRequired=0; changed that to "1" and then it works.

                            Got a new problem now that makes no sense. Im using an array but get the error "Cannot applay indexing with [] to an expressions of type 'double' "
                            double upp=new double[60];//This is how i declare it
                            upp[0]++; //This is how i try to acces the first element when i get the error.

                            Comment


                              #15
                              zwoop,

                              You cannot declare a double like that. Should you want a double to have historical values you would probably want to make a DataSeries object instead. Please see here for examples on making DataSeries which would hold historical double values: http://www.ninjatrader-support.com/H...taSeriesObject
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ballston, Today, 06:32 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post ballston  
                              Started by Lando Calrissian, Today, 07:30 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post Lando Calrissian  
                              Started by facuevasm, Today, 07:28 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post facuevasm  
                              Started by Leeroy_Jenkins, Today, 03:45 AM
                              0 responses
                              13 views
                              0 likes
                              Last Post Leeroy_Jenkins  
                              Started by sinpeople, Today, 04:38 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post sinpeople  
                              Working...
                              X