Page 1 of 1

GenerateStopLoss amount argument

Posted: Nov 21 2013
by gvandenbosch
Hi,

I want to set a stoploss according to an input.
For example on a session the loss is set to 1 dollar. Then I want to put the stoploss on the Bars price minus the stop loss.

I found this page https://www.multicharts.com/trading-sof ... ial_Orders describing the formula that calculate from amount to a price.

So in order to get the amount I want to pass with the GenerateStopLoss function I came up with this:

Code: Select all

this.dStopAmount = (dStopPrice - dClosePrice) * Bars.Info.BigPointValue;
However it generate the stop much earlier than the price I set.
Can someone give me a pointer what I am doing wrong?

Re: GenerateStopLoss amount argument

Posted: Nov 21 2013
by JoshM
(..)
However it generate the stop much earlier than the price I set.
Can someone give me a pointer what I am doing wrong?
That depends on which conditions trigger the stop-loss order submittance; you now have only shown how you calculate the stop amount, but not when these orders are send.

Re: GenerateStopLoss amount argument

Posted: Nov 21 2013
by gvandenbosch
I do the calculation once and then save it in an object property (this.dStopAmount).

Then on every calcbar I do:

Code: Select all

GenerateStopLoss(this.dStopAmount);

Re: GenerateStopLoss amount argument

Posted: Nov 21 2013
by JoshM
I do the calculation once and then save it in an object property (this.dStopAmount).

Then on every calcbar I do:

Code: Select all

GenerateStopLoss(this.dStopAmount);
If I look at the examples from the page you mentioned in your first post, I see methods that have parameters with positive values.

This calculation will not always return positive values:

Code: Select all

this.dStopAmount = (dStopPrice - dClosePrice) * Bars.Info.BigPointValue;
Try this instead:

Code: Select all

dStopAmount = Math.Abs(dStopPrice - dClosePrice) * Bars.Info.BigPointValue;
..
..
GenerateStopLoss(dStopAmount);

Re: GenerateStopLoss amount argument

Posted: Nov 21 2013
by gvandenbosch
It is not helping. I have made the stop price 1 dollar higher than closeprice.

But this is the result:
Image

It just has a few cents difference.

Re: GenerateStopLoss amount argument

Posted: Nov 22 2013
by JoshM
It is not helping. I have made the stop price 1 dollar higher than closeprice.

(..)

It just has a few cents difference.
Have you set CurSpecOrdersMode to PerPosition or PerContract? See information about that here.

Re: GenerateStopLoss amount argument

Posted: Nov 22 2013
by gvandenbosch
It is on PerPosition, should this be PerContract to reach my goal?

Re: GenerateStopLoss amount argument

Posted: Nov 22 2013
by JoshM
It is on PerPosition, should this be PerContract to reach my goal?
Based on what I understand from your goal, it should be on PerContract.

Re: GenerateStopLoss amount argument

Posted: Nov 25 2013
by Henry MultiŠ”harts
Hi,

I want to set a stoploss according to an input.
For example on a session the loss is set to 1 dollar. Then I want to put the stoploss on the Bars price minus the stop loss.

I found this page https://www.multicharts.com/trading-sof ... ial_Orders describing the formula that calculate from amount to a price.

So in order to get the amount I want to pass with the GenerateStopLoss function I came up with this:

Code: Select all

this.dStopAmount = (dStopPrice - dClosePrice) * Bars.Info.BigPointValue;
However it generate the stop much earlier than the price I set.
Can someone give me a pointer what I am doing wrong?
Hello gvandenbosch,

We were unable to replicate this behavior with the formula. It works as expected on our end.
Image

Re: GenerateStopLoss amount argument  [SOLVED]

Posted: Nov 25 2013
by gvandenbosch
Thanks for the replies.

Changing it from PerPosition to PerContract and adding the Math.Abs helped solving the problem.
It is working as expected now.