NexusFi: Find Your Edge


Home Menu

 





Prevent strategy from executing trade at the same price level within a session


Discussion in NinjaTrader

Updated
    1. trending_up 2,930 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
suprsnipes
Melbourne, Australia
 
Posts: 6 since Nov 2009
Thanks Given: 4
Thanks Received: 0

I have been researching the following topic of saving a variable in NT for use within a strategy to prevent the strategy from executing at the same price more than once within a session and I'm having some trouble trying to get it to compile.

If anyone one has the chance to review the code attached I would appreciate any help you can provide...

 
Code
// 
// Copyright (C) 2007, NinjaTrader LLC 
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Strategy;
#endregion

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    /// <summary>
    /// Sample strategy 
    /// </summary>
    [Description("Sample strategy")]
    public class MyCustomStrategy : Strategy
    {
        #region Variables
        double myEntryOrder        =     Position.AvgPrice;
        #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()
        {
            SetStopLoss("", CalculationMode.Ticks, 25, false);
            SetProfitTarget("", CalculationMode.Ticks, 6);

            CalculateOnBarClose = false;
        }
        
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            
            // Condition set 1
            if (CurrentDayOHL().CurrentLow[0] >= IY().IU[0]
                && Position.MarketPosition == MarketPosition.Flat
                && BarsSinceExit() > 40 && myEntryOrder != IY().IU[0])
            {
                myEntryOrder = EnterLongLimit(DefaultQuantity, IY().IU[0], "");
                
            }
            
        }
        
        #region Properties
        #endregion
    }
}
Thank you in advance,
suprsnipes


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
The May 31 Binary: 60% Trump Declares Iran Ops Over, Onl …
Prediction Markets & Event Contracts
GDP Day: The First Economic Reckoning -- Pahlavi at 6.55 …
Prediction Markets & Event Contracts
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
CME Group Fee Schedule Changes Hit All Four Exchanges -- …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks




Last Updated on February 28, 2010


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts