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,510 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

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

  #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?
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
Quantum physics & Trading dynamics
The Elite Circle
Better Renko Gaps
The Elite Circle
Cheap historycal L1 data for stocks
Stocks and ETFs
 




Last Updated on February 28, 2010


© 2024 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 - Privacy Policy - Downloads - Top
no new posts