Profit factor:
141.91

This trading algorithm, titled "Daydream," is designed to automate trade entries and exits based on price action relative to a dynamic price channel. It is specifically structured to identify moments where the market breaks out of recent established boundaries, allowing it to capture trend reversals or extensions.

Core Trading Logic

The script operates by monitoring the highest and lowest prices reached over a specific period (the "Channel Period"). It uses these two points to create a boundary for the current market movement.

Entry Conditions:

  • Buy Orders (Long): The system looks for instances where the current price closes below the lowest point of the recent channel. When this happens, it interprets the move as a signal to enter a "Buy" position, assuming a potential rebound or trend shift.
  • Sell Orders (Short): Conversely, if the current price closes above the highest point of the recent channel, the system identifies a "Sell" signal, entering a short position to profit from a downward move.

Trade Management: Whenever a new signal is identified, the script automatically manages existing positions:

  • If a Buy signal occurs while a Sell position is still open, it will close the Sell position before opening the new Buy.
  • If a Sell signal occurs while a Buy position is still open, it will close the Buy position before opening the new Sell.

Profit Protection and Exit Strategy

Beyond simple entry signals, the script includes an automated "Trailing Profit" mechanism to help lock in gains as the market moves in your favor:

  1. Dynamic Target Adjustment: As the price moves, the script constantly recalculates the target profit level. For a Buy position, it attempts to keep the profit target at a fixed distance ahead of the current price; for a Sell position, it keeps it at a fixed distance below the current price.
  2. Automatic Execution: Once the market reaches this dynamically updated profit target, the script will automatically close the trade.

