Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Symmetry
Updated August 3, 2010
Top Posters
looks_one
Maletor
with 11 posts (3 thanks)
looks_two
Big Mike
with 6 posts (0 thanks)
looks_3
Todd
with 4 posts (0 thanks)
looks_4
kronie
with 2 posts (0 thanks)
trending_up
13,640 views
thumb_up
3 thanks given
group
6 followers
forum
25 posts
attach_file
9 attachments
Symmetry
June 13th, 2009, 03:35 PM
Boston
Posts: 88 since Jun 2009
Thanks Given: 7
Thanks Received: 27
Here is my version of Mike's Symmetry.
My back test only goes back to 6/3 without crashing.
Maybe that's because I'm using a tick chart or who knows. It would be nice if it could go further back.
Anyways, I've been trying to optimize this to be more profitable. Right now it's pretty much break-even.
It could be that a 3 point simple bracket is not the right idea.
You're free to use this code as you like. Maybe if we can all work on it together we will finally come up with the Holy Grail
Code
#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.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class Symmetry : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#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()
{
SetProfitTarget("", CalculationMode.Ticks, 16);
SetStopLoss("", CalculationMode.Ticks, 16, false);
TraceOrders = true;
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// For direction
if(direction == "long")
if(Close[0] < DoubleMA(34, NinjaTrader.Indicator.MAV.MAType.ADXVMA, 34, NinjaTrader.Indicator.MAV.MAType.EMA).RisingPlot[0])
direction = null;
if(direction == "short")
if(Close[0] > DoubleMA(34, NinjaTrader.Indicator.MAV.MAType.ADXVMA, 34, NinjaTrader.Indicator.MAV.MAType.EMA).FallingPlot[0])
direction = null;
if(direction == "long")
if (TSSuperTrend(14, TradingStudies.NinjaScript.Utility.MovingAverageType.SMA, 2.618, 14, TradingStudies.NinjaScript.Utility.SuperTrendMode.ATR).UpTrend[0] == 0)
direction = null;
if(direction == "short")
if (TSSuperTrend(14, TradingStudies.NinjaScript.Utility.MovingAverageType.SMA, 2.618, 14, TradingStudies.NinjaScript.Utility.SuperTrendMode.ATR).DownTrend[0] == 0)
direction = null;
// For longs
if (ECO2New2(7, 4, 21).Main[0] > 0 &&
ECO2New2(7, 4, 21).Main[0] > ECO2New2(7, 4, 21).Signal[0]
&& ECO2New2(7, 4, 21).ECORising[0] != 0
&& TSSuperTrend(14, TradingStudies.NinjaScript.Utility.MovingAverageType.SMA, 2.618, 14, TradingStudies.NinjaScript.Utility.SuperTrendMode.ATR).UpTrend[0] != 0
&& Close[0] > DoubleMA(34, NinjaTrader.Indicator.MAV.MAType.ADXVMA, 34, NinjaTrader.Indicator.MAV.MAType.EMA).RisingPlot[0]
&& Close[0] > DoubleMA(16, NinjaTrader.Indicator.MAV.MAType.ZeroLagEMA, 16, NinjaTrader.Indicator.MAV.MAType.ZeroLagEMA).RisingPlot[0]
//&& DoubleMA(14, NinjaTrader.Indicator.MAV.MAType.ZeroLagEMA, 1, NinjaTrader.Indicator.MAV.MAType.ADXVMA).NeutralPlot[0] == 0
)
{
if(direction != "long")
{
direction = "long";
//DrawArrowUp("Up" + CurrentBar, true, 0, Low[0] - (4 * TickSize), Color.Lime);
//DrawText("Up info" + CurrentBar, Close[0].ToString("0.00"), 0, Low[0] - (10 * TickSize), Color.Lime);
//PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\long.wav");
EnterLong(1,"");
}
}
// For shorts
if (ECO2New2(7, 4, 21).Main[0] < 0 &&
ECO2New2(7, 4, 21).Main[0] < ECO2New2(7, 4, 21).Signal[0]
&& ECO2New2(7, 4, 21).ECOFalling[0] != 0
&& TSSuperTrend(14, TradingStudies.NinjaScript.Utility.MovingAverageType.SMA, 2.618, 14, TradingStudies.NinjaScript.Utility.SuperTrendMode.ATR).DownTrend[0] != 0
&& Close[0] < DoubleMA(34, NinjaTrader.Indicator.MAV.MAType.ADXVMA, 34, NinjaTrader.Indicator.MAV.MAType.EMA).FallingPlot[0]
&& Close[0] < DoubleMA(16, NinjaTrader.Indicator.MAV.MAType.ZeroLagEMA, 16, NinjaTrader.Indicator.MAV.MAType.ZeroLagEMA).FallingPlot[0]
//&& DoubleMA(14, NinjaTrader.Indicator.MAV.MAType.ZeroLagEMA, 1, NinjaTrader.Indicator.MAV.MAType.ADXVMA).NeutralPlot[0] == 0
)
{
if(direction != "short")
{
direction = "short";
//DrawArrowDown("Down" + CurrentBar, true, 0, High[0] + (4 * TickSize), Color.Lime);
//DrawText("Down info" + CurrentBar, Close[0].ToString("0.00"), 0, High[0] + (10 * TickSize), Color.Lime);
//PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\short.wav");
EnterShort(1,"");
}
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public string direction = null;
#endregion
}
}
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
June 13th, 2009, 03:45 PM
Manta, Ecuador
Site Administrator Developer Swing Trader
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,499 since Jun 2009
Thanks Given: 33,264
Thanks Received: 101,715
Hi Maletor,
Can you post the .CS file or better yet, File -> Utilities -> Export it and post the zip?
There is a hack to make ninja more stable with large backtests. I posted it here:
Mike
June 13th, 2009, 03:54 PM
Alpharetta, GA
Experience: Intermediate
Platform: ninja
Broker: Mirus / Zenfire
Trading: ES
Posts: 234 since Jun 2009
Thanks Given: 28
Thanks Received: 40
I'm still new at programming but I'm been experimenting with the ECO2 in discretionary trading.
Here was my idea. Maybe you could try this...
See screenshot [FONT=Calibri][SIZE=3][COLOR=#0000ff]http://screencast.com/t/5mV31Wku[/COLOR][/SIZE][/FONT]
Step 1:
Enter the trade on the 1st ECO entry signal after the eco line crosses the zero line IN THE DIRECTION OF THE OVERALL TREND LINE (MAYBE A 36 zerolag/zerolag dma).
Only taking trades in the direction of the longer timeframe trendline will hopefully avoid fakeouts without still allowing you to catch most of the profitable trades. I’ve noticed lots of times you have 6e or ES going long or sideways, then you get a little down (to shake people out of their long positions or get others to go short), then a big move up to leave to crush the quick entry shorts and disappoint the early exit longs. It's max pain on a small scale . I see this over and over again. In fact, you can see it in the screenshot.
Then, money management ….
Step 2a - Take one contract off at 6 ticks of profit (which should be very easy to do on 6e)
OR
Step 2b – Take a stop loss on both contracts at 15 tick stop loss from entry point
Step 3 – trail the 2nd contract with a progressively tightening trail stop.
Let me know what you think.
P.S.... I'm guessing that your code will only test back a few days because of contract rollover...but that is just a guess.
Todd
June 13th, 2009, 03:57 PM
Boston
Posts: 88 since Jun 2009
Thanks Given: 7
Thanks Received: 27
Stupid thing won't zip it complaining it won't compile when that is a farce.
Here is the .CS while I see if I can figure out what is making it stick.
Thanks for the NT backtesting hack by the way.
Attached Files
Elite Membership required to download: Symmetry.cs
June 13th, 2009, 04:03 PM
Boston
Posts: 88 since Jun 2009
Thanks Given: 7
Thanks Received: 27
You mean take 6 tick profit and move to stop breakeven or keep at -15 ticks?
Are you using ModHA2 in that screenshot ?
Mike, still no go with the export... CS file is all that works, but you can just create a new strategy and unlock code and copy and paste.
June 13th, 2009, 04:11 PM
Boston
Posts: 88 since Jun 2009
Thanks Given: 7
Thanks Received: 27
Here is export.
Attached Files
Elite Membership required to download: Symmetry.zip
June 13th, 2009, 04:21 PM
Manta, Ecuador
Site Administrator Developer Swing Trader
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,499 since Jun 2009
Thanks Given: 33,264
Thanks Received: 101,715
Maletor
Cool.
You might try a different period, like 4 range , 6 range, etc. Maybe 1597 volume instead of tick, or 2584 volume, 4181 volume, etc.
It is hard to really know what this strategy will do with only 20 or so trades and a short time frame.
I will load it up over here and backtest it further back and share the results in a few minutes.
Edit: please upgrade to latest SuperTrend from SuperTrend thread on Ninja forums, can't backtest it properly until this is done.
Mike
June 13th, 2009, 04:27 PM
Boston
Posts: 88 since Jun 2009
Thanks Given: 7
Thanks Received: 27
You are right Todd, it is more about money management than anything else.
The only reason I would program a strategy is to hear that girl say "possible long signal" so I can watch a movie or something and come back to see what is materializing.
June 13th, 2009, 04:35 PM
Alpharetta, GA
Experience: Intermediate
Platform: ninja
Broker: Mirus / Zenfire
Trading: ES
Posts: 234 since Jun 2009
Thanks Given: 28
Thanks Received: 40
Maletor,
I meant after 6 tick profit, move the stop on the remaining contract from -15 ticks to -6 or -5 ticks to guarantee at least a breakeven trade.
Yes...those are modha2 bars.
Todd
June 13th, 2009, 05:05 PM
Boston
Posts: 88 since Jun 2009
Thanks Given: 7
Thanks Received: 27
Version 2.
Here is a simplified version that seems to be doing much better.
It's all so discretionary, but this strategy would be what I should program to alert me that something is happening. I would still have all the indicators on as in the first Sym and would be staying out of flat ECOs.
Attached Thumbnails
Attached Files
Elite Membership required to download: Sym2.zip
Last Updated on August 3, 2010