Experts: RUBBERBANDS_2 EA - page 4

 
mtkhreb:

Beginning .. Thank you to share your idea

I have an idea for the development of expert advisor ..

Is it possible to add these properties

1 - pip difference between the sale and buy

2 - continued to take profit in one direction for any of the buy or sale

I apologized for not being able to speak in English well :)

almeshal78@hotmail.com

Hello there. We can surely add those properties and I simply encourage you to modify RUBBERBANDS as you wish and publish it in this community.

 
StJojo:
mtkhreb:

Beginning .. Thank you to share your idea

I have an idea for the development of expert advisor ..

Is it possible to add these properties

1 - pip difference between the sale and buy

2 - continued to take profit in one direction for any of the buy or sale

I apologized for not being able to speak in English well :)

almeshal78@hotmail.com

Hello there. We can surely add those properties and I simply encourage you to modify RUBBERBANDS as you wish and publish it in this community.


StJojo
wrote:

mtkhreb:

Beginning .. Thank you to share your idea

I have an idea for the development of expert advisor ..

Is it possible to add these properties

1 - pip difference between the sale and buy

2 - continued to take profit in one direction for any of the buy or sale

I apologized for not being able to speak in English well :)

almeshal78@hotmail.com

Hello there. We can surely add those properties and I simply encourage you to modify RUBBERBANDS as you wish and publish it in this community.

Has been tested expert advisor
On this page you can see the following results
And also you can see the results of currency gbp gpy after the amendment to the expert advisor
High-risk

Low risk

Now we need only to amendments that I have mentioned to you
After development will be the best expert in this year :)
** With my sincere respect and appreciation to you ..,
 
mtkhreb:

Beginning .. Thank you to share your idea

I have an idea for the development of expert advisor ..

Is it possible to add these properties

1 - pip difference between the sale and buy

2 - continued to take profit in one direction for any of the buy or sale

I apologized for not being able to speak in English well :)

almeshal78@hotmail.com

Hello there. We can surely add those properties and I simply encourage you to modify RUBBERBANDS as you wish and publish it in this community.

Has been tested expert advisor
On this page you can see the following results
And also you can see the results of currency gbp gpy after the amendment to the expert advisor
...
Now we need only to amendments that I have mentioned to you
After development will be the best expert in this year :)
** With my sincere respect and appreciation to you ..,

Well, I'm very much flattered. Thank you for your nice graphs. I'm just wondering why you don't publish your amended code. It's not me but you who made it!

 
StJojo:
mtkhreb:

Beginning .. Thank you to share your idea

I have an idea for the development of expert advisor ..

Is it possible to add these properties

1 - pip difference between the sale and buy

2 - continued to take profit in one direction for any of the buy or sale

I apologized for not being able to speak in English well :)

almeshal78@hotmail.com

Hello there. We can surely add those properties and I simply encourage you to modify RUBBERBANDS as you wish and publish it in this community.

Has been tested expert advisor
On this page you can see the following results
And also you can see the results of currency gbp gpy after the amendment to the expert advisor
...
Now we need only to amendments that I have mentioned to you
After development will be the best expert in this year :)
** With my sincere respect and appreciation to you ..,

Well, I'm very much flattered. Thank you for your nice graphs. I'm just wondering why you don't publish your amended code. It's not me but you who made it!


Actually .. Did not finish to add the points that I mentioned to you

We are still trying with my friend to modify these points

I hope you help me with reported :)


This is the code : Rubber_Band_v.3.3.mq4

