question on coding take profit point of mt4
question on coding take profit point of mt4
Loading saved threads...
max tony · External communityPost link
External question — Stack Overflow Stack Exchange
Author: max tony
Original post: https://stackoverflow.com/questions/72657918
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I have question on take profit point of mt4:
I would like to set take profit point to stop loss * 2, so the code should be:
takeprofit = NormalizeDouble((Ask + ((Ask - stoploss)*Point()*2) + StopLevel*Point()),Digits);
However, it won't works, so anyone know how to fix it? I am new to mq4 coder. Thanks
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/72715307
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Remember that you need to differentiate between BUY and SELL orders.
You also look like you are getting confused with
stoploss
and
StopLevel
. I'm assuming that your
StopLevel
is the distance of your stoploss in points.
If that is the case, your code should look something like this (you don't need to reference StopLevel if you already have the distance in Points):
if(ordertype==OP_BUY) takeprofit = NormalizeDouble(Ask+StopLevel*2*Point,Digits);
else takeprofit = NormalizeDouble(Bid-StopLevel*2*Point,Digits);
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: PaulB Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/72715307 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Remember that you need to differentiate between BUY and SELL orders. You also look like you are getting confused with stoploss and StopLevel . I'm assuming that your StopLevel is the distance of your stoploss in points. If that is the case, your code should look something like this (you don't need to reference StopLevel if you already have the distance in Points): if(ordertype==OP_BUY) takeprofit = NormalizeDouble(Ask+StopLevel*2*Point,Digits); else takeprofit = NormalizeDouble(Bid-StopLevel*2*Point,Digits);
Checking account access…