• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

True/ False Gap strategy help needed

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

    True/ False Gap strategy help needed

    Hi Team,
    I would like to test a strategy where Ninjatrader goes long when there is a 10 point gap up from yesterdays close till next day open at 8:30 E/T (IF THIS IS TRUE)

    Then Ninjatrade should take EVERY LONG EVERYTIME it crosses above the 5 EMA line and looki for 2pt profit.
    My issue is that ninjatrade only takes one trade a day. can you pleas take a look at the code and tell me what i am doing wrong.


    Code:
    #region Using declarations
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        /// <summary>
        /// Enter the description of your strategy here
        /// </summary>
        [Description("Enter the description of your strategy here")]
        public class Gap6 : Strategy
        {
            #region Variables
            // Wizard generated variables
            private double p = 0.050; // Default setting for P
            private double sL = 0.03; // Default setting for SL
            private double oFL = 0.005; // Default setting for OFL
            private double oFS = 0.005; // Default setting for OFS
            // User defined variables (add any user defined variables below)
            #endregion
    
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
                SetProfitTarget("", CalculationMode.Ticks, 10);
                SetStopLoss("", CalculationMode.Ticks, 10, false);
    
                CalculateOnBarClose = false;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Condition set 1
                if (PriorDayOHLC().PriorClose[0] > CurrentDayOHL().CurrentOpen[0] + 40 * TickSize
                    && ToTime(Time[0]) == ToTime(8, 35, 0))
                {
                    Variable0 = 1;
                }
    
    
    
    
                // Condition set 5
                if (Variable0 == 1
                    && CrossAbove(Close, EMA(5), 1))
                {
                    EnterLong(DefaultQuantity, "");
                    Variable0 = 0;
                }

    #2
    wallstreetking,

    ToTime(Time[0]) == ToTime(8, 35, 0)

    This line will only let a trade occur at exactly 8:35 AM. You would need to change it to be less restrictive.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Miguel_88, Today, 06:41 PM
    0 responses
    5 views
    0 likes
    Last Post Miguel_88  
    Started by spikeruk, Today, 01:49 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by Yandychang, Today, 02:16 PM
    5 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by priceisking, Today, 01:16 PM
    2 responses
    8 views
    0 likes
    Last Post priceisking  
    Started by kashyapjdave, 03-23-2017, 12:12 AM
    11 responses
    1,959 views
    0 likes
    Last Post forextrader2003  
    Working...
    X