//+------------------------------------------------------------------+
//| Rubber_Band_v.3.mq4 |
//+------------------------------------------------------------------+
/*
This EA works in any timeframe (timeframe is irrelavant) for any
currency pair, including gold and silver. Preferred currency pairs are
four major pairs: EUR/USD, GBP/USD,USD/JPY, and USD/CHF.

Its logic, again, is based on the fact that any price movement may
accompany rebound and the maxim of "Sell high, buy low".

It opens orders in both directions (BUY & SELL) at a time initially,
then opens an additional SELL order everytime the price goes up by m
ultiples of "pipstep" above the initial SELL order, and opens an
additional BUY order everytime the price goes down by multiples of
"pipstep" below the initial BUY order.

It closes all the session outstanding orders when the specified profit
"Dollar_Equity_Profit_Take" (in dollars) is reached, which functions
as TAKEPROFIT, or, if set so ("Use_Equity_Loss_Cut"==true), when the
specified loss "Dollar_Equity_Loss_Cut" (in dollars) is reached, which
functions as STOPLOSS. The opening of the initilal orders through the
closure of all outstanding orders constitutes one "session". The external
variable "Max_Trades" limits the number of orders per session. To avoid
big drawdowns, smaller "Dollar_Equity_Loss_Cut" may help.
*/
#property copyright "Free"
#property link "For free help contact: shihab_shihabi@yahoo.com"
//-----------------------------
extern int Magic_Number_Buy = 111111;
extern int Magic_Number_Sell= 222222;
//----------------------
extern bool Progression_Allowed=true;//chose true to allow avreging down while doubling
//-----------------------------
extern double Initial_Lots=0.01;
extern double Lots_Multiply_Factor=2;//to multiply by last order lot
//----------------------
extern int Max_Trades= 30;//maximum number of orders allowed in one session
extern int Pip_Step = 250; //pip distance to place additional BUY or SELL orders
//----------------------------------------
extern bool Use_Equity_Profit_Take =true;//don't change this. keepm it true
extern double Dollar_Equity_Profit_Take =10000;//profit in dollars per lot to close all outstanding orders
//-----------------------------
extern bool Use_Equity_Loss_Cut = false;//
extern double Dollar_Equity_Loss_Cut = 57400;//loss in dollars per lot to close all outstanding orders
//-----------------------------
extern bool Time_Control = false;
extern string Start_Time = "08:00";
extern string End_Time = "16:00";
//-----------------------------
extern bool Act_Now = false; //if true, opens orders immediately (do now)
extern bool Stop_Now = false;//if true, stops this EA
extern bool Close_Now = false;//if true, closes all outstanding orders
//-----------------------------
/*
The following three external variables are for restarting this EA after,
say, the weekend, when there are outstanding orders. "In_Max_Price_Level" and "In_Min_Price_Level"
are displayed as "Max" and "Min" on the chart.
*/
extern bool Use_In_Values = false; // set to true on restart
extern double In_Max_Price_Level = 0; // set former max on restart
extern double In_Min_Price_Level = 0; // set former min on restart
//------- global var's -----------------
double Max_Global_Price_Level;
double Min_Global_Price_Level;
bool Close_All_Global;
bool Buy_Now_Global;
bool Sell_Now_Global;
//--------------------------------
double Poin; //to fix the 6 Digit Forex Quotes issue for MetaTrader Expert Advisors
string EA_Name = "Rubber_Band";

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+

int init()
{

if (Use_In_Values==true)
{
Max_Global_Price_Level=In_Max_Price_Level;
Min_Global_Price_Level=In_Min_Price_Level;
}
else
{
Max_Global_Price_Level=Ask;
Min_Global_Price_Level=Ask;
}

Close_All_Global=Close_Now;
Buy_Now_Global=Act_Now;//(do now)
Sell_Now_Global=Act_Now;//(do now)

if (Point == 0.00001) Poin = 0.0001; //6 digits
else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)
else Poin = Point; //Normal for 5 & 3 Digit Forex Quotes

return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+

int deinit()
{

return(0);
}

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+


