How to set stop loss/profit on a whole number?  [SOLVED]

Questions about MultiCharts and user contributed studies.
treksis
Posts: 13
Joined: 18 Jul 2014
Has thanked: 4 times

How to set stop loss/profit on a whole number?

Postby treksis » 01 Aug 2014

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?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to set stop loss/profit on a whole number?  [SOLVED]

Postby TJ » 01 Aug 2014

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?
Look up:

IntPortion

monexx
Posts: 87
Joined: 20 Feb 2014
Has thanked: 26 times
Been thanked: 7 times

Re: How to set stop loss/profit on a whole number?

Postby monexx » 02 Aug 2014

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?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to set stop loss/profit on a whole number?

Postby TJ » 02 Aug 2014

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?
Please be precise on how you want to manipulate the numbers. Can you give an example?
I cannot decipher your intention regarding "1.33 1.335 1.34 1.345".

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to set stop loss/profit on a whole number?

Postby TJ » 02 Aug 2014

These keywords might help:

Round
FracPortion
Factorial
Floor
Ceiling
Mod
MaxList
MinList

monexx
Posts: 87
Joined: 20 Feb 2014
Has thanked: 26 times
Been thanked: 7 times

Re: How to set stop loss/profit on a whole number?

Postby monexx » 04 Aug 2014

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

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to set stop loss/profit on a whole number?

Postby TJ » 04 Aug 2014

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
1) First, multiply the number by 100

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.


Return to “MultiCharts”