NexusFi: Find Your Edge


Home Menu

 





SuperTrendU11 Strategy Query


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one sburtt with 8 posts (0 thanks)
    2. looks_two vegasfoster with 3 posts (0 thanks)
    3. looks_3 sam028 with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,581 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 14 posts
    2. attach_file 3 attachments




 
Search this Thread

SuperTrendU11 Strategy Query

  #11 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,824
Thanks Received: 4,629


sburtt View Post
sam028, thanks. whereabouts in the code should I include this script? and what exactly would this help doing? I am just asking because I would like to learn

thanks

You can add this in OnPositionUpdate() or in OnBarUpdate(), that will show you of the value you try to use in your stoploss() function.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
67 thanks
Battlestations: Show us your trading desks!
48 thanks
NexusFi site changelog and issues/problem reporting
47 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
31 thanks

  #12 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4


sam028 View Post
You can add this in OnPositionUpdate() or in OnBarUpdate(), that will show you of the value you try to use in your stoploss() function.

the issue still persists. I am happy to share the code if somebody is willing to look into this. The issue is the StopLine or StopDot plotted by the SuperTrendU11 indicator, I want to use this a hard stoploss but I continue to encounter charts like this in backtesting, basically entry/stoploss at the same level rather than at the stop level.

Started this thread Reply With Quote
  #13 (permalink)
 askerix 
Zurich Switzerland
 
Experience: None
Platform: NT
Trading: Ukulele
Frequency: Never
Duration: Never
Posts: 60 since Mar 2011
Thanks Given: 554
Thanks Received: 61


you have to take care that SetStopLoss is updated before your strategy enters a new position otherwise you will be immediately taken out by your former Long Stop Loss (in case you enter short).

from the NT 7 help ( NinjaTrader Version 7 )
• You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position
• Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position

Reply With Quote
The following user says Thank You to askerix for this post:
  #14 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4


askerix View Post
you have to take care that SetStopLoss is updated before your strategy enters a new position otherwise you will be immediately taken out by your former Long Stop Loss (in case you enter short).

from the NT 7 help ( NinjaTrader Version 7 )
• You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position
• Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position

that made the trick, thanks it's working fine now.

Started this thread Reply With Quote
  #15 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4


askerix View Post
you have to take care that SetStopLoss is updated before your strategy enters a new position otherwise you will be immediately taken out by your former Long Stop Loss (in case you enter short).

from the NT 7 help ( NinjaTrader Version 7 )
• You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position
• Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position

by any chance, would you know if it's possible to optimize the AnaSuperTrendU11 parameters used in a strategy via the StrategyAnalyzer optimizer? When I try to optimize I receive the following error message:



I am running a very simple code, not sure what'screating this issue, code below. Thanks

 
Code
namespace NinjaTrader.Strategy
{
    [Description("")]
    public class aaaFisherAnaSuperTrendLong : Strategy
    {
        #region Variables
		private int period = 10;
		private int multiplier = 3;
		private int rngPeriod = 6;

        #endregion

        protected override void Initialize()
        {
			Add(anaSuperTrendU11(period, multiplier, rngPeriod, false, anaSuperTrendU11BaseType.TEMA, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Standard_Deviation));
            CalculateOnBarClose = true;
			EntryHandling 	=	EntryHandling.UniqueEntries;
			ExitOnClose = false;
		}
        
        protected override void OnBarUpdate()
        {							
			if (Position.MarketPosition == MarketPosition.Flat)
				SetStopLoss(CalculationMode.Ticks,100);
				
			//Enter long
			if (CrossAbove(..))
				EnterLong("Long");
			
			if (Position.MarketPosition == MarketPosition.Long)
				SetStopLoss(CalculationMode.Price,Instrument.MasterInstrument.Round2TickSize(anaSuperTrendU11(period, multiplier, rngPeriod, false, anaSuperTrendU11BaseType.TEMA, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Standard_Deviation).StopDot[0]));
			
        }

        #region Properties		
		[Description("")]
        [GridCategory("Parameters")]
        public int Period
        {
            get { return period; }
            set { period = Math.Max(0, value); }
        }
		
		[Description("")]
        [GridCategory("Parameters")]
        public int Multiplier
        {
            get { return multiplier; }
            set { multiplier = Math.Max(0, value); }
        }		
		
		[Description("")]
        [GridCategory("Parameters")]
        public int RngPeriod
        {
            get { return rngPeriod; }
            set { rngPeriod = Math.Max(0, value); }
        }		
 		#endregion
    }
}

Started this thread Reply With Quote





Last Updated on May 29, 2013


© 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