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

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

Hi All,

I am trying to use the SuperTrendU11 indicator as a stop loss in my strategy.

However I need the uptrend and downtrend lines (respectively my short stop loss and long stop loss) to be generated only when my strategy enters position. e.i. my strategy is a MovingAverageCrossOver, I would need SuperTrendU11 to switch from uptrend to downtrend on the MovingAverageCrossOver. Is this possible?

Could somebody please indicate me what part of the code I must modify in order to make this possible.

Thanks!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
 
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

  #3 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844


I don't have NT installed anymore, but I would try adding the condition to the supertrend code and then replace the two parts highlighted here with that condition



Anyone feel free to correct me, but I think something like this will work,

 
Code
bool UP = EMA(13)[0] > EMA(21)[0];
bool DOWN = EMA(13)[0] < EMA(21)[0];

else 
			{
				if (priorUpTrend && DOWN)
					currentUpTrend = false;
				else if (!priorUpTrend && UP)
					currentUpTrend = true;
				else
					currentUpTrend = priorUpTrend;
			}

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


vegasfoster View Post
I don't have NT installed anymore, but I would try adding the condition to the supertrend code and then replace the two parts highlighted here with that condition



Anyone feel free to correct me, but I think something like this will work,

 
Code
bool UP = EMA(13)[0] > EMA(21)[0];
bool DOWN = EMA(13)[0] < EMA(21)[0];

else 
			{
				if (priorUpTrend && DOWN)
					currentUpTrend = false;
				else if (!priorUpTrend && UP)
					currentUpTrend = true;
				else
					currentUpTrend = priorUpTrend;
			}

I used this
 
Code
			else 
			{
				if (priorUpTrend && CrossBelow(EMA(13),EMA(21),1))
					currentUpTrend = false;
				else if (!priorUpTrend && CrossAbove(EMA(13),EMA(21),1))
					currentUpTrend = true;
				else
					currentUpTrend = priorUpTrend;
as the bool was giving me an error, not sure why.

does it make anydifference if I use CrossAbove rather than >? graphically looks the same

THANKS FOR YOUR HELP

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

Would somebody know how to use the SuperTrend as a stoploss?

I am using this code, but in multiple occasions my strategy enters an exits at exactly the same time, not what I would like it to do (see below)



Clearly i am not doing it right, I would appreciate if you had any tips.
Thanks

 
Code
        protected override void OnBarUpdate()
        {				
			if (Position.MarketPosition != MarketPosition.Long)
			{
				SetStopLoss(CalculationMode.Price,Instrument.MasterInstrument.Round2TickSize(anaSuperTrendU11(24, 9, 4, false, anaSuperTrendU11BaseType.TEMA, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Standard_Deviation).StopLine[0]));
			}

Started this thread Reply With Quote
  #6 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,824
Thanks Received: 4,629

You can try this:
 
Code
                            
Print(Instrument.MasterInstrument.Round2TickSize(anaSuperTrendU11(2494falseanaSuperTrendU11BaseType.TEMAanaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Standard_Deviation).StopLine[0]))) 

That should help the debugging process.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #7 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

My initial thought is that the strategy code is calculating before the supertrend has a chance to flip over and so it is entering and then immediately getting the signal to exit because the supertrend is still in the opposite state. In Sierra Chart you can control precedence to determine if this is the problem, but I am not sure how to do it in NT. Or...???

Reply With Quote
  #8 (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 try this:
 
Code
                            
Print(Instrument.MasterInstrument.Round2TickSize(anaSuperTrendU11(2494falseanaSuperTrendU11BaseType.TEMAanaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Standard_Deviation).StopLine[0]))) 

That should help the debugging process.

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

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


vegasfoster View Post
My initial thought is that the strategy code is calculating before the supertrend has a chance to flip over and so it is entering and then immediately getting the signal to exit because the supertrend is still in the opposite state. In Sierra Chart you can control precedence to determine if this is the problem, but I am not sure how to do it in NT. Or...???

it could be the case, but in theory the script should not action on the same timeframe, as it has a Position.MarketPosition check

Started this thread Reply With Quote
  #10 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844


IC, I dunno then.

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