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

Does not enter the trade

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

    Does not enter the trade

    Hey all,

    got a problem I have never had so far. I programmed a simple multitimeframe indicator and its plot is absolutely correct => takes on the value 1 when it should be. (see: screenshot attached) But when I try to backtest the strategy (this indicator == an indicator which only holds the value one => then entry /*which has always worked fine with any other strategy so far*/) it does not enter and I don't know why.

    Has it got something to do with the multiple timeframe concept? Any suggestion what I'm doing wrong?

    Being really grateful for your help,

    Andrew
    Attached Files

    #2
    What entry condition would you use here Andrew for the indicator? The plot hitting the value of 1 for going long?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by andrew-aut1 View Post
      Hey all,

      got a problem I have never had so far. I programmed a simple multitimeframe indicator and its plot is absolutely correct => takes on the value 1 when it should be. (see: screenshot attached) But when I try to backtest the strategy (this indicator == an indicator which only holds the value one => then entry /*which has always worked fine with any other strategy so far*/) it does not enter and I don't know why.

      Has it got something to do with the multiple timeframe concept? Any suggestion what I'm doing wrong?

      Being really grateful for your help,

      Andrew
      What is the error in your log?

      Comment


        #4
        entry condition: plot hitting the value of 1 for going long. Idea is that after a fall in at the first day succeeded by two rises of the two following days will give me the opportunity to get in the market = value 1: My code is as follows : PS: don't get confused: the script has been modified was a script for Keltner Channels in the beginning; thus I couldn't get rid off the variables period and offset Multiplier and they are not of interest.

        Many thx!



        public class UpandDowns : Indicator
        {
        #region Variables
        private int period = 10;
        private double offsetMultiplier = 1.5;
        private DataSeries diff;

        private int timeframe = 390;
        private DataSeries myDataSeries; // Define a DataSeries variable
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
        Add(PeriodType.Minute, timeframe);
        //myDataSeries = new DataSeries(this, MaximumBarsLookBack.Infinite);

        Add(new Plot(Color.Blue, "Marker"));
        //Add(new Plot(Color.Red,PlotStyle.Dot, "Marker2"));
        diff = new DataSeries(this);

        Overlay = false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick).
        /// </summary>
        protected override void OnBarUpdate()
        {
        /* Only need to sync DataSeries objects once. We couldn't do this sync in the Initialize() method because we
        cannot access the BarsArray property there. */
        if (diff == null && BarsInProgress == 1)
        {
        /* Syncs another DataSeries object to the secondary bar object.
        We use an arbitrary indicator overloaded with an IDataSeries input to achieve the sync.
        The indicator can be any indicator. The DataSeries will be synced to whatever the
        BarsArray[] is provided.*/
        diff = new DataSeries(SMA(BarsArray[1], 50));
        }
        //checks we have enough bars to calculate
        if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
        return;
        double marker = 0;
        //double marker2 = 0;
        if (BarsInProgress == 0)
        {





        if (CurrentBar < 2)
        return;
        double Open12 = Opens[1][2];
        double Close12 = Closes[1][2];
        double Open11 = Opens[1][1];
        double Close11 = Closes[1][1];
        double Open10 = Opens[1][0];
        double Close10 = Closes[1][0];
        double Open00 = Opens[0][0];
        double Close00 = Closes[0][0];

        if (Open12 > Close12 && Open11 < Close11 && Open10 < Close10)
        {
        marker = marker + 1;
        }

        Marker.Set(marker);

        }


        if (BarsInProgress == 1)
        {
        if (CurrentBar < 2)
        return;


        }




        }

        Comment


          #5
          Thanks, I don't see an issue per se - with a simple test entry rule for market order like

          // Condition set 1
          if (UpandDowns()[0] >= 1)
          {
          EnterLong(DefaultQuantity, "");
          }

          ...I see it entering trades as expected.
          BertrandNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          5 responses
          3,290 views
          1 like
          Last Post jgualdronc  
          Started by Touch-Ups, Today, 10:36 AM
          0 responses
          7 views
          0 likes
          Last Post Touch-Ups  
          Started by geddyisodin, 04-25-2024, 05:20 AM
          8 responses
          61 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by Option Whisperer, Today, 09:55 AM
          0 responses
          8 views
          0 likes
          Last Post Option Whisperer  
          Started by halgo_boulder, 04-20-2024, 08:44 AM
          2 responses
          24 views
          0 likes
          Last Post halgo_boulder  
          Working...
          X