please help
-
i am trying to use the lotsize based on the stoploss and the stoploss is 3 times the atr pips so whatever the stoploss is it just calculates and then risk 5 percent of the account depending on the stoploss
something like this
-
-
It should be integrated in the buy/sell block:

-
@miro1360 yes but the problem is, I want to display the calculated lot size on the chart before the trade is opened its kind of a partial automated system, and the trade is taken when I click on the button that I created, but before clicking on the button I want to k ow what will be the lot size of this particular trade
-
Money management calculations happen inside the block and they can't be accessed from outside. If you want to display some information and then use it in particular block, then you should make the calculations outside this block.
By the way, in the past I was thinking about a little bit different way of opening trades. To have one Trade block Instead of Buy and Sell blocks, and some other block for doing the SL/TP calculations, and another block for the lot size calculation. In other words, instead of having all-in-one block, to have multiple block, one for each step. But my reasoning for this is not to be able to get some data (lot size, sl, tp) before buying or selling. I was thinking about this so we can connect one chain of blocks and that chain to be able to work for the buy part and for the sell part. Because now very often we have the same sets of blocks for both sides.
-
@fxdreema thats a very good idea to have all these things in separate chain of blocks it will give us more flexibility and possibilities
and about my question i know i cant use the calculations from buy/sell blocks anywhere else and i will have to perform separate calculations to display that on chart , i dont know where to start that calculation -
The calculation is a little bit complicated, yes. This is mine:
size=((value/100)*AccountEquity())/(sl*((TickValue/ticksize)*point)*PipValue(symbol))This is part of the code where this is calculated. size is obviously the result that we expect, in lots. value is the input value, the % to risk. sl is the stop loss, I think in pips. The rest of the formula is to make sure that everything works in any chart. Here are some of the variables:
double TickValue=MarketInfo(symbol,MODE_TICKVALUE); double point=MarketInfo(symbol,MODE_POINT); double ticksize=MarketInfo(symbol,MODE_TICKSIZE);what is tickvalue and what is ticksize... I don't really remember
I think point is 0..00001 if the broker is 5 digits. PipValue() is a function that I wrote and this function makes it possible for these settings to work:

So obviously these are some crazy calculations. They can be simple if you omit all these tick value/size, pip and point things.
-
@fxdreema from the looks of it , i believe its for a fix sl value. Right?