Trabajo finalizado
Tarea técnica
Hello,
I need to get code snippets as functions:
Function 1: to place a takeprofit and a stoploss at price thresholds in pips or in currency (we can use one of the other choice) on one or more orders at the same time (case of basket of orders).
Example:
If only one order is open, and I call the function to place a takeprofit at $ 10 (account currency) and stoploss at $ 30 (account currency), then the function will automatically place the TP and SL on the corresponding price levels depending on the position size and the instrument traded.
If several orders are open, the principle must be the same: place in each order the price levels of the corresponding takeprofit and stoploss so that the entire basket closes at $ 10 in profit and at $ 30 in loss. It doesn't matter how many orders there are and whether they are mixed up (buy and sell orders).
When calling the function, you can choose whether you want a gain / loss in account currency or in points / pips.
The calculated takeprofit and stoploss price levels should be included in each order.
Function 2: trailing stop for 1 or more orders with price thresholds in pips or in currency (we can use one of the other choice) on one or more orders at the same time (case of basket of orders).
Example:
This is a classic trailing stop, but the stoploss must activate and then move (trailing stop step size) with thresholds expressed in pips or in the account currency (as desired).
The stoploss price threshold should be placed in each order if more than one order is open. The trailing stop will act globally on the basket of orders (if several orders are open) and not individually for each order.
The calculated takeprofit and stoploss price levels should be included in each order.