Hilo Gold Pro v1.0 (Non-Repaint) is an Expert Advisor designed to assist traders in managing their trades by automatically adjusting profit targets and stop losses. It operates without repainting, meaning the signals it generates remain stable and consistent once they are established. The primary function of this EA is to streamline the trade management process, focusing on incrementally setting targets and dynamically moving stop losses to secure profits. This EA helps traders maintain a disciplined approach to managing their open positions, adapting to changing market conditions while following predefined rules.
//+------------------------------------------------------------------+
//| External variables that can be modified by the user |
//+------------------------------------------------------------------+
extern int First_Target = 10; // Initial target in pips
extern int Target_Increment = 6; // Increment of the target after each successful take profit
extern double Close_Lots = 0.1; // Number of lots to close at each target
extern int First_Stop = 10; // Initial stop in pips
extern int Stop_Differential = 0; // Differential for moving the stop loss
extern bool Move_Stops = true; // Whether to move the stop loss or not
//+------------------------------------------------------------------+
//| Global variables |
//+------------------------------------------------------------------+
int ft; // Variable to store the current target level
int fs; // Variable to store the current stop level
int curPipValue; // Difference between the open price and current price in pips
//+------------------------------------------------------------------+
//| Function to manage trade |
//+------------------------------------------------------------------+
void ManageTrade()
{
// Initialize local variables
int ti = Target_Increment; // Store the target increment
double cl = Close_Lots; // Store the lot size to close
int trange = 0; // Define a range for the target
int totalorders = OrdersTotal(); // Get the total number of open orders
// Loop through all open orders
for(int j = 0; j < totalorders; j++)
{
OrderSelect(j, SELECT_BY_POS, MODE_TRADES); // Select the order by position
if(ft == 0) ft = First_Target; // Initialize target if not set
// Manage BUY orders
if(OrderType() == OP_BUY && OrderSymbol() == Symbol())
{
curPipValue = (Bid - OrderOpenPrice()) / Point; // Calculate current pips
trange = ft + 5; // Set a range for the target
// Check if the current pips are within the target range
if(curPipValue >= ft - 1 && curPipValue <= trange)
{
// Close part of the position if the target is reached
if(OrderClose(OrderTicket(), cl, Bid, 3, YellowGreen))
{
ft += ti; // Increment the target
Comment(ft);
return; // Exit the function
}
}
}
// Manage SELL orders
else if(OrderType() == OP_SELL && OrderSymbol() == Symbol())
{
curPipValue = (OrderOpenPrice() - Ask) / Point; // Calculate current pips
trange = ft + 5; // Set a range for the target
// Check if the current pips are within the target range
if(curPipValue >= ft - 1 && curPipValue <= trange)
{
// Close part of the position if the target is reached
if(OrderClose(OrderTicket(), cl, Ask, 3, YellowGreen))
{
ft += ti; // Increment the target
Comment(ft);
return; // Exit the function
}
}
}
}
}
//+------------------------------------------------------------------+
//| Function to move stop losses |
//+------------------------------------------------------------------+
void MoveStops()
{
int sd = Stop_Differential; // Store the stop differential
int trange = 0; // Define a range for the stop
int totalorders2 = OrdersTotal(); // Get the total number of open orders
// Loop through all open orders
for(int j = 0; j < totalorders2; j++)
{
OrderSelect(j, SELECT_BY_POS, MODE_TRADES); // Select the order by position
if(fs == 0) fs = First_Stop; // Initialize stop if not set
trange = First_Stop + 5; // Set a range for the stop
// Manage BUY orders
if(OrderType() == OP_BUY && OrderSymbol() == Symbol())
{
curPipValue = (Bid - OrderOpenPrice()) / Point; // Calculate current pips
// Check if the current pips are within the stop range and move stops if enabled
if(Move_Stops && curPipValue >= First_Stop && curPipValue <= trange)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + Stop_Differential * Point, OrderTakeProfit(), 0, Plum);
return; // Exit the function
}
}
// Manage SELL orders
else if(OrderType() == OP_SELL && OrderSymbol() == Symbol())
{
curPipValue = (OrderOpenPrice() - Ask) / Point; // Calculate current pips
// Check if the current pips are within the stop range and move stops if enabled
if(Move_Stops && curPipValue >= First_Stop && curPipValue <= trange)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - Stop_Differential * Point, OrderTakeProfit(), 0, Plum);
return; // Exit the function
}
}
}
}
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int init()
{
// Call functions to manage trades and move stops
MoveStops();
ManageTrade();
return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ft = 0; // Reset target variable
return(0);
}
//+------------------------------------------------------------------+
//| Expert start function |
//+------------------------------------------------------------------+
int start()
{
// Call functions to manage trades and move stops
MoveStops();
ManageTrade();
return(0);
}
What Does This Expert Advisor Do?
The EA is designed to automate the management of trades by focusing on two primary tasks:
- Managing Targets: It incrementally adjusts the profit targets as the trade progresses.
- Moving Stop Losses: It automatically moves the stop loss to secure profits as the trade becomes more profitable.
These tasks help streamline the trading process by minimizing manual interventions and ensuring that trades are managed according to a predefined strategy.
How the EA Manages Targets
Initial Setup
When a trade is opened, the EA sets an initial target based on a predefined value. This initial target is the first milestone that the EA aims to achieve.
Incrementing Targets
Once the initial target is hit, the EA closes a portion of the trade to secure profits. After this, it automatically adjusts the target upwards by a specific increment. This process repeats every time the new target is hit, ensuring that the trade continues to secure profits while still allowing for potential gains.
Handling Different Trade Types
The EA is equipped to handle both buy and sell trades. It calculates the current profit in pips and checks whether it is within the acceptable range to close a portion of the trade. This feature ensures that the EA can adapt to different market conditions and trade directions.
Moving Stop Losses
Securing Profits
As the trade progresses, the EA also moves the stop loss to a higher level (for buy trades) or a lower level (for sell trades) to secure the profits already made. This dynamic adjustment of stop losses helps protect the trade from sudden market reversals.
Customizable Stop Loss Movement
The EA allows for the stop loss to be moved based on a differential value. This value is predefined and ensures that the stop loss is adjusted at the right time to maximize profit potential while minimizing risk.
Practical Application of the EA
Reducing Manual Intervention
One of the key benefits of using this EA is that it significantly reduces the need for manual intervention. By automating the management of targets and stop losses, traders can focus on other aspects of their strategy without worrying about constantly monitoring their open positions.
Flexibility and Adaptability
The EA is flexible enough to be adapted to different trading strategies. Whether you prefer setting tight stops and small targets or giving your trades more room to breathe, this EA can be configured to meet your specific needs.
Conclusion
This Expert Advisor provides a systematic approach to managing trades, focusing on target increments and stop loss adjustments. While it requires some initial setup, its ability to automate trade management can be a valuable asset for traders looking to optimize their strategy. By reducing manual tasks and ensuring that trades are managed consistently, this EA helps traders stay disciplined and focused on their overall trading goals.