# Creating Orders Based on a Fixed Transaction Value

## Recommended Posts

Hello Jerry,

I would like to ask you if it is possible to set a desired transaction value, so that each time that an order is placed, the number of shares reflects the desired transaction value.

For example:

For Example:

- Desired Transaction Value: 5000\$

- Stock Price: 5\$

- The Trading capsule (if market order) is already set to 1000 shares. Or if alternatively, I wanna place a limit order at 4.80\$ the trading capsule would automatically update to 1040 shares.

I have seen there is this option (photo below). But when I then try to place an order on the chart, the default quantity in the trading capsule does not reflect the transaction value required.

Thank you very much for your help

Davide

##### Share on other sites

that is not available - the account level setting is applied at the time the trade ticket is loaded, or in case of charts, at the time symbol is loaded

##### Share on other sites

Thanks for the reply Jerry. Would it possible to have an indicator that shows the level of shares to buy given these three variables:

- Desired Trasaction Value

- Maximum Amount Willing to Lose

- Risk, expressed maybe as a percentage

So the formula to calculate the position size would be Maximum Amount Willling to Lose / Risk % (applied to the price of the stock).

For example:

Current Price: 5\$

Maximum Amount WIlling to Lose: 250\$

Risk%: 5%

This would give a Number of shares to buy equal to 1000.

Is it possible to create a similar indicator to put on the chart?

##### Share on other sites

You could make a paintbar that calculates this. Simple code like this

var MaxLoss = 250;
var RiskPercent = 5;
var Amt = Math.Floor(MaxLoss / (RiskPercent*0.01) / Close);

SetColor(Color.Yellow);
SetYValue(Amt);

Then show the paintbar on the bottom chart.

##### Share on other sites

Thank you very much Mike.

I try do it.

##### Share on other sites

Mike,

I am not an expert in coding. I have tried to paste the formulas you gave me in the advanced paintbar, but it gives me the following error

Would you be able to help me?

Thank you

##### Share on other sites

when MT converted a simple paintbar to advanced, it had the Main function declaration. Seems that you removed it. It is required

##### Share on other sites

This is the screenshot that I get when swithcing to Advanced Paintbar, from simple

Where should I put the code?

Thanks

delete the
if (....

; // ...

Thank you Jerry

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.