Trabajo finalizado
Tarea técnica
Please write a code
Write the code so it monitors all the pending limit orders that have been entered on the trading platform
Write the code so that I can adjust the difference in times from my time zone to New York time zone.
The code will first check for any upcoming high-impact news events for all currencies. If there are any, it will suspend all pending orders involving these currencies 15 minutes before the news event and keep them suspended for 45 minutes. If the price has moved past the entry price during the suspension the pending limit order will be closed.
Assuming there are no high-impact news events, the code will monitor the pending limit order continually. If the price moves to within 2 pips of the entry price and then moves 80% of the way towards the intended profit target, the order will be cancelled.
If the spread exceeds 25 points or slippage is equal to or exceeds 5 points, the code will not open the pending order. If the price has moved past the entry price during the suspension the pending limit order will be closed.
Once the pending limit order is triggered and the trade is entered, the code will continuously monitor the trade and move the stop loss to the reaction point if the price moves 75% of the way to the profit target from the entry price. The reaction point is defined by the closest price to the stop loss after the trade has been opened, when the current price reaches 75% of the profit target.
If the trade is profitable and reaches the profit target, the code will close the trade and take the profits. However, if the price moves against us and hits the stop loss, the code will close the trade and limit our losses.
If the original pending limit order hits the stop loss, the code will place a hedge trade with the same parameters and conditions as the original pending limit order, but with an entry price 2 pips higher than the original pending order if the hedge trade is a long trade and 2 pips lower if the original order was a short trade. The hedge trade is only valid if the original pending limit order hits the stop loss. If the original order hits the profit target, then the hedge trade is cancelled.
The code will suspend all pending orders 2 hours before the close of the New York session and keep them suspended for 3 hours. If the price has moved past the entry price during the suspension the pending limit order will be closed. The code will close all open trades 30 minutes before the close of the New York session