int start()
{

//+------------------------------------------------------------------+
//| checking trade contexts |
//+------------------------------------------------------------------+

int TradeAllow = Is_Trade_Allowed();
if(TradeAllow < 0)
{
return(-1);
}

if(TradeAllow == 0)
{
RefreshRates();
}

//-----------------------------

int cnt, ticket, total;
bool Close_Now;//, buynow, sellnow

// STOP NOW?

if (Stop_Now==true)
{
Comment_Stopped();
return(0);
}

//Comment_Null();

total=Count_All();

// CLOSE NOW?

// if true, close one by one

if (Close_All_Global==true && total>0)
{
Close_One_By_One();
return(0);
}

if (Close_All_Global==true && total==0)
{
Close_All_Global=false;
Max_Global_Price_Level=Ask;
Min_Global_Price_Level=Ask;
Buy_Now_Global=false;
Sell_Now_Global=false;
}

// check free margin

//if(AccountFreeMargin()<(1000*Get_Buy_Lots()) || AccountFreeMargin()<(1000*Get_Sell_Lots()))
//{
//Print("We have no money. Free Margin = ", AccountFreeMargin());
//return(0);
//}

if((Time_Control==true && CurTime()>=StrToTime(Start_Time)
&& CurTime()>=StrToTime(Start_Time))
|| Time_Control==false)
{

// BUY NOW?

if (Buy_Now_Global==true)
{
ticket=OrderSend(Symbol(),OP_BUY,Initial_Lots,Ask,3,0,0,EA_Name,Magic_Number_Buy,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
if(OrderMagicNumber() == Magic_Number_Buy)

Print("Buy order opened : ",OrderOpenPrice());
}
else
{
Print("Error opening Buy order : ",GetLastError());
return(-1);
}
Buy_Now_Global=false;
return(0);
}

// SELL NOW?

if (Sell_Now_Global==true)
{
ticket=OrderSend(Symbol(),OP_SELL,Initial_Lots,Bid,3,0,0,EA_Name,Magic_Number_Sell,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
if(OrderMagicNumber() == Magic_Number_Sell)

Print("Sell order opened : ",OrderOpenPrice());
}
else
{
Print("Error opening Sell order : ",GetLastError());
return(-1);
}
Sell_Now_Global=false;
return(0);
}

}

// new order from 0 orders

if (total==0 && Seconds()==0)
{
Buy_Now_Global=true;
Sell_Now_Global=true;
return(0);
}

//-------------------------------------------

// counter if you will

if (total>0)
{

// what's the profit made

double My_Profit=0;
int xtotal=OrdersTotal();

for(cnt=0;cnt<xtotal;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
if(OrderMagicNumber() == Magic_Number_Buy || OrderMagicNumber() == Magic_Number_Sell)
{
My_Profit+=OrderProfit();
} //-if
} //-for

Comment_PL("My_Profit",My_Profit,total);

// close all trades for profit made?

if (Use_Equity_Profit_Take ==true && My_Profit>=Dollar_Equity_Profit_Take *Initial_Lots)//Lots
{
Close_All_Global=true;
}

// close all trades for loss cut?

if (Use_Equity_Loss_Cut==true && My_Profit<=(-1)*Dollar_Equity_Loss_Cut*Initial_Lots)//Lots
{
Close_All_Global=true;
}

if (total>=Max_Trades)//maxcount
{
return(0);
}

// do we buy or sell now?

//Buy
if (Ask<=Min_Global_Price_Level-Pip_Step*Poin)
{
Min_Global_Price_Level=Ask;

ticket=OrderSend(Symbol(),OP_BUY,Get_Buy_Lots(),Ask,3,0,0,EA_Name,Magic_Number_Buy,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
if(OrderMagicNumber() == Magic_Number_Buy)

Print("Buy order opened : ",OrderOpenPrice());
}
else
{
Print("Error opening Buy order : ",GetLastError());
return(-1);
}
return(0);
}

//---------------------------

//Sell
if (Ask>=Max_Global_Price_Level+Pip_Step*Poin)
{
Max_Global_Price_Level=Ask;

ticket=OrderSend(Symbol(),OP_SELL,Get_Sell_Lots(),Bid,3,0,0,EA_Name,Magic_Number_Sell,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
if(OrderMagicNumber() == Magic_Number_Sell)

Print("Sell order opened : ",OrderOpenPrice());
}
else
{
Print("Error opening Sell order : ",GetLastError());
return(-1);
}
return(0);
}

//-------------------------------

} // if total
return(0);//end of start function
} //-start

