30 lines
865 B
JavaScript
30 lines
865 B
JavaScript
|
|
/**
|
||
|
|
* Free Trading Calculators
|
||
|
|
* Web versions: https://blog.quant-view.xyz/tools/
|
||
|
|
* Telegram: https://t.me/GFIL_Trading
|
||
|
|
* Discord: https://discord.gg/GMmMCD4MCr
|
||
|
|
*/
|
||
|
|
|
||
|
|
function positionSize(accountBalance, riskPercent, stopLossPips, pipValue = 10) {
|
||
|
|
const riskAmount = accountBalance * (riskPercent / 100);
|
||
|
|
return parseFloat((riskAmount / (stopLossPips * pipValue)).toFixed(2));
|
||
|
|
}
|
||
|
|
|
||
|
|
function pipValue(currencyPair, lotSize = 1) {
|
||
|
|
const rates = { "EURUSD": 10, "GBPUSD": 10, "USDJPY": 9.3, "XAUUSD": 10 };
|
||
|
|
return rates[currencyPair] * lotSize || 10;
|
||
|
|
}
|
||
|
|
|
||
|
|
function fibonacci(high, low) {
|
||
|
|
const diff = high - low;
|
||
|
|
return {
|
||
|
|
"0.236": high - diff * 0.236,
|
||
|
|
"0.382": high - diff * 0.382,
|
||
|
|
"0.500": high - diff * 0.500,
|
||
|
|
"0.618": high - diff * 0.618,
|
||
|
|
"0.786": high - diff * 0.786,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = { positionSize, pipValue, fibonacci };
|