I've been reading about Stop Loss and Take Profits and at this point I'm a bit confused.
Here is my current understanding:
1. If I'm selling a stock, I pay the bid price.
I need to set a stop loss amount that is lower than the bid price.
I need to set a take profit amount that is higher than the bid price.
2. If I'm buying a stock, I pay the ask price.
I need to set a stop loss amount that is higher than the ask price.
I need to set a take profit amount that is lower than the ask price.
Thank you...
Welcome to mql5
If you are selling an asset you are paying the Bid price
- You need to set a stop loss above the Ask price
- You need to set a take profit below the Bid price
- The order will be closed with the Ask price
If you are buying an asset you are paying the Ask price
- You need to set a stop loss below the Bid price
- You need to set a take profit above the Ask price
- The order will be closed with the Bid price
There is also the brokers allowed minimum distance of any stop from current price limitation . Some brokers dont have that ,some do.
I have implemented the SL and TP logic.
Below is my Buy code snippet. The logic still seems 'backwards' to me. I have added the actual values when I run my code as comments so you can see what they are.
I don't understand, when buying a stock, why there is a SL below the bid price? Shouldn't the SL be above the bid price? My thinking is that I don't want to buy a stock that changes in price and goes up. I want to put a 'cap' on how much I'm willing to buy it for.
The TP amount I don't get that logic for a buy at all? That only makes sense to me if I am selling. Where is the profit in a buy trade?
Thank you...
Print("bid:",NormalizeDouble(Latest_Price.bid,_Digits)," STP:",STP," _Point:",_Point," stop loss:",NormalizeDouble(Latest_Price.bid - (STP * _Point),_Digits)); // // bid:145.45 STP:30 _Point:0.01 sl:145.15 Print("ask:",NormalizeDouble(Latest_Price.ask,_Digits)," TKP:",TKP," _Point:",_Point," take profit:",NormalizeDouble(Latest_Price.ask + (TKP * _Point),_Digits)); // // ask:145.46 TKP:100 _Point:0.01 tp:146.46 ZeroMemory(mrequest); ZeroMemory(mresult); mrequest.action = TRADE_ACTION_DEAL; // immediate order execution mrequest.price = NormalizeDouble(Latest_Price.ask,_Digits); // latest ask price mrequest.sl = NormalizeDouble(Latest_Price.bid - (STP * _Point),_Digits); // Bid:145.45 Stop Loss 145.15 mrequest.tp = NormalizeDouble(Latest_Price.ask + (TKP * _Point),_Digits); // Ask:145.46 Take Profit 146.46 mrequest.symbol = _Symbol; // currency pair mrequest.volume = dLot; // number of lots to trade mrequest.magic = EA_Magic; // Order Magic Number mrequest.type = ORDER_TYPE_BUY; // Market Buy Order mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type mrequest.deviation = 100; // max price deviation, specified in points
I see what you mean , you are probably confusing SL with limit and stop orders
Lets assume there is a market of strawberries - this market has one price not an Ask + Bid
The price for 1 strawberry is 100$ in the market and is known as the "price of strawberries".
You buy a strawberry at 100$
You set TakeProfit for your strawberry at 140$ - that means (for the market) that if "price of strawberries" reaches 140$ and above you want to sell it.[and will profit $40]
You set StopLoss for your strawberry at 90$ - that means (for the market) that if "price of strawberries" reaches 90$ and below you want to sell it.[and will lose $10]
The broker is the mediator ,the dude/lady who you tell "i want to sell my strawberry" and has a list of people who want to buy and sell ,matches transactions accordingly.
The example above was for an instant execution .
Lets assume you have not bought a strawberry yet and the "price of strawberries" is 100$
You tell the market ,i will buy one strawberry if the price goes to 120$ -> that is called a Buy Stop
You tell the market ,i will buy one strawberry if the price goes to 80$ -> that is called a Buy Limit
This may help :
Regarding your Strawberry instant execution example (great example BTW, thank you).
So after I purchase a $100.00 strawberry, there is still an open order pending for the stop loss and take profit values? Those will stay open on the broker side for how long?
Thank you...
Regarding your Strawberry instant execution example (great example BTW, thank you).
So after I purchase a $100.00 strawberry, there is still an open order pending for the stop loss and take profit values? Those will stay open on the broker side for how long?
Thank you...
Until they are hit ,if they are placed .
Price gaps on openings will also affect them .
Thanks a lot. You're explanations on this topic were the best I've ever seen online. And I've googled this topic a lot...!!!
Thanks a lot. You're explanations on this topic were the best I've ever seen online. And I've googled this topic a lot...!!!
You are welcome
Regarding the Buy Stop and Stop Limit:
In the struct MqlTradeRequest I don't see a .property for Buy Stop?
Also, if I am buying a stock using the Buy Stop and Stop Limit, then (I'm assuming) I don't need to fill in the Stop Loss and Take Profit properties? I can set them to 0.00?
Thank you...
struct MqlTradeRequest { ENUM_TRADE_REQUEST_ACTIONS action; // Trade operation type ulong magic; // Expert Advisor ID (magic number) ulong order; // Order ticket string symbol; // Trade symbol double volume; // Requested volume for a deal in lots double price; // Price double stoplimit; // StopLimit level of the order double sl; // Stop Loss level of the order double tp; // Take Profit level of the order ulong deviation; // Maximal possible deviation from the requested price ENUM_ORDER_TYPE type; // Order type ENUM_ORDER_TYPE_FILLING type_filling; // Order execution type ENUM_ORDER_TYPE_TIME type_time; // Order expiration type datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type) string comment; // Order comment ulong position; // Position ticket ulong position_by; // The ticket of an opposite position };
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've been reading about Stop Loss and Take Profits and at this point I'm a bit confused.
Here is my current understanding:
1. If I'm selling a stock, I pay the bid price.
I need to set a stop loss amount that is lower than the bid price.
I need to set a take profit amount that is higher than the bid price.
2. If I'm buying a stock, I pay the ask price.
I need to set a stop loss amount that is higher than the ask price.
I need to set a take profit amount that is lower than the ask price.
Thank you...