ts-gbp-jpy_1t

Author: Felipe Schmitt
Profit factor:
0.48
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
ts-gbp-jpy_1t
/*
 * GBP/JPY strategy http://www.forexinvestimentos.com/forum/smf/index.php/topic,1029.0.html
 
 */

#property copyright "Felipe Schmitt"

// Universal settings

// Money management
extern double FixedLots = 0.3;   // if > 0.0 fixed lots used
extern double Risk = 0.01;       // per cent of free margin of a single offer

extern int StopLoss = 50;
extern int TakeProfit1 = 100;
//extern int TakeProfit2 = 70;
//extern int TakeProfit3 = 60;

extern int DayStartHour = 4;
extern int StopShift = 0;
extern int OrderExpirationHours = 20;



bool extremsSet = false;
double dayHigh = 0.0;
double dayLow = 0.0;

void CloseOpenPositions()
{
   //for(int i = 0; i < OrdersTotal(); i++)
   for(int i = OrdersTotal(); i>=0; i--)
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      {
         if(OrderType() == OP_BUY || OrderType() == OP_SELL)
         {
            double price = Ask;
            if(OrderType() == OP_BUY)
               price = Bid;
            
            OrderClose(OrderTicket(), OrderLots(), price, 3);
         }
      }
   }
}

void SetPositions()
{
   // calculate lot size
   double lots;
   if(FixedLots > 0.0)
      lots = FixedLots;
   else
      lots = NormalizeDouble(AccountFreeMargin() * Risk / (StopLoss * MarketInfo(Symbol(), MODE_TICKVALUE)), 1);

   CloseOpenPositions();

   double price = Ask;
   int operation = OP_BUYSTOP;
  // if(Ask < dayHigh)
   {
      operation = OP_BUYSTOP;
      price = dayHigh + StopShift * Point;
   }
   
   OrderSend(Symbol(), OP_BUYSTOP, lots, price, 3, price - StopLoss * Point, price + TakeProfit1 * Point, NULL, 0, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Blue);
   //OrderSend(Symbol(), OP_BUYSTOP, lots, price, 3, price - StopLoss * Point, price + TakeProfit2 * Point, NULL, 0, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Blue);
  // OrderSend(Symbol(), OP_BUYSTOP, lots, price, 3, price - StopLoss * Point, price + TakeProfit3 * Point, NULL, 0, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Blue);

   price = Bid;
   operation = OP_SELLSTOP;
  // if(Bid > dayLow)
   {
      operation = OP_SELLSTOP;
      price = dayLow - StopShift * Point;
   }
   
   OrderSend(Symbol(), OP_SELLSTOP, lots, price, 3, price + StopLoss * Point, price - TakeProfit1 * Point, NULL, 0, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Red);
   //OrderSend(Symbol(), OP_SELLSTOP, lots, price, 3, price + StopLoss * Point, price - TakeProfit2 * Point, NULL, 0, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Red);
  // OrderSend(Symbol(), OP_SELLSTOP, lots, price, 3, price + StopLoss * Point, price - TakeProfit3 * Point, NULL, 0, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Red);
}

void start()
{
   if(TimeHour(TimeCurrent()) == DayStartHour && !extremsSet)
   {
      dayHigh = High[iHighest(NULL, PERIOD_H1, MODE_HIGH, 8, 0)] ;
      dayLow = Low[iLowest(NULL, PERIOD_H1, MODE_LOW, 8, 0)];
      extremsSet = true;
      
      SetPositions();
   }
   else if(TimeHour(TimeCurrent()) != DayStartHour && extremsSet)
      extremsSet = false;
}

Profitability Reports

NZD/USD Oct 2024 - Jan 2025
0.78
Total Trades 82
Won Trades 23
Lost trades 59
Win Rate 28.05 %
Expected payoff -2.38
Gross Profit 690.00
Gross Loss -885.00
Total Net Profit -195.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.47
Total Trades 100
Won Trades 19
Lost trades 81
Win Rate 19.00 %
Expected payoff -6.45
Gross Profit 570.00
Gross Loss -1215.00
Total Net Profit -645.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.19
Total Trades 81
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -11.11
Gross Profit 210.00
Gross Loss -1110.00
Total Net Profit -900.00
-100%
-50%
0%
50%
100%

Comments