Go Back   NinjaTrader Support Forum > Application Technical Support > Strategy Analyzer

Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer.

Thread Tools Display Modes
Old 02-10-2012, 10:58 PM   #1
Senior Member
Join Date: Jan 2011
Posts: 134
Thanks: 22
Thanked 2 times in 2 posts
Default 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.

#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)

        /// <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;
wallsteetking is offline  
Reply With Quote
Old 02-11-2012, 01:10 PM   #2
NinjaTrader Customer Service
NinjaTrader_AdamP's Avatar
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 387 times in 375 posts


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.
NinjaTrader_AdamP is offline  
Reply With Quote

false, gap strategy, mutli entries, true

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strategy.CalculateOnBarClose=true vs. Indicator.CalculateOnBarClose=false karimatka Strategy Development 7 05-23-2011 03:39 AM
CalculateOnBarClose True AND False ohowie Automated Trading 6 10-11-2010 01:43 PM
Strategy COBC=false, Indicator COBC=true? MXASJ Version 7 Beta General Questions & Bug Reports 2 06-28-2010 05:35 AM
CalculateOnBarClose=true; but then false stephenszpak Strategy Development 1 01-02-2010 02:42 AM
Statements if/true/false skikg General Programming 2 12-09-2009 02:45 PM

All times are GMT -6. The time now is 12:59 AM.

FULL RISK DISCLOSURE: Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

The NinjaTrader Support Forum is hosted and operated by NinjaTrader LLC (“NT”), a software development company which owns and supports the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is an NFA registered introducing broker (NFA #0339976). The Support Forum is intended for information and educational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Developers who offer products or other trading software tools to be used with the NinjaTrader trading platform are independent persons or companies that are in no manner affiliated with NT or NTB. Please be aware that any performance information provided by a 3rd party developer should be considered hypothetical and must contain the required additional disclosures. Specific questions related to a brokerage account should be sent to your broker directly. The views and opinions expressed in this forum are those of the authors and do not necessarily reflect the official policy or position of NT or NTB.