//+------------------------------------------------------------------+
//| checking trade contexts |
//+------------------------------------------------------------------+

int Is_Trade_Allowed(int MaxWaiting_sec = 30)
{
if(!IsTradeAllowed())
{
int StartWaitingTime = GetTickCount();
Print("Trade context is busy! Wait until it is free...");
while(true)
{
if(IsStopped())
{
Print("The expert was terminated by the user!");
return(-1);
}
if(GetTickCount() - StartWaitingTime > MaxWaiting_sec * 1000)
{
Print("The waiting limit exceeded (" + MaxWaiting_sec + " seconds.)!");
return(-2);
}
if(IsTradeAllowed())
{
Print("Trade context has become free!");
return(0);
}
}
}
else
{
return(1);
}
}

//+------------------------------------------------------------------+
//| calculating progression long lots |
//+------------------------------------------------------------------+

double Get_Buy_Lots()
{
int total = OrdersTotal();

for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{

OrderSelect(cnt,SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == Magic_Number_Buy && OrderSymbol()==Symbol() && OrderType()==OP_BUY)
{

if(Progression_Allowed==false)
{
return(Initial_Lots);
}
//----------

if(Progression_Allowed==true)
{
if(OrderProfit()<0)
{
return(NormalizeDouble(OrderLots()*Lots_Multiply_Factor,2));
}
}
}
}
}

//+------------------------------------------------------------------+
//| calculating progression short lots |
//+------------------------------------------------------------------+

double Get_Sell_Lots()
{
int total = OrdersTotal();

for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == Magic_Number_Sell && OrderSymbol()==Symbol() && OrderType()==OP_SELL)
{

if(Progression_Allowed==false)
{
return(Initial_Lots);
}
//----------

if(Progression_Allowed==true)
{
if(OrderProfit()<0)
{
return(NormalizeDouble(OrderLots()*Lots_Multiply_Factor,2));
}
}
}
}
}

//+------------------------------------------------------------------+
//| counting trades |
//+------------------------------------------------------------------+

int Count_All()
{
int i, total, count;

total=OrdersTotal();

if (total==0)
{
return(0);
}

count=0;

for(i=0;i<total;i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol())
if(OrderMagicNumber() == Magic_Number_Buy || OrderMagicNumber() == Magic_Number_Sell)
{
count++;
}
} // for
return(count);
}

//+------------------------------------------------------------------+
//| closing trades |
//+------------------------------------------------------------------+

int Close_One_By_One()
{
int i, total5;

total5=OrdersTotal();

if (total5==0)
{
return(0);
}

for (i = total5-1 ; i >= 0 ; i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
if(OrderMagicNumber() == Magic_Number_Buy || OrderMagicNumber() == Magic_Number_Sell)
{
if(OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
return(0);
}
else /*OP_SELL*/
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
return(0);
}
} // if ordertype
} // for
return(0);
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+

