Beta-Testers needed for SPOT FX Position Size indie. USD account only right now. - futures io
futures io futures trading



Beta-Testers needed for SPOT FX Position Size indie. USD account only right now.


Discussion in NinjaTrader

Updated
    1. trending_up 1,401 views
    2. thumb_up 4 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

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

 
Search this Thread
 

Beta-Testers needed for SPOT FX Position Size indie. USD account only right now.

(login for full post details)
  #1 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received

Howdy,

So, position sizing is a PITA in FX, imo. Especially when sizing for anything outside of your BASE currency matching the quote Pair...

E.g., if account is in USD, and you are trading Eur/Usd, that is easy as the calculation is simply: ($Risk/Stop) * (1/pipSize)... where pipSize is 0.0001, unless its a JPY pair, then its 0.01.

It gets more complicated when the account has the match in the base currency.
E.g., if account is in USD, and you're trading Usd/Jpy, then the calculation is:
((USD/JPY price*$Risk)/Stop) * (1/pipSize)

It gets even more complicated when account currency is present in neither the base or quote currency.

The formula is either:
(($Risk/exchangePrice)/StopSize) * (1/pipSize)
OR
(($Risk*exchangePrice)/StopSize) * (1/pipSize)

Which to use depends on if the quote currency leads or lags in the pairs that match your account currency...

If all of this sounds confusing, it is because it is... either that or you're already a FX size ninja and none of this matters to you. In any case, that's why I built the indie.

But... if anyone here is interested in testing an indicator to position size, I will post it here, as I need some feedback, as this isn't one I just want to release into the wild, in the downloads section until I can verify it works properly.

So for right now... it is only for those with USD-based accounts.

Secondly, the list is limited as it sits right now. But if one is willing to beta test, and has a few pairs they want to see, I can append them to the current list.

Thirdly, right now, the indie is a bit cumbersome, as you have to manually open the User Input screen, and type your values in.

Future plans is that I want to make the first 3 columns input fields, ON THE CHART, so this step is no longer necessary, but I haven't figured that out yet. The attached image gives an idea of what the indie looks like on chart, plus what I plan on doing in the future with the input fields ON-CHART.

The other thing I'd like want to do is either release different versions for different base accounts(EUR, GBP, etc...). Either that or make it universal. The only reason to release separate versions, is that it requires loading in various other symbols, to get other closing prices. So the less you need to load, the better/faster it works.

This will go into the second panel, just drag the size of the panel all the way up so you can see all the pairs better. I recommend you put it on a Daily or higher chart, as there is no reason for it to even run on each bar, as you only need to calculate it when you are looking to trade.

Tool is simple, doesn't set size or anything, it's just a calculator. So you enter your account dollar value, the risk you are willing to take in dollar value, and the stop size in pips you desire. It then tells you what that dollar risk is, and the trade size in units.

I have each input for each symbol separately, as that's how I usually like to see it, as I trade many different pairs at once, and I don't want to have all the values change as my balance changes... so I like them all individually accounted.

Comments or suggestions welcome.

Position size calculator on babyPips HERE.


-----EDIT 30DEC2020-----
I realized I may not have made my first post clear with all my rambling. But the indicator works as-is now. If you are interested, post here, and I'll DM you the indicator for testing.

Attached Thumbnails
Click image for larger version

Name:	2020-12-19_121440.png
Views:	80
Size:	75.7 KB
ID:	307553  
Started this thread Reply With Quote
The following user says Thank You to forrestang for this post:

Can you help answer these questions
from other members on futures io?
Work with historical tcks data on MUltichart NET PowerLa …
MultiCharts
COTbase for quant trading?
Elite Algorithmic NinjaTrader Trading
Neurological explanations for trading Success
Psychology and Money Management
NT8 indicator to simulate a Funding Evaluation where to …
NinjaTrader
What blockvolume is visible? - order processing
NinjaTrader
 
 
(login for full post details)
  #2 (permalink)
Jacksonville, Florida United States
 
Experience: Intermediate
Platform: NT8 + Custom
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
 
Jasonnator's Avatar
 
Posts: 126 since Dec 2014
Thanks: 37 given, 119 received

There is definitely a way to do this and to make it fully automated. It's been years since I've worked with FX and I remember some of the frustrations you're describing. I'm going to see if I can dig up some of my old coding projects to help you out. For starters, these are some of the things I did to solve some of the issues you describe.

