Position Sizing when trading Forex FX - NinjaTrader Programming | futures io social day trading
futures io futures trading


Position Sizing when trading Forex FX
Updated: Views / Replies:2,353 / 17
Created: by sburtt 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
 

Position Sizing when trading Forex FX

  #1 (permalink)
Elite Member
London, UK
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: EUR/USD
 
Posts: 58 since Jul 2012
Thanks: 3 given, 4 received

Position Sizing when trading Forex FX

Hi there,
has anybody developed an algorithm in NT to determine position size when trading FX?

This might sound stupid or obvious but the traditional position sizing tools that you find browsing around in the forum or in the NT forum work fine for futures but not for FX. What is needed is an algorithm that adopts different code when trading direct rates (e.i. EURUSD,AUDUSD,NZDUSD) comprared to indirect rates (e.i. USDCAD,USDJPY). This is without taking into consideration cross rates (e.i trading EURJPY with a USD account) that would imply even more complex code.

I am trying to develop this myself, as I believe that embedding Money Management in a strategy can dramatically improve the equity curve of any given strategy. I was wondering if anybody out there would be happy to work with me on this, or even better has this already developed. Thanks, John

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.

 
  #3 (permalink)
Elite Member
London, UK
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: EUR/USD
 
Posts: 58 since Jul 2012
Thanks: 3 given, 4 received


everybody on holiday?

Reply With Quote
 
  #4 (permalink)
Trading Apprentice
Frankfurt / Germany
 
Futures Experience: Intermediate
Platform: NT, MC
Favorite Futures: Stocks, Futures
 
sagetrade's Avatar
 
Posts: 47 since Jul 2013
Thanks: 28 given, 10 received

would also appreciate qualified comments to this thread

Reply With Quote
 
  #5 (permalink)
Trading Apprentice
Vienna Austria
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 8 since Jul 2013
Thanks: 2 given, 6 received

This has less to do with position sizing, the problem is that ninja (and most of the other retail software) cannot calculate PnL for FX. It was made under the assumption that (like with stocks or futures) the tick-value of an instrument is constant, while in FX it will fluctuate in $-terms for pairs that are not quoted in US Dollars (like usd/jpy).

For realtime, you could calculate it yourself, but for backtesting its more difficult. Bottom-line is Ninja needs to support multi-currrency portfolios on a realtime and historical basis. Not sure if this is part of 8.0. Probably not, i am always surprised that so few people complain about such a glaring defect.

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
Frankfurt / Germany
 
Futures Experience: Intermediate
Platform: NT, MC
Favorite Futures: Stocks, Futures
 
sagetrade's Avatar
 
Posts: 47 since Jul 2013
Thanks: 28 given, 10 received


sburtt View Post
Hi there,
...but the traditional position sizing tools that you find browsing around in the forum or in the NT forum work fine for futures but not for FX.

Which tools are your referring to?

Reply With Quote
The following user says Thank You to sagetrade for this post:
 
  #7 (permalink)
Vendor self-promotion
Cyprus
 
Futures Experience: Intermediate
Platform: Multicharts
Favorite Futures: ES
 
Posts: 68 since Jul 2013
Thanks: 15 given, 18 received


Pippi View Post
This has less to do with position sizing, the problem is that ninja (and most of the other retail software) cannot calculate PnL for FX. It was made under the assumption that (like with stocks or futures) the tick-value of an instrument is constant, while in FX it will fluctuate in $-terms for pairs that are not quoted in US Dollars (like usd/jpy).

I thought for standard lots the pip value is constant. At least I have not seen any change in for EUR/USD

Reply With Quote
The following user says Thank You to solotrader for this post:
 
  #8 (permalink)
Elite Member
Israel
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: pfg
Favorite Futures: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 206 received

Actually I've done it a long time ago.
I don't remember all the nuances.
Its a lot of code in different places.
 
Code
In Initialize()
//Series 1 
			if (BarsPeriod.Id == PeriodType.Minute && BarsPeriod.Value >= 5) Add(PeriodType.Minute, 1);
			else Add(PeriodType.Tick, 10);
//Series 2 For Currencies
			if (InstrType == "Currency")
			{
				CalculateSize = true;
				if (UseASK && BackTest) 
				{
					LEntrShExitOnBar = 2;
					Add(Instrument.FullName, PeriodType.Minute, 1, MarketDataType.Ask);
				}

				CurInstrument = TInst.ToString();
				USDQuote = GetUSD ();
				if (USDQuote == "") 
				{
					if (CurInstrument.Substring(0,3) == "USD") ConvertMethod = 2;
					else ConvertMethod = 1;
				}
				else if (USDQuote.Substring(0,4) == "$USD") ConvertMethod = 4;
				else ConvertMethod = 3;
				if (ConvertMethod > 2) 
				{
	//Series 3 Not Always
					Add(USDQuote, PeriodType.Minute, 30);
					if (UseASK && BackTest) USDSerie = 3;
					else USDSerie = 2;
				}
			}