void Comment_Stopped()
{
Comment
(
//"Initial_Lots = "+DoubleToStr(Initial_Lots,2),"\n",
//"Max_Trades = "+Max_Trades,"\n",
//"Pip_Step = "+Pip_Step,"\n",
//"Max_Price_Level = "+DoubleToStr(Max_Price_Level,4),"\n",
//"Min_Price_Level = "+DoubleToStr(Min_Price_Level,4),"\n",
//"Use_Equity_Profit_Take = "+Use_Equity_Profit_Take,"\n",
//"Dollar_Equity_Profit_Take = "+DoubleToStr(Dollar_Equity_Profit_Take,0),"\n",
//"Use_Equity_Loss_Cut = "+Use_Equity_Loss_Cut,"\n",
//"Dollar_Equity_Loss_Cut = "+DoubleToStr(Dollar_Equity_Loss_Cut,0),"\n","\n",
"STOPPED BY USER"
);
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
/*
void Comment_Null()
{
Comment
(
"Initial_Lots = "+DoubleToStr(Initial_Lots,2),"\n",
"Max_Trades = "+Max_Trades,"\n",
"Pip_Step = "+Pip_Step,"\n",
"Max_Price_Level = "+DoubleToStr(Max_Price_Level,4),"\n",
"Min_Price_Level = "+DoubleToStr(Min_Price_Level,4),"\n",
"Use_Equity_Profit_Take = "+Use_Equity_Profit_Take,"\n",
"Dollar_Equity_Profit_Take = "+DoubleToStr(Dollar_Equity_Profit_Take,0),"\n",
"Use_Equity_Loss_Cut = "+Use_Equity_Loss_Cut,"\n",
"Dollar_Equity_Loss_Cut = "+DoubleToStr(Dollar_Equity_Loss_Cut,0),"\n","\n",
"RUNNING"
);
}
*/
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+

void Comment_PL(string bs, double Profit_Or_Loss, int total6)
{
Comment
(
"\n",
"Active Orders = " + Count_All(),"\n",
"Profit/Loss = " + DoubleToStr((AccountEquity()-AccountBalance()),2) //,"\n",
//"Profit/Loss = "+ DoubleToStr(Profit_Or_Loss,2)//,"\n",
//"Initial_Lots = "+DoubleToStr(Initial_Lots,2),"\n",
//"Max_Trades = "+Max_Trades,"\n",
//"Pip_Step = "+Pip_Step,"\n",
//"Max_Price_Level = "+DoubleToStr(Max_Price_Level,4),"\n",
//"Min_Price_Level = "+DoubleToStr(Min_Price_Level,4),"\n",
//"total = "+total6,"\n",
//"Use_Equity_Profit_Take = "+Use_Equity_Profit_Take,"\n",
//"Dollar_Equity_Profit_Take = "+DoubleToStr(Dollar_Equity_Profit_Take,0),"\n",
//"Use_Equity_Loss_Cut = "+Use_Equity_Loss_Cut,"\n",
//"Dollar_Equity_Loss_Cut = "+DoubleToStr(Dollar_Equity_Loss_Cut,0),"\n","\n",
//bs
);
}

//----------------------------------------

 
mtkhreb:


Actually .. Did not finish to add the points that I mentioned to you

We are still trying with my friend to modify these points

I hope you help me with reported :)


This is the code : Rubber_Band_v.3.3.mq4

...(code)...

Thank you for your code. You have filled up things missing in my code, such as trade contexts and time control. The coming RUBBERBANDS_3 may contain your points, I guess, in different forms. Just wait and see..

 


look in the left side on my live account

ea rubberbands 3.3 here in the form the profit/loss in not the same as a demo on alpari lol can we fix it whats the reason....


......it is my kediet....lol

can we fix it



 

rubber bands 3.3 with some ajustments.......

extern double Lots_up_when_losing=0.01;//

...........

........

return(NormalizeDouble(OrderLots()+Lots_up_when_losing,2));

2 times in the code 3.3


tester on 3000eur

2 years steady grow almost 100 percent

max trades 10

pipstep 50

profit take 1200

im not sure thats not working on a live account help me with credit see down

eur/chf 1 hour

on alpari 5digits every tick

Strategy Tester Report
RUBBERBANDS_tester
AlpariUK-Micro-2 (Build 225)

