Thank you @l-andorrà , just the hint I needed.
If anyone is interested you can set price per pip variable with this calculation

Thank you @l-andorrà , just the hint I needed.
If anyone is interested you can set price per pip variable with this calculation

I know this is an old topic but I went around in circles thinking the reply above was valid.
It is not correct: the boolean function DOES work and is expected for the weekday.
So Tuesday boolean value of 'false' means 'Reject'
Is @kestra DMing everyone else with requests to save his work for him? Unfortunately I can't block him but have reported his profile a few weeks ago but nothing has been done. Just pay for a subscription @kestra then you will be able to save your work.
Can one of the admins @fxdreema @l-andorrà please ban him

Wow I never knew about that block! Thank you @jstap !
(For those that are curious it's under 'controlling blocks':
)
you need to understand what the different types are, especially if it's a scalper
https://www.youtube.com/watch?v=qqVoHMg-Q_Y
This happened to me just now.
Error message looks like this and is very difficult to debug:

It happened as in a comments (ugly) box a data row had a value of text (code). Even though the label was blank and there was no code in the box the error came up. So I changed it back to the default of 'Numeric' and it compiled successfully.
I complained about this a while back but didn't file a report - thanks for sharing your icustom solution
@l-andorrà no it will only work for buys, that's a hedged trade, no?
But it might be worth asking ChatGPT as it can come up with a calculation/formula for you
you need to understand what the different types are, especially if it's a scalper
https://www.youtube.com/watch?v=qqVoHMg-Q_Y
Be wary of using chatGPT as it took me a while to get to this formula.
For example, some of the maths was completely out - I gave it 'real life' figures based on watching strategy tester (as it was working with TP based on profit, rather than price). Then it corrected itself.
But you can also just say 'now give it to me as MQL5' and it spits out code for you, so that's pretty handy
double CalculateTakeProfitPriceForBuy(double P_A, double P_D, double x_pips)
{
double lot_size_A = 0.02;
double lot_size_D = 0.06;
double pip_size = 0.0001; // Standard pip size for major pairs like EURUSD
return (lot_size_A * P_A + lot_size_D * P_D + x_pips * pip_size * (lot_size_A + lot_size_D)) / (lot_size_A + lot_size_D);
}
// Sample usage:
void OnTick()
{
double P_A = 1.09692; // Opening price of trade A
double P_D = 1.09592; // Opening price of trade D
double x_pips = 3.0; // Desired profit in pips
double TP_Price = CalculateTakeProfitPriceForBuy(P_A, P_D, x_pips);
// Use the TP_Price as necessary, e.g., set a take profit order, draw a line on chart, etc.
// ... your logic here ...
}
A little more on the formula (buys only)

This is bizarre.
I have 2 formulas to trace bug on why calc isn't working. One that uses custom pip size (0.0001) and one that uses original (0.00001). Identical formulas bar the 1 decimal place. But fxdreema seems to be unable to calculate the one with the extra decimal place. Just completely ignores it. And it's not the variable, I've tried hardcoding the 0.00001 as well. Very strange.
This formula seems to work weirdly I can't get the calculation to work. It simple refuses to multiply by 0.00001. Tried it an MQL5 code block and output to journal. No dice.

It's soooo close. The above is the solution but I have spent so long on this now for some visual flair I think I'll just leave it.
Also remember the TP in pips is of the first/last trades total lot size. The oldest trade is almost certainly in drawdown when it's closed (but the two together close in profit)
Never knew you could draw lines straight from TP!
But I don't think that'll work - it works on bucket, right? For bucket you can only filter by direction or manual/automated. By loop you could do it (count buys, then only count every (totaltrades -1)) but then you can't calc the aggregated TP of the 2 trades (remember, this could be the first/last trades of a batch of 10+)
ChatGPT's approach is to proportionally measure each trade's contribution to profit by point, and take into account the starting price of each, which is how it would've been in my head but I had no idea what formula would be.
I've nearly done it but the maths/formula is tripping me up, particularly point size as I want it to work on metals/FX/indices. I'm so close, I have the correct TP now but it's multiplied it by 10 somewhere. I'll post formula when I've cracked it.
@TipsyWisdom it is, super easy.
BUT, I would like to display the TP as a line on the chart, and I can only do this (as far as I know) by calculating the price that the TP line should be.
ChatGPT has this to say. I'm going to take a look at this closely a little later (it's for a sell):
(Deleted pic as formula was wrong)