Strategy of Regularities of Exchange Rates

Author: Copyright � 2008, ����, yuriy@fortrader.ru
Profit factor:
0.69

Here's a breakdown of what the trading script does, explained in plain language:

Overall Goal:

The script tries to automatically trade on the forex market by identifying patterns that might occur at specific times of the day. It's designed to run on an hourly timeframe. The script is specifically designed for testing purposes, not for real trading.

How it Works:

  1. Setup:

    • The script starts by defining a few settings that you, the user, can adjust. These include:
      • optime: The hour of the day when the script will try to open new trades.
      • cltime: The hour of the day when the script will close any open trades.
      • point: A measure of distance on the price chart, helping to determine how far away the script should place orders.
      • Lots: The size of the trades the script will place.
      • TakeProfit: The amount of profit (measured in "points") the script aims to make on each trade.
      • StopLoss: The amount of loss (measured in "points") the script will tolerate on each trade.
  2. Time Check:

    • The script makes sure it's running on a timeframe that's one hour or less. If the chart is set to a longer timeframe (like a daily chart), the script will stop.
  3. Opening New Trades (TimePattern Function):

    • When the current hour matches the optime setting, the script attempts to place two "pending" orders:
      • A "sell stop" order: This is an order to sell if the price drops to a certain level below the current price.
      • A "buy stop" order: This is an order to buy if the price rises to a certain level above the current price.
    • These orders are placed at a distance from the current price, determined by the point setting.
    • The script also sets a StopLoss to limit losses and TakeProfit to automatically close the trade when a specific profit is reached.
  4. Managing Existing Trades (PosManager Function):

    • The script constantly checks all open trades.
    • If the current hour matches the cltime setting, the script closes all pending orders
    • For any open trades (buys or sells):
      • If the trade has reached the TakeProfit target, or if the current hour matches the cltime setting, the script closes the trade to take the profit (or limit potential losses).

In Simple Terms:

Imagine the script as a robot that wakes up at a specific hour (optime), looks at the current price of a currency, and places two bets: one that the price will go up, and one that the price will go down. The robot sets rules for how much it's willing to lose (StopLoss) and how much profit it wants to make (TakeProfit). Then, at another specific hour (cltime), the robot closes all open bets, whether they've made a profit or not. This happens repeatedly, every time the script runs.

Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt Closes Orders by itself
3 Views
0 Downloads
0 Favorites
Strategy of Regularities of Exchange Rates
//+------------------------------------------------------------------+
//|                   Strategy of Regularities of Exchange Rates.mq4 |
//|                       Copyright © 2008, Þðèé, yuriy@fortrader.ru |
//|     http://www.ForTrader.ru, Àíàëèòè÷åñêèé æóðíàë äëÿ òðåéäåðîâ. |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Þðèé, yuriy@fortrader.ru"
#property link      "http://www.ForTrader.ru, Àíàëèòè÷åñêèé æóðíàë äëÿ òðåéäåðîâ."

extern int optime=9; //âðåìÿ
extern int cltime=2; //âðåìÿ
extern int point=20;//ðàññòîÿíèå
extern double Lots=0.1;//ðàññòîÿíèå
extern int TakeProfit=20;//ðàññòîÿíèå
extern int StopLoss=500;//ðàññòîÿíèå

//Ïðîôèòíûé ñîâåòíèê äëÿ ðàáîòû íà ÷àñîâèêàõ

int bars;
int start()
  {
  Comment("FORTRADER.RU - âåðñèÿ äëÿ òåñòèðîâàíèÿ");
  if(IsDemo()==FALSE && IsTesting()==FALSE){Print("FORTRADER.RU -version only testing");return(0);}
 
 PosManager();
 
  //åñëè ïåðèîä áîëüøå ÷àñîâèêà òî âûõîäèì
 if(Period()>60){Print("Period must be < hour");return(0);}
  
 if(bars!=Bars)
 {bars=Bars;
 
 TimePattern();
 }
   return(0);
  }


int TimePattern()
{
if(Hour() ==optime)
{
//åñëè öåíà áîëüøå âåðõíåé ëèíèè òî óäàëÿåì ïðåäûäóùèé îðäåð è ñòàâèì íîâûé
OrderSend(Symbol(),OP_SELLSTOP,Lots,NormalizeDouble(Ask-point*Point,Digits),3,NormalizeDouble(Ask+StopLoss*Point,Digits),0,"FORTRADER.RU",0,0,Red);
OrderSend(Symbol(),OP_BUYSTOP,Lots,NormalizeDouble(Bid+point*Point,Digits),3,NormalizeDouble(Bid-StopLoss*Point,Digits),0,"FORTRADER.RU",0,0,Red);
}

return(0);
}

int deletebstop()
{
   for( int i=1; i<=OrdersTotal(); i++)          
   {
    if(OrderSelect(i-1,SELECT_BY_POS)==true) 
    {                                       
     if(OrderType()==OP_BUYSTOP && OrderSymbol()==Symbol())
     {
      OrderDelete(OrderTicket()); 
     }//if
    }//if
   }
   return(0);
}

int deletesstop()
{
   for( int i=1; i<=OrdersTotal(); i++)          
   {
    if(OrderSelect(i-1,SELECT_BY_POS)==true) 
    {                                       
     if(OrderType()==OP_SELLSTOP && OrderSymbol()==Symbol())
     {
      OrderDelete(OrderTicket()); 
     }//if
    }//if
   }
   return(0);
}

int PosManager()
{int i,z;

if(Hour() ==cltime){deletebstop();deletesstop();}

for(  i=1; i<=OrdersTotal(); i++)          
   {
    if(OrderSelect(i-1,SELECT_BY_POS)==true) 
    {                                       
     if(OrderType()==OP_SELL && ((OrderOpenPrice()-Ask)>=(TakeProfit)*Point || Hour()==cltime))
     {
     OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);   
     }//if
    }//if
   }
   
   
   for(i=1; i<=OrdersTotal(); i++)          
   {
    if(OrderSelect(i-1,SELECT_BY_POS)==true) 
    {                      
     if(OrderType()==OP_BUY && ((Bid-OrderOpenPrice())>=(TakeProfit)*Point || Hour()==cltime))
     {OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);         
     }//if
    }//if
   }


return(0);
}

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
0.69
Total Trades 127
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -0.83
Gross Profit 239.20
Gross Loss -344.80
Total Net Profit -105.60
-100%
-50%
0%
50%
100%

Comments