Hi there,
There is this code from http://www.earnforex.com/position-size-calculator. Is the function that calculate risk and position size from their indicator.
Wlhat is the purpose of the TICKSIZE? On XXXJPY it returns .001 but on other pairs it returns 0. The help doco says it returns the tick size in the quote currency. I thought that'd mean it returns .001 or .0001. Is this not the case? If not, how is it being used above? I have attached the full .mq4 file just in case.
Thanks.
P.S. The full .mq4 file code is included below just in case.
The help doco says it returns the tick size in the quote currency.
No it doesn't
You are confusing TickSize and TickValue
Hi there,
There is this code from http://www.earnforex.com/position-size-calculator. Is the function that calculate risk and position size from their indicator.
Wlhat is the purpose of the TICKSIZE? On XXXJPY it returns .001 but on other pairs it returns 0. The help doco says it returns the tick size in the quote currency. I thought that'd mean it returns .001 or .0001. Is this not the case? If not, how is it being used above? I have attached the full .mq4 file just in case.
Thanks.
P.S. The full .mq4 file code is included below just in case.
Show your code that returns a value for ticksize
If it only prints to 4 digits, what would 0.00001 return?
Hi there,
This is what my code returns for tick size. Note: I had to update my build due to new release from broker.
The doco says tick size is "Tick size in points".
For YEN pairs it is .001 and for others it is different as shown below.
Can someone please tell me this is used to calculate position size in the first post? As I'm not a programmer am having difficult getting my head around this..
2014.03.18 23:56:43.527 MyScript EURJPY,Daily: Pair: EURJPY 2014.03.18 23:56:43.527 MyScript EURJPY,Daily: Tick size: 0.001 2014.03.18 23:56:43.527 MyScript EURJPY,Daily: Tick value: 1.080660499697415 2014.03.18 23:56:30.202 MyScript USDJPY,Daily: Pair: USDJPY 2014.03.18 23:56:30.202 MyScript USDJPY,Daily: Tick size: 0.001 2014.03.18 23:56:30.202 MyScript USDJPY,Daily: Tick value: 1.080788975952445 2014.03.18 23:56:08.416 MyScript AUDUSD,Daily: Pair: AUDUSD 2014.03.18 23:56:08.416 MyScript AUDUSD,Daily: Tick size: 1e-005.0 2014.03.18 23:56:08.416 MyScript AUDUSD,Daily: Tick value: 1.097441863017307 2014.03.18 23:55:52.910 MyScript EURGBP,Daily: Pair: EURGBP 2014.03.18 23:55:52.910 MyScript EURGBP,Daily: Tick size: 1e-005.0 2014.03.18 23:55:52.910 MyScript EURGBP,Daily: Tick value: 1.81942 2014.03.18 23:50:20.682 MyScript EURUSD,Daily: Pair: EURUSD 2014.03.18 23:50:20.682 MyScript EURUSD,Daily: Tick size: 1e-005.0 2014.03.18 23:50:20.682 MyScript EURUSD,Daily: Tick value: 1.097815347458558
Thanks!
Jimdandy, haven't I watched youtube vids of yours?!
I've updated the TICKSIZE with DoubletoStr.
When I drop the script on EURUSD this is the output.
"AUDUSD:" should read "AUDUSD Ask Price".
The Position Size Calculator online (http://www.earnforex.com/position-size-calculator) where I got the code from outputs:
The position size in my output is .003 whereas online it's .274.
The code I used to generate my results are below:
double RiskPercent=.03; double RiskPips=50; double RiskMoney=5000*RiskPercent; double TickSize=0; double UnitCost=0; double PositionSize=0; void CalculatePositionSize() { UnitCost=MarketInfo(Symbol(),MODE_TICKVALUE); TickSize=MarketInfo(Symbol(),MODE_TICKSIZE); PositionSize = (RiskMoney / (RiskPips * UnitCost / TickSize))*100;//Multiplied by 100 to move decimal to left 2 places. Print("Pair: ",Symbol()); Print("Tick value: ", DoubleToStr(UnitCost,Digits)); Print("Tick size: ",DoubleToStr(TickSize,Digits)); Print("AUDUSD: ",MarketInfo("AUDUSD",MODE_ASK)); Print("PositionSize: ", DoubleToStr(PositionSize,3)); //where RiskMoney = The amount of money being risked on the trade. //StopLoss = RiskPips i.e. The number of pips between the EntryLevel and stop-loss level. //UnitCost = The tick value in the deposit currenty //TickSize = The tick size in points. }//End CalculatePositionSize
Can you please explain why my position size is not right i.e. the same as the online calculator?
Jimdandy, haven't I watched youtube vids of yours?!
I've updated the TICKSIZE with DoubletoStr.
When I drop the script on EURUSD this is the output.
"AUDUSD:" should read "AUDUSD Ask Price".
The Position Size Calculator online (http://www.earnforex.com/position-size-calculator) where I got the code from outputs:
The position size in my output is .003 whereas online it's .274.
The code I used to generate my results are below:
Can you please explain why my position size is not right i.e. the same as the online calculator?
- RaptorUK: Shouldn't you be using TickValue instead of TickSize ?No you must use BOTH value and size as a ratio
- PositionSize = (RiskMoney / (RiskPips * UnitCost / TickSize))*100;//Multiplied by 100 to move decimal to left 2 places.
Don't hard code numbers (100 = 1/pips2dbl on JPY)
RiskMoney = (AccountBalance * percent) = risk = RiskPips * pips2dbl * UnitCost / TickSize * lotsize
RiskPips must include the spread because OrderOpenPrice - OrderStopLoss does.
Solve for lotsize and normalize properly
Jimdandy, haven't I watched youtube vids of yours?!
I've updated the TICKSIZE with DoubletoStr.
When I drop the script on EURUSD this is the output.
"AUDUSD:" should read "AUDUSD Ask Price".
The Position Size Calculator online (http://www.earnforex.com/position-size-calculator) where I got the code from outputs:
The position size in my output is .003 whereas online it's .274.
The code I used to generate my results are below:
Can you please explain why my position size is not right i.e. the same as the online calculator?
UnitCost=MarketInfo(Symbol(),MODE_TICKVALUE); TickSize=MarketInfo(Symbol(),MODE_TICKSIZE); PositionSize=(RiskMoney)//Multiplied by 100 to move decimal to left 2 places. //What are we risking here? RiskMoney=5000*RiskPercent so 150 PositionSize=(150/(RiskPips*UnitCost); //UnitCost=MarketInfo(Symbol(),MODE_TICKVALUE) which is the value of a 1 tick move in the account currency //RiskPips =50 so we now have PositionSize=(150/(50*1 tick move)); //Hang on - a 1 tick move is not the same as a 1 pip move as the symbol has 5 digits. so we now have PositionSize=(150/(5*1 pip move); //So we obviously have to multip[ly this value by 10 PositionSize=(150/(5*1 pip move/TickSize)*100; //TickSize is 0.00001, divide 5 by 0.00001 and you end up with 500,000 //Multiply by 100 and you are now at 5,000 PositionSize=(150/(5,000*1 pip move); //You intended to work out the position size for a 50 pip move, but calculated for a 5,000 pip move //100 times bigger so your calculations will arrive at the online calculator's vaue/100
- RaptorUK: Shouldn't you be using TickValue instead of TickSize ?No you must use BOTH value and size as a ratio
- PositionSize = (RiskMoney / (RiskPips * UnitCost / TickSize))*100;//Multiplied by 100 to move decimal to left 2 places.
Don't hard code numbers (100 = 1/pips2dbl on JPY)
RiskMoney = (AccountBalance * percent) = risk = RiskPips * pips2dbl * UnitCost / TickSize * lotsize
RiskPips must include the spread because OrderOpenPrice - OrderStopLoss does.
Solve for lotsize and normalize properly
Are you saying the code should look like this?
double RiskPercent=.03; double RiskPips=50; double RiskMoney=5000*RiskPercent; double TickSize=0; double UnitCost=0; double PositionSize=0; double pips2dbl = 10; UnitCost=MarketInfo(Symbol(),MODE_TICKVALUE); TickSize=MarketInfo(Symbol(),MODE_TICKSIZE); PositionSize = (RiskMoney / (RiskPips * UnitCost * pips2dbl / TickSize));
This produced the following results:
Or this?
double RiskPercent=.03; double RiskPips=50; double RiskMoney=5000*RiskPercent; double TickSize=0; double UnitCost=0; double PositionSize=0; double pips2dbl = 10; UnitCost=MarketInfo(Symbol(),MODE_TICKVALUE); TickSize=MarketInfo(Symbol(),MODE_TICKSIZE); PositionSize = (RiskPips * UnitCost * pips2dbl / TickSize * RiskMoney);
Which produces..
Thanks.
Are you saying the code should look like this?
PositionSize = (RiskMoney / (RiskPips * UnitCost * pips2dbl / TickSize));
Or this?
PositionSize = (RiskPips * UnitCost * pips2dbl / TickSize * RiskMoney);
I said solve for lotsize RiskMoney = (AccountBalance * percent) = risk = RiskPips * pips2dbl * UnitCost / TickSize * lotsize Doesn't that result in: lotsize = RiskMoney / (RiskPips * pips2dbl * UnitCost / Ticksize) double pips2dbl = 10;
pips2dbl is not 10. On a 3/5 digit broker it is 10 * Point. Didn't you follow the link previously posted?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
There is this code from http://www.earnforex.com/position-size-calculator. Is the function that calculate risk and position size from their indicator.
Wlhat is the purpose of the TICKSIZE? On XXXJPY it returns .001 but on other pairs it returns 0. The help doco says it returns the tick size in the quote currency. I thought that'd mean it returns .001 or .0001. Is this not the case? If not, how is it being used above? I have attached the full .mq4 file just in case.
Thanks.
P.S. The full .mq4 file code is included below just in case.