SymboolEURCHF (Euro vs Swiss Franc)
Periode1 Uur (Uur1) 2006.11.28 00:00 - 2009.07.31 22:00 (2006.11.28 - 2009.08.01)
ModelElke tik (gebaseerd op alle beschikbare minste tijd frames met fractal interpolatie)
ParametersMagic_Number_Buy=111111; Magic_Number_Sell=222222; Progression_Allowed=true; Initial_Lots=0.01; Lots_Multiply_Factor=0.01; Max_Trades=10; Pip_Step=50; Use_Equity_Profit_Take=true; Dollar_Equity_Profit_Take=1200; Use_Equity_Loss_Cut=false; Dollar_Equity_Loss_Cut=57400; Time_Control=false; Start_Time="08:00"; End_Time="16:00"; Act_Now=false; Stop_Now=false; Close_Now=false; Use_In_Values=false; In_Max_Price_Level=0; In_Min_Price_Level=0;

Staven in test17435Gemodelleerde tikken11663239Modellering kwaliteit90.00%
Mismatched charts errors0




Initiële storting3000.00



Totale netto winst2765.10Brutto winst6669.01Brutto verlies-3903.91
Winst factor1.71Verwachte uitbetaling2.63

Absolute vermindering856.36Maximale vermindering1128.64 (20.31%)Relative drawdown30.33% (933.04)

Totale handelingen1053Short posities (won %)527 (61.10%)Long posities (won %)526 (57.98%)

Winst handelingen (% van totaal)627 (59.54%)Verlies handelingen (% van totaal)426 (40.46%)
Grootstewinst transactie116.67verlies transactie-67.31
Gemiddeldwinst transactie10.64verlies transactie-9.16
MaximumOpeenvolgende winst trades (winst in geld)5 (259.18)Opeenvolgende verlies trades (verlies in geld)6 (-142.85)
MaximaalOpeenvolgende winst (telling van winst transacties)259.18 (5)Opeenvolgende verliezen (telling van verlies transacties)-268.10 (5)
GemiddeldOpeenvolgende winsten2Opeenvolgende verliezen1


follow in demo:

http://hulspas.mt4stats.com/






 
hulspas:

<figure>

look in the left side on my live account

ea rubberbands 3.3 here in the form the profit/loss in not the same as a demo on alpari lol can we fix it whats the reason....


......it is my kediet....lol

can we fix it


Your result is amazng! The displayed profit/loss value is an approximate one, calculated just before closing.

 
hulspas:
StJojo:
hulspas:

thank you i cant't wait this ea have a good potential.!!! great work

look at exp amstell combine somethings of it that is a great ea too.


I have looked at "exp amstell" and it is indeed very neat !

i have bin busy 2 days to get something of the ground some combine of rubberbands and amstell

im not a coder but the ea is working.....:-)

//+------------------------------------------------------------------+
//|                                                  exp_Amstell.mq4 |
//|                                   Copyright © 2009, Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Yuriy Tokman"
#property link      "yuriytokman@gmail.com"
//òîðãîâëÿ áåç ñòîï ëîñîâ,ïåðèîä day,ïîêóïàòü ,åñëè öåíà îòêðûòèÿ ïîñëåäíåãî 
//îòêðûòîãî îðäåðà âûøå òåêóùåé öåíû,è çàêðûâàòü îðäåð ïî äîñòèæåíèè 1000 ïóíêòîâ,
//òî æå è ñ ïðîäàæåé.îòêðûâàòü îðäåð sell,åñëè ïîñëåäíèé îòêðûòûé sell íèæå òåêóùåé 
//öåíû. îòêðûâàòü ïîçèöèè ïî öåíàì îòêðûòèÿ
extern double My_Money_Profit_Target=10;     //The amount of money profit at which you want to close ALL open trades.
extern int    Test             = 300;
extern int    Distancebuy         = 500;
extern double Lotsbuy             = 0.02; 
extern int    TakeProfitbuy       = 10000;
extern int    Distancesell         = 500;
extern double Lotssell             = 0.01; 
extern int    TakeProfitsell       = 10000;            // Ðàçìåð òåéêà â ïóíêòàõ
extern bool UseTrailing        = true; //enabling/disabling T-SL
extern int TrailingStopsell        = 500;   //Trailing Stop Loss level
extern int TrailingStopbuy      = 0;   //Trailing Stop Loss level
extern int TrailingStep        = 500;    //Trailing Stop Loss step
extern double    priceAlert;
int Slippage=5;
int i;
extern int    StopLoss         = 50000;
 
  
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  int Magic=0;
  