Key Operational Features

  • Frequency Control: The script is programmed to ensure it only opens one trade per candle (time period), preventing it from entering multiple redundant positions during a single price fluctuation.
  • Precision: It accounts for "Slippage," which helps manage the execution of orders in fast-moving markets where the exact requested price might change slightly between the signal and the actual execution.
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt Closes Orders by itself
7 Views
1 Downloads
0 Favorites
Daydream01
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                              Daydream by Cothool |
//|                                          Recommended: USD/JPY 1H |
//+------------------------------------------------------------------+
#define MAGIC_NUM  48213657
//+------------------------------------------------------------------+
extern double Lots       = 1;
extern int ChannelPeriod = 25;
extern int Slippage      = 3;
extern int TakeProfit    = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
   if (Time[0] == LastOrderTime)
      return;
   if (CurrentDirection != 0)
      return;

   OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0,
             "Daydream", MAGIC_NUM, 0, Blue);
   LastOrderTime = Time[0];
   CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
   if (Time[0] == LastOrderTime)
      return;
   if (CurrentDirection != 0)
      return;

   OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0,
             "Daydream", MAGIC_NUM, 0, Red);
   LastOrderTime = Time[0];
   CurrentDirection = -1;
}
//+------------------------------------------------------------------+
void CloseLong()
{
   int i;

   if (Time[0] == LastOrderTime)
      return;
   if (CurrentDirection != 1)
      return;

   for (i = 0; i < OrdersTotal(); i++)
   {
      if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
          OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_BUY)
      {
         OrderClose(OrderTicket(), OrderLots(), Bid, 3, White);
         LastOrderTime = Time[0];
         CurrentDirection = 0;
      }
   }
}
//+------------------------------------------------------------------+
void CloseShort()
{
   int i;

   if (Time[0] == LastOrderTime)
      return;
   if (CurrentDirection != -1)
      return;

   for (i = 0; i < OrdersTotal(); i++)
   {
      if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
          OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_SELL)
      {
         OrderClose(OrderTicket(), OrderLots(), Ask, 3, White);
         LastOrderTime = Time[0];
         CurrentDirection = 0;
      }
   }
}
//+------------------------------------------------------------------+
void start()
{
   double HighestValue;
   double LowestValue;

   HighestValue = High[Highest(NULL, 0, MODE_HIGH, ChannelPeriod, 1)];
   LowestValue = Low[Lowest(NULL, 0, MODE_LOW, ChannelPeriod, 1)];

   // BUY
   if (Close[0] < LowestValue)
   {
      CloseShort();
      OpenLong();
      CurrentTakeProfitPrice = Bid + TakeProfit * Point;
   }

   // SELL
   if (Close[0] > HighestValue)
   {
      CloseLong();
      OpenShort();
      CurrentTakeProfitPrice = Ask - TakeProfit * Point;
   }

   // Trailing Profit Taking for Long Position
   if (CurrentDirection == 1)
   {
      if (CurrentTakeProfitPrice > Bid + TakeProfit * Point)
         CurrentTakeProfitPrice = Bid + TakeProfit * Point;
      if (Bid >= CurrentTakeProfitPrice)
         CloseLong();
   }

   // Trailing Profit Taking for Short Position
   if (CurrentDirection == -1)
   {
      if (CurrentTakeProfitPrice < Ask - TakeProfit * Point)
         CurrentTakeProfitPrice = Ask - TakeProfit * Point;
      if (Ask <= CurrentTakeProfitPrice)
         CloseShort();
   }
}
//+------------------------------------------------------------------+

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
17 reports
EUR/USD Jul 2025 - Sep 2025
2406.86
Total Trades 389
Won Trades 181
Lost trades 208
Win Rate 46.53 %
Expected payoff 84031.83
Gross Profit 32701968.00
Gross Loss -13587.00
Total Net Profit 32688381.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.64
Total Trades 188
Won Trades 87
Lost trades 101
Win Rate 46.28 %
Expected payoff -19.82
Gross Profit 6710.00
Gross Loss -10437.00
Total Net Profit -3727.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.63
Total Trades 218
Won Trades 101
Lost trades 117
Win Rate 46.33 %
Expected payoff -9.77
Gross Profit 3682.00
Gross Loss -5812.00
Total Net Profit -2130.00
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.56
Total Trades 601
Won Trades 277
Lost trades 324
Win Rate 46.09 %
Expected payoff -11.11
Gross Profit 8568.00
Gross Loss -15247.00
Total Net Profit -6679.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.52
Total Trades 381
Won Trades 154
Lost trades 227
Win Rate 40.42 %
Expected payoff -18.95
Gross Profit 7813.07
Gross Loss -15034.60
Total Net Profit -7221.53
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.42
Total Trades 371
Won Trades 162
Lost trades 209
Win Rate 43.67 %
Expected payoff -13.10
Gross Profit 3489.00
Gross Loss -8350.00
Total Net Profit -4861.00
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.42
Total Trades 365
Won Trades 116
Lost trades 249
Win Rate 31.78 %
Expected payoff -13.54
Gross Profit 3573.78
Gross Loss -8514.88
Total Net Profit -4941.10
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.38
Total Trades 197
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -29.28
Gross Profit 3496.00
Gross Loss -9265.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.35
Total Trades 367
Won Trades 119
Lost trades 248
Win Rate 32.43 %
Expected payoff -17.29
Gross Profit 3419.00
Gross Loss -9764.00
Total Net Profit -6345.00
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.30
Total Trades 321
Won Trades 97
Lost trades 224
Win Rate 30.22 %
Expected payoff -29.99
Gross Profit 4053.93
Gross Loss -13679.34
Total Net Profit -9625.41
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.30
Total Trades 209
Won Trades 59
Lost trades 150
Win Rate 28.23 %
Expected payoff -46.05
Gross Profit 4068.64
Gross Loss -13693.77
Total Net Profit -9625.13
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.28
Total Trades 274
Won Trades 80
Lost trades 194
Win Rate 29.20 %
Expected payoff -35.13
Gross Profit 3740.00
Gross Loss -13366.00
Total Net Profit -9626.00
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.28
Total Trades 318
Won Trades 97
Lost trades 221
Win Rate 30.50 %
Expected payoff -29.88
Gross Profit 3717.50
Gross Loss -13218.15
Total Net Profit -9500.65
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.27
Total Trades 199
Won Trades 52
Lost trades 147
Win Rate 26.13 %
Expected payoff -35.63
Gross Profit 2559.59
Gross Loss -9650.35
Total Net Profit -7090.76
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.17
Total Trades 208
Won Trades 50
Lost trades 158
Win Rate 24.04 %
Expected payoff -42.14
Gross Profit 1829.00
Gross Loss -10594.00
Total Net Profit -8765.00
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.10
Total Trades 185
Won Trades 37
Lost trades 148
Win Rate 20.00 %
Expected payoff -49.73
Gross Profit 1064.64
Gross Loss -10264.77
Total Net Profit -9200.13
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.02
Total Trades 89
Won Trades 6
Lost trades 83
Win Rate 6.74 %
Expected payoff -103.38
Gross Profit 178.56
Gross Loss -9379.05
Total Net Profit -9200.49
-100%
-50%
0%
50%
100%

Comments