-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
42 lines (31 loc) · 1.12 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
let guess
let capital = document.getElementById("capital");
let risk = document.getElementById("risk");
let entry = document.getElementById("entry");
let stopLoss = document.getElementById("stoploss");
const getTotal = document.getElementById("calculate");
const positionSize = document.getElementById("pSize");
getTotal.addEventListener("click", calculatePosition);
function calculatePosition() {
if (!capital.value || !risk.value || !entry.value || !stopLoss.value) {
pSize.style.color = "red"
pSize.innerHTML = "Fill The Details First!";
} else {
let percentRisk = risk.value/100;
if(percentRisk > 0.25){
swal("Seriously!","Serious Traders only risk 1% - 5%", "warning")
}
let x = +capital.value * +percentRisk;
let y = +entry.value - +stopLoss.value;
if(entry.value< stopLoss.value){
guess = 'Short'
}else{
guess = 'Long'
}
let z = x / y;
let total = z * +entry.value;
total = Math.abs(Math.round(total))
pSize.style.color = "green"
pSize.innerHTML = "Your position size is : " + total + ' USDT'+ '<br> Good Luck With Your ' + guess
}
}