for(int cnt=0;cnt<OrdersTotal();cnt++)// Ïåðåáèðàåì âñå îðäåðà
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);//îðäåð âûáèðàåòñÿ ñðåäè îòêðûòûõ è îòëîæåííûõ îðäåðîâ
      if( OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)// Ñîâïàäàåò ëè ñèìâîë îðäåðà( Çäåñü ïî íàäîáíîñòè åù¸ ìàãèê ìîæíî ïðîâåðèòü)
        {
         if(OrderType()==OP_BUY)//Îòáèðàåì ïîçèöèþ áàé
           {
            if(Bid-OrderOpenPrice()>TakeProfitbuy*Point || OrderOpenPrice()-Ask>StopLoss*Point)//
              {
               OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Violet); //çàêðûâàåì îðäåð
               return(0); // âûõîäèì
              }//StopLoss
           }
          if(OrderType()==OP_SELL)//Îòáèðàåì ïîçèöèþ ñåëë
           {
            if(OrderOpenPrice()-Ask>TakeProfitsell*Point || Bid-OrderOpenPrice()>StopLoss*Point)//
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Violet); //çàêðûâàåì îðäåð
               return(0); // âûõîäèì
              }
           }
         }
      }
//----
 int buy = 0, sell = 0;
//----
   if(!ExistPositions(NULL,OP_BUY))buy=1;
   else if(PriceOpenLastPos(NULL,OP_BUY)-Ask>Distancebuy*Point)buy=1; 
   
   if(!ExistPositions(NULL,OP_SELL))sell=1;
   else if(Bid-PriceOpenLastPos(NULL,OP_SELL)>Distancesell*Point)sell=1;   
//----
    if(buy==1)
    OrderSend(Symbol(),OP_BUY,Lotsbuy,Ask,3,0,0,"",0,0,Green);
   
    if(sell==1)
    OrderSend(Symbol(),OP_SELL,Lotssell,Bid,3,0,0,"",0,0,Red); 
     
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|  Îïèñàíèå : Âîçâðàùàåò ôëàã ñóùåñòâîâàíèÿ ïîçèöèé                          |
//+----------------------------------------------------------------------------+
//|  Ïàðàìåòðû:                                                                |
//|    sy - íàèìåíîâàíèå èíñòðóìåíòà   (""   - ëþáîé ñèìâîë,                   |
//|                                     NULL - òåêóùèé ñèìâîë)                 |
//|    op - îïåðàöèÿ                   (-1   - ëþáàÿ ïîçèöèÿ)                  |
//|    mn - MagicNumber                (-1   - ëþáîé ìàãèê)                    |
//|    ot - âðåìÿ îòêðûòèÿ             ( 0   - ëþáîå âðåìÿ îòêðûòèÿ)           |
//+----------------------------------------------------------------------------+
bool ExistPositions(string sy="", int op=-1, int mn=-1, datetime ot=0) {
  int i, k=OrdersTotal();
  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (ot<=OrderOpenTime()) return(True);
            }
          }
        }
      }
    }
  }
  return(False);
}
//+----------------------------------------------------------------------------+
//|  Âåðñèÿ   : 19.02.2008                                                     |
//|  Îïèñàíèå : Âîçâðàùàåò öåíó îòêðûòèÿ ïîñëåäíåé îòêðûòîé ïîçèöèé.           |
//+----------------------------------------------------------------------------+
//|  Ïàðàìåòðû:                                                                |
//|    sy - íàèìåíîâàíèå èíñòðóìåíòà   (""   - ëþáîé ñèìâîë,                   |
//|                                     NULL - òåêóùèé ñèìâîë)                 |
//|    op - îïåðàöèÿ                   (-1   - ëþáàÿ ïîçèöèÿ)                  |
//|    mn - MagicNumber                (-1   - ëþáîé ìàãèê)                    |
//+----------------------------------------------------------------------------+
double PriceOpenLastPos(string sy="", int op=-1, int mn=-1) {
  datetime t;
  double   r=0;
  int      i, k=OrdersTotal();
  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderOpenTime()) {
                t=OrderOpenTime();
                r=OrderOpenPrice();
              }
            }
          }
        }
      }
    }
  }
   
