move sl 20
Download scriptThis script is designed to automatically manage your open trades by dynamically adjusting their protective limits based on real-time market movements. It acts as an automated "safety net" for your active positions, ensuring that your risk management remains consistent with current price fluctuations.
How the Logic Works
The tool performs a continuous scan of all your currently active trading positions. Every time the script runs, it filters through these trades to identify which ones are associated with the specific currency pair or asset you are currently viewing. It specifically looks for two types of positions: "Buy" orders and "Sell" orders.
For Buy Positions: Whenever the script detects an open "Buy" order on the current chart, it automatically adjusts the position's modification level. It calculates a specific distance from the current market price (specifically 20 points below the current bid) and updates the trade to reflect this new threshold. This ensures that your protective limits are always anchored relative to where the price is currently trading, rather than where it was when you first opened the trade.
For Sell Positions: Conversely, if the script identifies an open "Sell" order, it performs the opposite action. It calculates a specific distance above the current market price (specifically 20 points above the current ask) and updates the position accordingly.
Key Takeaways for the User
- Dynamic Updates: Instead of leaving your trade limits static, this script constantly "relocates" your protective markers to stay within a fixed distance of the live market price.
- Automated Precision: It eliminates the need for manual adjustments; as the market moves up or down, the script follows along, maintaining a consistent buffer.
- Symbol Specificity: The logic is intelligent enough to only modify trades on the specific chart you are currently viewing, preventing it from accidentally interfering with trades on other currency pairs.
int start()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
{
if (OrderSymbol()==Symbol()&& OrderType() == OP_BUY ) {
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-20*Point,OrderTakeProfit(),0,Green);
}
if (OrderSymbol()==Symbol()&& OrderType() == OP_SELL ) {
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+20*Point,OrderTakeProfit(),0,Green);
}
}
}
return;
}
Comments