I am trying to find a way to set the stop loss and the profit target at a whole number.
For instance, if I bought "x" shares at "x" price(let's say 25.54$) and I want to set a stop loss at the low whole number(25$) and I want to set the profit target(26$) at the next whole number.
How can I make the code that tests whether or not "close" is a whole number?
How to set stop loss/profit on a whole number? [SOLVED]
- TJ
- Posts: 7746
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2225 times
Re: How to set stop loss/profit on a whole number? [SOLVED]
Look up:I am trying to find a way to set the stop loss and the profit target at a whole number.
For instance, if I bought "x" shares at "x" price(let's say 25.54$) and I want to set a stop loss at the low whole number(25$) and I want to set the profit target(26$) at the next whole number.
How can I make the code that tests whether or not "close" is a whole number?
IntPortion
- TJ
- Posts: 7746
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2225 times
Re: How to set stop loss/profit on a whole number?
Please be precise on how you want to manipulate the numbers. Can you give an example?Hello,
Please ,and how to set target profit on round number, for example, the currency pair EUR / USD
1.33 1.335 1.34 1.345 and so on?
I cannot decipher your intention regarding "1.33 1.335 1.34 1.345".
- TJ
- Posts: 7746
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2225 times
Re: How to set stop loss/profit on a whole number?
These keywords might help:
Round
FracPortion
Factorial
Floor
Ceiling
Mod
MaxList
MinList
Round
FracPortion
Factorial
Floor
Ceiling
Mod
MaxList
MinList
Re: How to set stop loss/profit on a whole number?
For example, if we traded euro fx and buy 1 contract for example at price 1.332 .
Profittarget want to place your up nearest rounded number 1.335 and stoploss your down nearest rounded number 1.330 .
Assuming that the round number as an every number increased by 0.005
or reduced by 0.005
Profittarget want to place your up nearest rounded number 1.335 and stoploss your down nearest rounded number 1.330 .
Assuming that the round number as an every number increased by 0.005
or reduced by 0.005
- TJ
- Posts: 7746
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2225 times
Re: How to set stop loss/profit on a whole number?
1) First, multiply the number by 100For example, if we traded euro fx and buy 1 contract for example at price 1.332 .
Profittarget want to place your up nearest rounded number 1.335 and stoploss your down nearest rounded number 1.330 .
Assuming that the round number as an every number increased by 0.005
or reduced by 0.005
1.332 x 100 = 133.2
2) next, use IntPortion to remove the decimal place
3) divide the number by 100 to get back your 1.330
4) you can then add or subtract your 0.005 target.