1) FX has a sort of seniority or rank. For example, when creating any pair, EUR is always going to be the dominant currency. I remember I picked the 8-12 most common currencies and hard coded their precedence (EUR - 0, GPB - 1, USD - 2, etc.). With that, I could dynamically generate all possible permutations of pairs. I put all of those in a list so I could look them up later. So for example, if you need the cross between EUR/USD and GBP/USD, you'd end up with EUR/GBP which would be represented as "0 / 1". Since EUR is the highest precedence, you know it'll come first and GBP being a lower precedence, it will be in the denominator.

2) Symbol verification. Once you have a symbol (FX pair) you want to get a bid or ask price for, you'll need to use the look up list from #1 above and try to get a price. This will need to be wrapped in a try catch block in case you accidentally try to get a bid or ask for an invalid pair.

3) Once you have your price, you're probably going to need to do some conversions to whatever currency you are dealing with primarily. This is mainly what I need to search for to see if I still have (50/50 shot). The conversion will require the tick value or point value from the NT MasterInstrument property. I think point value will work here but am not 100% sure.

4) Determine your risk. You've already done some of the work here but you mentioned wanting it on the chart. It wouldn't be too terribly hard to use a WPF control and databind it to a property in your indicator. MVVM works fine with NT8 but bring along its own learning curve.

Quick note which I'm super hesitant to even bring up but I will just in case. If you're trying to figure out position sizing for arbitrage, stop now and save yourself tons of time. It cannot be done with NT8. I really try not to ever say "trust me" but I have spent weeks/months trying to do it and NT8 is not capable of doing FX arbitrage for a multitude of reasons which could be their own post. It's an extremely capable platform but you'll simply be handing your money directly to purpose built, esoteric systems/hardware which operate on the nanosecond timescale.

I will keep your project in mind and post here as I come across code which may help you.

Reply With Quote
The following user says Thank You to Jasonnator for this post:
 
(login for full post details)
  #3 (permalink)
Jacksonville, Florida United States
 
Experience: Intermediate
Platform: NT8 + Custom
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
 
Jasonnator's Avatar
 
Posts: 126 since Dec 2014
Thanks: 37 given, 119 received


Wikipedia has the 8 most common currencies and their unofficial rank order, here.

Reply With Quote
The following user says Thank You to Jasonnator for this post:
 
(login for full post details)
  #4 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received

Thanks for checking in Jason. I probably did a bad job in describing it...

But I have already got it working. The chart that I showed above, it's a live chart, as in that's actually the indie working already. It calculates the position sizing properly.

Just to give you an idea of how I did it. For a USD based account, these are the symbols that are needed to be loaded:
 
Code
			else if (State == State.Configure)
			{
				AddDataSeries("AUDUSD"); 	
				AddDataSeries("EURUSD");	
				AddDataSeries("GBPUSD");	
				AddDataSeries("NZDUSD");
				AddDataSeries("USDCAD");	
				AddDataSeries("USDCHF");
				AddDataSeries("USDJPY");
                         }

Next there are 4 possibilities as described with calculating position sizing. That looks like this:
 