In OnBarUpdate()
				if (Position.MarketPosition == MarketPosition.Flat)
				{
					if (Direction == 1)
					{
						EntryPrice = CalcLongEntry();
						SLPrice = CalcLongSL();
						PTPrice = CalcLongPT();
						GoodRR = true;
						if (PTPrice > 0 && (PTPrice - EntryPrice) / (EntryPrice - SLPrice) < (double)RRRatio / 100) GoodRR = false;
						if (GoodRR && Close[0] < EntryPrice)
						{
							if (CalculateSize) EntrySize = GetLotSize4(AccountSize, rType.ToString(), Risk, EntryPrice, SLPrice, ConvertMethod, USDSerie);
							if (EntrySize > 0) entryOrder = EnterLongStop(LEntrShExitOnBar, true, EntrySize, EntryPrice, EntryName);
						}
					}
					else if (Direction == -1)
					{
						EntryPrice = CalcShortEntry();
						SLPrice = CalcShortSL();
						PTPrice = CalcShortPT();
						GoodRR = true;
						if (PTPrice > 0 && (EntryPrice - PTPrice)  / (SLPrice - EntryPrice) < (double)RRRatio / 100) GoodRR = false;
						if (GoodRR && Close[0] > EntryPrice)
						{
							if (CalculateSize) EntrySize = GetLotSize4(AccountSize, rType.ToString(), Risk, EntryPrice, SLPrice, ConvertMethod, USDSerie);
							if (EntrySize > 0) entryOrder = EnterShortStop(1, true, EntrySize, EntryPrice, EntryName);
						}
					}
					else if (entryOrder != null) CancelOrder(entryOrder);
				}

#region GetLotSize4
		public int GetLotSize4(double AccountSize, string rType, double Risk, double EntryPrice, double SLPrice, int ConvertMethod, int USDSerie)
		{
			double PipValue100K = 0;
			if (!Historical)
			{
				if (ConvertMethod == 1) PipValue100K = 100000 * TickSize; //$XXXUSD
				else if (ConvertMethod == 2) PipValue100K = 100000 * TickSize / Close[0]; //$USDXXX
				else if (ConvertMethod == 3) PipValue100K = 100000 * TickSize * Closes[USDSerie][0] / Close[0]; // USDSerie: $XXXUSD
				else if (ConvertMethod == 4) PipValue100K = 100000 * TickSize / Closes[USDSerie][0]; //USDSerie: $USDXXX
			}
			else PipValue100K = 10; // for backtesting
			int RiskSum = 0;
			if (rType == "Percent") RiskSum = (int)(AccountSize * Risk);
			else RiskSum = (int)Risk;
			double RiskPerTick = RiskSum / (Math.Abs(EntryPrice - SLPrice) / TickSize); 
			int Lots2Trade = (int)Math.Floor(RiskPerTick / (PipValue100K / 100)) * 1000;
//			if (Lots2Trade < 25000) Lots2Trade = 0;
			return Lots2Trade;
		}
#endregion
#region GetUSD
		public string GetUSD ()
		{
			string CurInstr = Instrument.FullName;
			if (CurInstr.Substring(4,3) == "CAD") return "$USDCAD";
			else if (CurInstr.Substring(4,3) == "CHF") return "$USDCHF";
			else if (CurInstr.Substring(4,3) == "JPY") 	return "$USDJPY";
			else if (CurInstr.Substring(4,3) == "NZD") return "$NZDUSD";
			else if (CurInstr.Substring(4,3) == "AUD") return "$AUDUSD";
			else if (CurInstr.Substring(1,3) == "EUR") return "$EURUSD";
			else return "";
		}
#endregion
Its not for newbies.

Baruch

Reply With Quote
The following 6 users say Thank You to baruchs for this post:
 
  #9 (permalink)
Trading Apprentice
Vienna Austria
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 8 since Jul 2013
Thanks: 2 given, 6 received


solotrader View Post
I thought for standard lots the pip value is constant. At least I have not seen any change in for EUR/USD

Its fixed $10 per pip per 100K lot for all XXX/USD pairs. But not for the others.

Looks like Baruchs' code is good for accurate position sizing. But as far as i can see, there is no way to make Ninja calculate PnL for a backtest this way and use it for performance calculations (which makes optimization results questionable in some cases). Same problem when you trade a portfolio of futures, for example ES and FDAX.

Reply With Quote
The following user says Thank You to Pippi for this post:
 
  #10 (permalink)
Elite Member
Israel
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: pfg
Favorite Futures: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 206 received


My calculations should work in BT too.
I don't use it because I don't see an advantage in it.

Reply With Quote
The following user says Thank You to baruchs for this post:

Reply



futures io > > > > > Position Sizing when trading Forex FX

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why position sizing matters sdonahue MTPredictor 3 September 19th, 2014 04:54 PM
AmiBroker Tiered Position Sizing dwitkin AmiBroker 9 April 9th, 2014 03:24 PM
Vant Tharp's Percent Volatility Position Sizing - FX equation - PLEASE ANYONE? fxhst329 Psychology and Money Management 5 November 16th, 2012 11:58 PM
Position Sizing by Van Tharp Laserdan Psychology and Money Management 21 July 8th, 2011 11:37 AM
Position sizing codes ptcm EasyLanguage Programming 2 January 2nd, 2011 04:24 PM


All times are GMT -4. The time now is 04:56 PM.

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-11 in 0.14 seconds with 19 queries on phoenix via your IP 54.226.132.197