(Kaufman adaptive moving average + ROC) Strategy Transcode - NinjaTrader Programming | futures io social day trading
futures io futures trading


(Kaufman adaptive moving average + ROC) Strategy Transcode
Updated: Views / Replies:741 / 1
Created: by Pharmakon Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

(Kaufman adaptive moving average + ROC) Strategy Transcode

  #1 (permalink)
Elite Member
Paris France
 
Futures Experience: Beginner
Platform: TradingView
Broker/Data: CQG
Favorite Futures: ES1!, CL1!, DY1!
 
Pharmakon's Avatar
 
Posts: 45 since Jan 2016
Thanks: 115 given, 26 received

(Kaufman adaptive moving average + ROC) Strategy Transcode

Hi everybody !

Firstly, I'd like to give many thanks to everybody working hard to give this community a lot of value. It's very helpful to find almost one post about everything I'm looking to know about trading methodology.

I'm very new to strategy programming but I'd really like to make progress on it. I've only done the BigMike Tutorial. Thank you Big Mike. And, I've understood that I won't be able to progress alone or in a very slow way. So I come here looking to share ideas and help if I can but I don't want to flood the forum. I'm trying to give the most value to my post.

I've found a nice working strategy on TradingView website. It works very well on many securities (see pictures at the bottom of the post) with this platform trading simulator. I give the link to the strategy just to respect sourcing.

https://www.tradingview.com/script/Y49ipujG-Kama-VS-HeikinAshi-Strategy-synapticex/

It's a combination of Kaufman Adaptive Moving Average and ROC.

Source code is here (TradingView Proprietary Language) :

 
Code
//@version=2
//synapticex.com
kamaPeriod = input(8, minval=1) 
ROCLength=input(4, minval=1) 

kama(length)=>
    volatility = sum(abs(close-close[1]), length)
    change = abs(close-close[length-1])
    er = iff(volatility != 0, change/volatility, 0)
    sc = pow((er*(0.666666-0.064516))+0.064516, 2)
    k = nz(k[1])+(sc*(hl2-nz(k[1])))
    
kamaEntry = security(tickerid,period,kama(kamaPeriod))

plot(kamaEntry, color=gray, title="Kama",transp=0, trackprice=false, style=line)
roc = roc(close, ROCLength)

strategy("Kama VS HeikinAshi", overlay=true, pyramiding=0, calc_on_every_tick=true, calc_on_order_fills=true)

buyEntry =  kamaEntry[0]>kamaEntry[1] and roc[1]<0 and roc >0
sellEntry = kamaEntry[0]<kamaEntry[1] and roc[1]<0 and roc <0

buyExit = kamaEntry<kamaEntry[1] or (roc[1]>0 and roc<0)
sellExit =  kamaEntry>kamaEntry[1] or (roc[1]<0 and roc>0)

if (buyEntry)
    strategy.entry("KAMAL", strategy.long, comment="KAMAL")
else
    strategy.close("KAMAL", when=buyExit)

if (sellEntry)
    strategy.entry("KAMAS", strategy.short, comment="KAMAS")
else
    strategy.close("KAMAS", when=sellExit)

I'm trying to transcode it to NinjaTrader to be able to share it to do a small real backtest. But I'm confronted with some issues on coding it. I'm stuck ! I don't how to transcode two of these function :

- nz : Not a Number function (NaN)
- security : which returns another series of the input data given.

I've already started to code it. I hope it will help :

 
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>
    /// 20160428 My first money maker strategy based with SMA, EMA, HMA
    /// </summary>
    [Description("20160428 My first money maker strategy based with SMA, EMA, HMA")]
    public class MyMoneyMaker : Strategy
    {
        #region Variables
        // Wizard generated variables
        private int myInput0 = 1; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
        #endregion
		
		private int		kamaPeriod 		= 8;		//variables en minuscules
		private int		rocLength 		= 4;
		
        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
            CalculateOnBarClose = true;
			EntryHandling		= EntryHandling.UniqueEntries; //Unique entry if you have multiple longs signal at same time
			
        }		
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
			EntryHandling		= EntryHandling.UniqueEntries;
			
			if (Position.MarketPosition != MarketPosition.Flat) return;
			if (CurrentBar < kamaPeriod) return;
			
			//length = kamaPeriod
			
			double 		volatility 		= 0;
			double 		change			= 0;
			double		er				= 0;
			double		sc				= 0;
			double		k				= 0;
			double		roc				= 0;
			
			for (int barsAgo = 0; barsAgo < kamaPeriod; barsAgo++)
			{
				volatility = volatility + Math.Abs(Close[barsAgo] - Close[barsAgo+1]);
			}
			
			change = Math.Abs(Close[0] - Close[kamaPeriod - 1]);
			
			if (volatility != 0)
				er = change/volatility;
			else
				er = 0;
			
			sc = Math.Pow((er*(0.666666-0.064516))+0.064516, 2);
			
			// left: 
			// security ?
			// k : NaN function ?
			// Plot ?
			
			//ROC
			
			roc = ROC(Close[0],rocLength);
			
			
			// Long/Sell entry orders
			
			
			// exit orders
			
			
			
			
		
        }

        #region Properties
        [Description("")]
        [GridCategory("Parameters")]
        public int KamaPeriod	//Fonction 1ere lettre en Majuscule ?
        {
            get { return kamaPeriod; }
            set { kamaPeriod = Math.Max(1, value); }
        }        
		[Description("")]
        [GridCategory("Parameters")]
		public int RocLength
        {
            get { return rocLength; }
            set { rocLength = Math.Max(1, value); }
        }        
        #endregion
    }
}


 
Code
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Regards,
M.

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.


Reply



futures io > > > > > (Kaufman adaptive moving average + ROC) Strategy Transcode

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adaptive RSI Moving Average With Smoothing WilleeMac Sierra Chart 0 April 10th, 2016 04:34 PM
Multiple moving average crossing strategy parsamkk The Elite Circle 7 August 5th, 2013 10:07 AM
Best Moving Average sharmas Elite Automated Trading 62 April 9th, 2012 07:44 PM
MAMA (Mesa Adaptive Moving Average) EA motoko Platforms and Indicators 0 August 29th, 2011 06:02 PM
Moving average Help yiman NinjaTrader Programming 4 July 29th, 2011 09:03 AM


All times are GMT -4. The time now is 02:39 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-14 in 0.10 seconds with 19 queries on phoenix via your IP 54.221.76.68