Code
		public int GetPositionSize( string accountCurrency, double myRisk, double myStop, string myPair)	
		{
			int lotSize = 0;
			string baseCurrency = myPair.Substring(0,3); 	//Gets first symbol in pair	
			string quoteCurrency = myPair.Substring(3,3); 	//Gets second symbol in pair+

			double decimalVal =0;			//Get Decimal Value	
			if(myPair.Contains("JPY") )		decimalVal = 0.01;
			else							decimalVal = 0.0001;	
			
		//Condition where accountCurrency == quoteCurrency(2) -> USD == EUR/USD
			if(accountCurrency == quoteCurrency)
				return lotSize = Convert.ToInt32( (myRisk/myStop) * (1/decimalVal) );	

		//Condition where accountCurrency == baseCurrency(1) -> USD == USD/JPY
			if(accountCurrency == baseCurrency)
			{
				switch(quoteCurrency)	
				{
					case "CAD":
						return lotSize = Convert.ToInt32( ((Closes[5][0] * myRisk) / myStop) * (1/decimalVal)  );
						break;
					case "CHF":
						return lotSize = Convert.ToInt32( ((Closes[6][0] * myRisk) / myStop) * (1/decimalVal)  );
						break;
					case "JPY":
						return lotSize = Convert.ToInt32( ((Closes[7][0] * myRisk) / myStop) * (1/decimalVal)  );
						break;
				}
			}
			
		//Condition where accountCurrency is NEITHER, but quoteCurrency(2) LEADS in Instrument LookUp List -> E.g., given symbol EUR/GBP, you need to use GBP/USD, where GBP leads or is baseCurrency
			if(accountCurrency != baseCurrency && accountCurrency != quoteCurrency )
			{
				switch(quoteCurrency)	
				{
					case "AUD":
						return lotSize = Convert.ToInt32( ((myRisk/Closes[1][0])/myStop) * (1/decimalVal) );
						break;
					case "EUR":
						return lotSize = Convert.ToInt32( ((myRisk/Closes[2][0])/myStop) * (1/decimalVal) );
						break;
					case "GBP":
						return lotSize = Convert.ToInt32( ((myRisk/Closes[3][0])/myStop) * (1/decimalVal) );
						break;
					case "NZD":
						return lotSize = Convert.ToInt32( ((myRisk/Closes[4][0])/myStop) * (1/decimalVal) );
						break;
				}
			}
			
		//Condition where accountCurrency is NEITHER, but quoteCurrency(2) LAGS in Instrument LookUp List -> E.g., given symbol CHF/JPY, you need to use USD/JPY, where JPY lags or is quoteCurrency
			if(accountCurrency != baseCurrency && accountCurrency != quoteCurrency )
			{
				switch(quoteCurrency)	
				{
					case "CAD":
						return lotSize = Convert.ToInt32( ((myRisk*Closes[5][0])/myStop) * (1/decimalVal) );
						break;
					case "CHF":
						return lotSize = Convert.ToInt32( ((myRisk*Closes[6][0])/myStop) * (1/decimalVal) );
						break;
					case "JPY":
						return lotSize = Convert.ToInt32( ((myRisk*Closes[7][0])/myStop) * (1/decimalVal) );
						break;
				}
			}			
			
			return lotSize;
			
			//This set of symbols should be sorted by AccountCurrency being EITHER base or Quote pair.
//				1 index) AddDataSeries("AUDUSD"); 	//AccountCurrency is quoteCurrency
//				2 index) AddDataSeries("EURUSD"); 	//AccountCurrency is quoteCurrency
//				3 index) AddDataSeries("GBPUSD"); 	//AccountCurrency is quoteCurrency	
//				4 index) AddDataSeries("NZDUSD"); 	//AccountCurrency is quoteCurrency
//				5 index) AddDataSeries("USDCAD"); 	//AccountCurrency is baseCurrency	
//				6 index) AddDataSeries("USDCHF"); 	//AccountCurrency is baseCurrency	
//				7 index) AddDataSeries("USDJPY"); 	//AccountCurrency is baseCurrency	
		}
Your #3 is one thing I should do, and that is some type of error-checking to be sure that the end-user's platform actually loads in the pairs needed to do that conversion. I noted a slight bug the other day, as I was loading this with daily data, and for some reason my broker didn't give me daily data that day, and I was scratching my head trying to figure out what the problem was? Turns out, loaded up a 240min chart, and worked fine. So yeah, needs some error-checking to be sure it loads in those 7 data series coded above.

The thing that I want to do... is turn those first for columns shown in the image, into text fields. As is right now... to modify the values, you have to open the user-input screen which is cumbersome. It would be nice if they were text-fields, ON-CHART, so you could just type them in, without having to open the user input screen.

OR... Like I mentioned in YOUR thread... I may want to turn this into an add-on, as I think an add-on would lend itself really well to a position size calculator.

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received

Also... for anyone else curious, I was looking for beta testers... as the indie already works. If interested, post here and I'll DM you the indie. I just hadn't posted it here or in the downloads section, as it's not something I want in the wild yet. Looking for people who actually have a need for FX position sizing, who are actively trading, and would give useful feedback.

Started this thread Reply With Quote
 
(login for full post details)
  #6 (permalink)
 
 
Posts: 26 since May 2013
Thanks: 20 given, 18 received


forrestang View Post
Also... for anyone else curious, I was looking for beta testers... as the indie already works. If interested, post here and I'll DM you the indie. I just hadn't posted it here or in the downloads section, as it's not something I want in the wild yet. Looking for people who actually have a need for FX position sizing, who are actively trading, and would give useful feedback.

Hi @forrestang ,
If you have a NT7 code I could test It in the near future.

Cheers.

Don't hesitate, just trade!
Reply With Quote
The following user says Thank You to mzabarain for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Beta-Testers needed for SPOT FX Position Size indie. USD account only right now.


Last Updated on January 11, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 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