//+-------------------------------------------------------------------------------------------------+ 
//|                                      trail of open orders                                       |
if (UseTrailing)
{ 
  for (int trall=0; trall<OrdersTotal(); trall++) {
    if (!(OrderSelect(trall, SELECT_BY_POS, MODE_TRADES))) continue;
    if (OrderSymbol() != Symbol()) continue;       
 
    if (OrderType() == OP_BUY ) {
      if (Bid-OrderOpenPrice() > TrailingStopbuy*Point) {
        if (OrderStopLoss() < Bid-(TrailingStopbuy+TrailingStep-1)*Point || OrderStopLoss() == 0) {
          OrderModify(OrderTicket(), OrderOpenPrice(), Bid-TrailingStopbuy*Point, OrderTakeProfit(), 0, Blue);
       }
      }
    }
 
    if (OrderType() == OP_SELL) {
     if (OrderOpenPrice()-Ask > TrailingStopsell*Point) {
        if (OrderStopLoss() > Ask+(TrailingStopsell+TrailingStep-1)*Point || OrderStopLoss() == 0) {
          OrderModify(OrderTicket(), OrderOpenPrice(), Ask+TrailingStopsell*Point, OrderTakeProfit(), 0, Blue);
        }
     }
    }
  }
 }
//|                                      trail of open orders                                       |
//+-------------------------------------------------------------------------------------------------+
if (AccountProfit()>= My_Money_Profit_Target)
{
    for(i=OrdersTotal()-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),Slippage,Pink);
                         break;
               
          //Close opened short positions
          case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,Pink);
                          
          }
          
       if(result == false)
          {
            Sleep(3000);
          }  
       }
      Print ("Account Profit Reached. All Open Trades Have Been Closed");
      return(0);
   }  
   
   Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(),
           "\nMy Account Profit Target: ",My_Money_Profit_Target);
   
  return(r);
}
  

 

Hi St Jojo etal,

I’m a new comer to the ForEx, but have used computers for over 30 years and have done a little bit of programming along the way. I have read your description of your RubberBands EA and understand how and why it works and think it is a good approach as well. From the little bit I have learned this is a type of Martingale system like PipMaker though I may be mistaken about it being an apt description of your approach.

They both are great profit makers, but their downfall is that the losing trades don’t get canceled out EARLY. A tight Stop Loss on the losing trade of hedging pairs makes it very profitable. I also have a great little commercial utility from PipBoxer.Com that is a 2 stage Trailing Stop Loss (PBTS) that helps these systems and is very reasonably priced. It works with your RubberBands AE but unfortunately not with PipMaker.

When I use these programs more in a Scalping mode, which they are great for as they recognize and place a lot of trades very quickly (when your AE is in ‘Safety Mode’) and manually close out the losing trade very early as soon it is clear which of the trades is definitely losing money and the other one of the pair is making money both of these approaches are VERY profitable.

I have no experience programming MT4 and I don’t know if personal circumstances will permit me to undertake programming in this area. At this stage if I am going to do it I will wait till MT5 comes out very soon.

I appeal to you as well as other programmers to put an adjustable Stop Loss and preferably a Trailing Stop Loss as well onto both your RubberBands AND PipMaker and these systems will be GREAT and VERY profitable EAs.

Thanks for sharing. (8 >) Prosperous Trading (< 8)

DougRH

Reason: