- Greg MK: In general I insert either a classic stop loss like: "Ask+100*_Point",
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
My GBPJPY shows average spread = 26 points, average maximum spread = 134.
My EURCHF shows average spread = 18 points, average maximum spread = 106.
(your broker will be similar).
Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)
-
- Greg MK: The problem is that i don't know how to define the conditions in the variables "TakeProfit Conditions" that I defined. How can I code this ?
Until you can state your requirements in concrete terms, it can not be coded.
When I open a trade with the OrderSend() command, there is the basic command to perform the stop loss. In general I insert either a classic stop loss like: "Ask+100*_Point", or through a variable that I would have previously defined via the "extern int" command.
Now i would like to go further and develop my TakeProfit conditions in my script.
I would like to expand the conditions and write these conditions in this simple line of code. for example, I would like my trade to close if the SMA200 goes above the SMA20 for example.
To do this I think of defining a variable that I would call "TakeProfit Conditions" and that I would define like this:
int extern TakeProfitConditions. I will insert it later in the conditions of the OrderSend function. The problem is that i don't know how to define the conditions in the variables "TakeProfit Conditions" that I defined.
How can I code this ?
Thanks
When I open a trade with the OrderSend() command, there is the basic command to perform the stop loss. In general I insert either a classic stop loss like: "Ask+100*_Point", or through a variable that I would have previously defined via the "extern int" command.
Now i would like to go further and develop my TakeProfit conditions in my script.
I would like to expand the conditions and write these conditions in this simple line of code. for example, I would like my trade to close if the SMA200 goes above the SMA20 for example.
To do this I think of defining a variable that I would call "TakeProfit Conditions" and that I would define like this:
int extern TakeProfitConditions. I will insert it later in the conditions of the OrderSend function. The problem is that i don't know how to define the conditions in the variables "TakeProfit Conditions" that I defined.
How can I code this ?
Thanks
The approach has several steps .
By wanting to have a "TP conditions" parameter i assume you want to be able to have a normal TP and an MA TP so , first you will code that switch with an enumeration
enum tp_mode{ tp_mode_none=0,//nothing tp_mode_points=1,//points tp_mode_cross=2//ma cross }; input tp_mode TPMode=tp_mode_points;//Select TP Method :
Then you will need to remember the trades your system takes and what the alignment of the MAs is , although i imagine if you want to TP when MAs cross then you enter on the opposite alignment .
Then you will need a control block where if the TP mode is with MAs you go over your trades when a new bar forms and check the MA alignment , and , close accordingly if needed.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When I open a trade with the OrderSend() command, there is the basic command to perform the stop loss. In general I insert either a classic stop loss like: "Ask+100*_Point", or through a variable that I would have previously defined via the "extern int" command.
Now i would like to go further and develop my TakeProfit conditions in my script.
I would like to expand the conditions and write these conditions in this simple line of code. for example, I would like my trade to close if the SMA200 goes above the SMA20 for example.
To do this I think of defining a variable that I would call "TakeProfit Conditions" and that I would define like this:
int extern TakeProfitConditions. I will insert it later in the conditions of the OrderSend function. The problem is that i don't know how to define the conditions in the variables "TakeProfit Conditions" that I defined.
How can I code this ?
Thanks