NexusFi: Find Your Edge


Home Menu

 





Symmetry


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Maletor with 11 posts (3 thanks)
    2. looks_two Big Mike with 6 posts (0 thanks)
    3. looks_3 Todd with 4 posts (0 thanks)
    4. looks_4 kronie with 2 posts (0 thanks)
    1. trending_up 13,484 views
    2. thumb_up 3 thanks given
    3. group 6 followers
    1. forum 25 posts
    2. attach_file 9 attachments




 
Search this Thread

Symmetry

  #1 (permalink)
Maletor
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
    }
}

Attached Thumbnails
Click image for larger version

Name:	Picture 5(2).png
Views:	305
Size:	97.4 KB
ID:	43   Click image for larger version

Name:	Picture 4(2).png
Views:	567
Size:	164.3 KB
ID:	44  
Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
 
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
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,463 since Jun 2009
Thanks Given: 33,236
Thanks Received: 101,658

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

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 
Todd's Avatar
 Todd 
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

Reply With Quote
  #4 (permalink)
Maletor
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
Reply With Quote
  #5 (permalink)
Maletor
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.

Reply With Quote
  #6 (permalink)
Maletor
Boston
 
Posts: 88 since Jun 2009
Thanks Given: 7
Thanks Received: 27

Here is export.

Attached Files
Elite Membership required to download: Symmetry.zip
Reply With Quote
  #7 (permalink)
 
Big Mike's Avatar
 Big Mike 
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,463 since Jun 2009
Thanks Given: 33,236
Thanks Received: 101,658


Maletor View Post
Here is export.

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

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
Maletor
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.

Reply With Quote
  #9 (permalink)
 
Todd's Avatar
 Todd 
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

Reply With Quote
  #10 (permalink)
Maletor
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
Click image for larger version

Name:	Picture 6(2).png
Views:	408
Size:	157.3 KB
ID:	47   Click image for larger version

Name:	Picture 7(2).png
Views:	258
Size:	96.9 KB
ID:	48  
Attached Files
Elite Membership required to download: Sym2.zip
Reply With Quote




Last Updated on August 3, 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