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,499 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?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Are there any eval firms that allow you to sink to your …
Traders Hideout
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
Deepmoney LLM
Elite Quantitative GenAI/LLM
Build trailing stop for micro index(s)
Psychology and Money Management
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
43 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks




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