Position size in forex

Hello,

Hope you are doing well during the pandemic.
Suppose I have an account with $100,000 capital and the broker provides a 1:100 leverage. In each trade I want to risk 1% of capital ($1000). I searched in the forum about size of positions in the forex market but I still couldn't find what I am exactly looking for. I would appreciate it if could help me with the following question:

When I want to define the volume which I should buy, first I calculate the difference between the entry point and stop-loss (based on points in MT5). Then, I divide the amount I am going to invest or put in risk ($1000) by the difference. For example, in the below pic I want to entre at 0.94390 and put my stop-loss at 0.94096. So, the volume (position size) should be $1000 / 294 points = 3.40 (with two decimals).

Note: I know that it is not an exact definition to find the volume and it depends and the point value and commission but here I assumed that the point value is $10 (in other words, if I trade one lot ($100,000) from AUDCAD and the price changes one pip (TickSize = 0.0001), it worths $10 (PointValue = 10).

Now, if I buy 3.40 lot of AUDCAD at 0.94390 and then the price goes down to the 0.94096, I will lose $1000.

image

Based on the below link, I defined a trailing stop loss which is 20 pips lower than the low of the candle:
http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/

SetOption("InitialEquity", 100000 );
settradedelays( 0, 0, 0, 0 );
//PointValue = 10;      // determines the amount of profit generated by one contractfor a one point increase in price. 
                      // represents value of profit/loss by 1 full point price movement.
//MarginDeposit = 1000; // in most cases should be set to 1000 (1% margin from $100’000)
TickSize = 0.0001;    // This setting controls the minimum price move of given symbol. 
RoundLotSize = 0;     // If default size is set also to zero it meansthat fractional number of shares/contracts are allowed.

PositionSize = 1000 / ( ( (C - L - 0.002) / TickSize ) * 10);
//SetPositionSize(PctSize, spsShares);


//=============================================================================================================================

Buy = Cross( C, MA( C, 20 ) );
Sell = 0;
trailARRAY = Null;
trailstop = 0;

//StopLevel = 1 - Param("trailing stop %", 3, 0.1, 10, 0.1)/100;
StopLevel = 0.002;

for( i = 1; i < BarCount; i++ )
{

   if( trailstop == 0 AND Buy[ i ] ) 
   { 
      //trailstop = High[ i ] * stoplevel;
      trailstop = Low[i] - StopLevel;
   }
   else Buy[ i ] = 0; // remove excess buy signals

   if( trailstop > 0 AND Low[ i ] < trailstop )
   {
      Sell[ i ] = 1;
      SellPrice[ i ] = trailstop;
      trailstop = 0;
   }

   if( trailstop > 0 )
   {
      //trailstop = Max( High[ i ] * stoplevel, trailstop );
      trailstop = Max( Low[i] - StopLevel, trailstop );
      trailARRAY[ i ] = trailstop;
   }

}


PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0, L, Offset = -10);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0, L, Offset = -20);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0, L, Offset = -15);

PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset = 10);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset = 20);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0, H, Offset = -15);

Plot( Close,"Price",colorBlack,styleBar);
Plot( trailARRAY,"trailing stop level", colorRed );

I applied the above-mentioned code on my chart and based on the formulation I expect to find a 3.4 lot for size of position on 2020-09-28 entry and a profit of around 3% but I cannot get that result.

image

This is the setting of my backtest:
image
image
image

and here you can find the report of the backtest:
image
image

I also tried the following sample codes in the following link but I cannot find the 3.40 in the shares and profit of around 3% for long entry on 2020-09-28. I don't understand what is wrong?
http://www.amibroker.com/kb/2014/10/12/position-sizing-based-on-risk/

I would deeply appreciate if you could help me. Thanks a million in advance.

Best regards,

1 Like

If you post duplicates like this: https://forum.amibroker.com/t/re-position-size-in-forex-market/22401 it is considered forum vandalism and you are unlikely to get any answer because forum participants don't appreciate such behavior

3 Likes

Thanks for reminding me but I mistakenly post it in the AmiBroker forum, so I deleted it and repost it in the AFL programming. I am sorry for that.

Dear @Tomasz,

Could you please help me with this question? Thanks in advance for your help.

Best regards,

Search the forum - there are existing threads on very same subject.

2 Likes

I already did but I will do it one more time. I will get back to you if I couldn't find it. Thank you for your reply.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.