Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 681
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
probably like this, for selling:
profit=NormalizeDouble((OrderOpenPrice()-Ask)*MarketInfo(_Symbol,MODE_TICKVALUE)*lot/Point,2);
to buy by Bid, i.e. ( Bid -OrderOpenPrice())
TakeProfit =100 points Lot = 0.1, how much will be the profit of the open position in the currency, when the position is closed by TP?
it doesn't work that way.
Need to operate:Lot -> Money -> Distance, and the cost of the tick
Money is just the thing to find out )
The solution does not take into account commissions and swaps. The points seem to be in profit, but the costs are a loss.
I don't like the formula OrderProfit()+ OrderComission()+OrderSwap() with commissions and swaps
The help says that commission may be in points or in deposit currency, this formula doesn't take this into account, and may do more harm than good in testing, but this is a matter of taste
Take_Profit =100 points, lot =0.1, how much will be the profit of an open position in the currency, when the position is closed by TP?
It doesn't work like that.
Isn't maths your thing? ;)
otherwise:
profit=NormalizeDouble((Take_Profit *Point)*MarketInfo(_Symbol,MODE_TICKVALUE)*lot/Point,2);
if shortened, it will be
profit=NormalizeDouble(lot *TakeProfit*MarketInfo(_Symbol,MODE_TICKVALUE),2);
What is meant here is thatOrderProfit() should be used in the calculation
How to calculate the lot for a position before sending an order to get a profit of USD 20 when TakeProfit kicks in? The OrderProfit() will not help here - there is no position yet.
Or otherwise: What would be the TakeProfit of the future position in order to get a profit of 20 USD when opening with 0.1 lot? And here OrderProfit() will not help - for the same reason.
And another way: What Stop Loss should be in the future position, so that when I open with 0.1 lot I get a loss of no more than 3% of available funds? And here OrderProfit() will not help - for the same reason.
Update: all calculations will be approximate without knowing the commission and swap. We will have to adjust stop-orders "on the spot" if we need accuracy to a cent or a point.
Before sending an order to open a position, how do I calculate the lot for the future position, so that when the takeprofit is triggered, I get a profit of 20 USD? OrderProfit() is not helpful here - there is no position yet.
Or in other words: What would be the TakeProfit of the future position, so that if I open with 0.1 lot I would get a profit of 20 USD? And here OrderProfit() will not help - for the same reason.
I just wrote and understood what I had to calculate before opening and immediately deleted the message. How smart of you to reply)
I once wrote such, and entered an amount per 1 lot in the input parameters as a commission.
does it increase with each tick? Help:-))))
it means you are counting on every tick the code you submitted and not initializingSredRazmax andSredRazmin variables
it's a good habit to initialize variables before use - that's what universities teach you, it reduces the time it takes to find bugs ;)
Colleagues, why does this code refuse to execute in the strategy tester, but executes correctly in real time. I'm talking specifically about the OnChartEvent() function. In the visualization mode in the tester, it is not executed when the buttons are clicked.
Colleagues, why does this code refuse to execute in the strategy tester, but executes correctly in real time. I'm talking specifically about the OnChartEvent() function. In the visualization mode in the tester, it is not executed when the buttons are clicked.
Because in MT4 OnChartEvent() does not work in the tester. Check the button state flag in the tester.
Thank you! I had that suspicion, but I didn't find information in the help that OnChartEvent() doesn't work in the tester.