How can I set initial profit and stoploss range in PL?  [SOLVED]

Questions about MultiCharts and user contributed studies.
phobos
Posts: 2
Joined: 13 May 2013
Has thanked: 2 times

How can I set initial profit and stoploss range in PL?

Postby phobos » 13 May 2013

Before I start, I have to apologize for my pool english.

I want to set profit and loss in tick value as input statement and set them as initial profit and stoploss range.

Can anyone please help me to finish the statement?

Code: Select all

inputs : profitrange(20), lossrange(10); / 20 ticks for profit and 10 ticks for stoploss

if ....................then / order statement
buy;


setprofittarget( ); / set profit tick value in the blank
SetStopLoss( ); / set stoploss tick value in the blank

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

Re: How can I set initial profit and stoploss range in PL?  [SOLVED]

Postby TJ » 13 May 2013

Before I start, I have to apologize for my pool english.

I want to set profit and loss in tick value as input statement and set them as initial profit and stoploss range.

Can anyone please help me to finish the statement?

inputs : profitrange(20), lossrange(10); / 20 ticks for profit and 10 ticks for stoploss

if ....................then / order statement
buy;


setprofittarget( ); / set profit tick value in the blank
SetStopLoss( ); / set stoploss tick value in the blank
one tick equals to (minmove/pricescale).

You can code as follows:

Code: Select all

inputs : profitrange(20), lossrange(10); / 20 ticks for profit and 10 ticks for stoploss

if ....................then / order statement
buy;


setprofittarget( profitrange * minmove/pricescale * BigPointValue ); / set profit tick value in the blank
SetStopLoss( lossrange * minmove/pricescale * BigPointValue ); / set stoploss tick value in the blank

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

Re: How can I set initial profit and stoploss range in PL?

Postby TJ » 13 May 2013

ps. no need to apologise for your English; we are from all over the World.


ps. How to Post Codes
viewtopic.php?f=16&t=11713

phobos
Posts: 2
Joined: 13 May 2013
Has thanked: 2 times

Re: How can I set initial profit and stoploss range in PL?

Postby phobos » 13 May 2013

Thank you very much TJ. :-)

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

Re: How can I set initial profit and stoploss range in PL?

Postby TJ » 13 May 2013

alternatively you can code it like this:

Code: Select all

setprofittarget( profitrange * minmove * PointValue ); / set profit tick value
SetStopLoss( lossrange * minmove * PointValue ); / set stoploss tick value


Return to “MultiCharts”