FPI_wibitiens_yen_ringv0.1

Author: Copyright � 2007, wibitiens
Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Miscellaneous
It issuies visual alerts to the screen
1 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
FPI_wibitiens_yen_ringv0.1
// ----------------------------------------------------------------------------- //
//                FPI - Fractional Product Inefficiency EA                       //
//                    © 2007 by wibitiens - Forex TSD                            //
// Thanks to:                                                                    //
//    Michal Kreslik, from where this method was adopted                         //
//    URL = http://kreslik.com/forums/viewtopic.php?t=307&highlight=fpi          //
//    Nicholishen for building the (FPI) predictive price                        //
//    URL = http://www.forex-tsd.com/indicators-metatrader-4/                    //
//                 6008-fpi-predictive-price.html?highlight=Ring                 //
//Yen Ring minor mod with lot changes by getdown71                               //
// ----------------------------------------------------------------------------- //

#property copyright "Copyright © 2007, wibitiens"
#property link      "http://www.forex-tsd.com/"

extern double  TotalProfit  = 75;
extern double  LoFPI        = 0.9999;
extern double  HiFPI        = 1.0003;
extern string  Rings        = "=== Currency pairs setting ===";
extern string  ring1        = "EURJPY";
extern string  ring2        = "USDJPY";
extern string  ring3        = "EURUSD";
extern double  lot1         = 4;
extern double  lot2         = 2;
extern double  lot3         = 1;

double   HProfit = -999999;
double   LProfit = 999999;
double   HFPI    = -9;
double   LFPI    = 9;
int      magic   = 9502;

int start()
  {     
   int TO =  OrdersTotal();

   // ===== Time to Next Bar     
   double seco= (Time[4]-Time[5])-MathMod(CurTime(),Time[4]-Time[5]);
   double minu=seco/60;
   seco=(minu-MathFloor(minu))*60;
   minu=MathFloor(minu);
  
   // ===== Get FPI Value
   

   double bid1 = MarketInfo(ring1,MODE_BID);
   double bid2 = MarketInfo(ring2,MODE_BID);
   double bid3 = MarketInfo(ring3,MODE_BID);
   double FPI = bid2 * bid3 * (1/bid1);
      
   if ((FPI<LoFPI)&&(TO==0))
   {
      OrderSend(ring1,OP_SELL, lot1, MarketInfo(ring1,MODE_BID), 2, NULL, NULL, "FPI", magic, NULL, FireBrick);
      OrderSend(ring2,OP_BUY,  lot2, MarketInfo(ring2,MODE_ASK), 2, NULL, NULL, "FPI", magic, NULL, LimeGreen);
      OrderSend(ring3,OP_BUY,  lot3, MarketInfo(ring3,MODE_ASK), 2, NULL, NULL, "FPI", magic, NULL, LimeGreen);
   }

   // ===== Get Account Profit and Update Highest Profit
  
   double Profit = AccountProfit();
   if (TO==3)
   {
      if (HProfit<Profit) HProfit = Profit;
      if (Profit<LProfit) LProfit = Profit;
      if (HFPI<FPI) HFPI = FPI;
      if (FPI<LFPI) LFPI = FPI;
   }
   
   // ===== Write Comment
   
   Comment("Time to Next Bar =  ",minu," : ",seco,"\n",
           "Ring : ",ring1," - ",ring2," - ",ring3,"\n",
           "FPI = ",FPI," : ",LFPI," to ",HFPI,"\n",
           "Profit = ",Profit," :  ",LProfit," to ",HProfit
           );
   
   // ===== If Target Profit reached then Close All Orders

   if ((Profit>=TotalProfit)&&(TO==3))
   {
      Alert("Total Profit of ",TotalProfit," has been reach. Closing all trades now!");
      CloseAllOpens();
      
      // Reset Highest Profit
      HProfit = -999999;
   }
  
   return(0);
}


// =========================================================================================== //
//                    C L O S E   A L L   O P E N    P O S I T I O N                           //
// =========================================================================================== //
void CloseAllOpens()
{    
  int total = OrdersTotal();
  for(int i=total-1;i>=0;i--)
  {
    OrderSelect(i, SELECT_BY_POS);
    int type   = OrderType();
    bool result = false;
    
    switch(type)
    {
      //Close opened long positions
      case OP_BUY       : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
                          break;
      //Close opened short positions
      case OP_SELL      : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
    }
    
    if(result == false)
    {
      Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
      Sleep(3000);
    }  
  }
  
}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---