
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thanks a ton Mladen .... You are great ...
Hi guys,
any help with my request on page 103, please? I have been looking for info online but couldnt get the alert for every 5 bar to go off (starting at the top of hour)
Thank you in advance
Dear Mladen/Mr Tools Can u please fix this ea so that it doesn't reopen trade once stop or tp is hit..
Coding help for stop loss
Hi Guys,
I have this EA that I cannot seem to change the Stop Loss on it.
No matter what I change, it will not change. I would like to change the stop loss to at least 300. Any ideas?
Thanks in advance
this is the code for it:
// generic user input
extern double Lots=1.0;
extern int TakeProfit=44;
extern int StopLoss=90;
extern bool RSIMethodA=false;
extern bool RSIMethodB=true;
extern int RSIValue=50;
extern bool AbandonMethodA=true;
extern bool AbandonMethodB=false;
extern int Abandon=101;
extern bool MoneyManagement=true;
extern int Risk=2;
extern int Slippage=3;
extern bool UseProfitLock=true;
extern int BreakEvenTrigger=25;
extern int BreakEven=3;
extern bool LiveTrading=false;
extern bool AccountIsMini=false;
extern int maxTradesPerPair=1;
extern int MagicNumber=5432;
double lotMM;
bool BuySignal=false;
bool SetBuy=false;
bool SellSignal=false;
bool SetSell=false;
// Bar handling
datetime bartime=0;
int bartick=0;
int TradeBars=0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if (UseProfitLock) ProfitLockStop();
if (AbandonMethodA || AbandonMethodB)
{
RunAbandonCheck();
RunAbandonMethods();
}
if (!SetLotsMM()) return(0);
RunOrderTriggerCalculations();
RunPairSpesificSettings();
RunNewOrderManagement();
//----
return(0);
}
/////////////////////////////////////////////////
// SetLotsMM - By Robert Cochran http://autoforex.biz
/////////////////////////////////////////////////
bool SetLotsMM()
{
double MarginCutoff;
if(!AccountIsMini) MarginCutoff = 1000;
if( AccountIsMini) MarginCutoff = 100;
if(AccountFreeMargin() < MarginCutoff) return(false);
if(MoneyManagement)
{
lotMM = MathCeil(AccountBalance() * Risk / 10000) / 10;
if(lotMM < 0.1) lotMM = Lots;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
// Enforce lot size boundaries
if(LiveTrading)
{
if( AccountIsMini) lotMM = lotMM * 10;
if(!AccountIsMini && lotMM < 1.0) lotMM = 1.0;
}
if(lotMM > 100) lotMM = 100;
}
else
{
lotMM = Lots; // Change MoneyManagement to 0 if you want the Lots parameter to be in effect
}
return(true);
}
//+------------------------------------------------------------------+
/////////////////////////////////////////////////
// RunOrderTriggerCalculations
/////////////////////////////////////////////////
bool RunOrderTriggerCalculations()
{
bool RSIPOS=false;
bool RSINEG=false;
// 3-period moving average on Bar[1]
double bullMA3=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,1);
// 7-period moving average on Bar[1]
double bearMA7=iMA(Symbol(),0,7,0,MODE_EMA,PRICE_CLOSE,1);
// 2-period moving average on Bar[2]
double RSI=iRSI(Symbol(),0,2,PRICE_CLOSE,2);
double RSI2=iRSI(Symbol(),0,2,PRICE_CLOSE,1);
// Determine what polarity RSI is in
if (RSIMethodA)
{
if(RSI>RSIValue && RSI2<RSIValue)
{
RSIPOS=true;
RSINEG=false;
}
else RSIPOS=false;
if(RSIRSIValue)
{
RSIPOS=false;
RSINEG=true;
}
else RSINEG=false;
}
if (RSIMethodB)
{
if(RSI>RSIValue)
{
RSIPOS=true;
RSINEG=false;
}
if(RSI<RSIValue)
{
RSIPOS=false;
RSINEG=true;
}
}
if ((bullMA3 > (bearMA7+Point)) && RSINEG)
{
BuySignal=true;
}
else BuySignal=false;
if ((bullMA3 < (bearMA7-Point)) && RSIPOS)
{
SellSignal=true;
}
else SellSignal=false;
return(true);
}
/////////////////////////////////////////////////
// OpenOrdersBySymbolAndComment
/////////////////////////////////////////////////
int OpenOrdersForThisEA()
{
int ofts=0;
for(int x=0;x<OrdersTotal();x++)
{
OrderSelect(x, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
ofts++;
}
}
return(ofts);
}
/////////////////////////////////////////////////
// PROFIT LOCK - By Robert Cochran - http://autoforex.biz
/////////////////////////////////////////////////
bool ProfitLockStop()
{
if( OpenOrdersForThisEA() > 0 )
{
for ( int i = 0; i < OrdersTotal(); i++){
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
//--- LONG TRADES
if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber()== MagicNumber)
{
if (Bid >= OrderOpenPrice() + BreakEvenTrigger*Point &&
OrderOpenPrice() > OrderStopLoss())
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + BreakEven * Point, OrderTakeProfit(), Green);
}
}
//--- SHORT TRADES
if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==MagicNumber)
{
if (Ask <= OrderOpenPrice() - BreakEvenTrigger*Point &&
OrderOpenPrice() < OrderStopLoss())
{
OrderModify(OrderTicket(), OrderOpenPrice(),OrderOpenPrice() - BreakEven * Point, OrderTakeProfit(), Blue);
}
}
}
}
}
/////////////////////////////////////////////////
// ABANDON CHECK
/////////////////////////////////////////////////
bool RunAbandonCheck()
{
if( OpenOrdersForThisEA() > 0 )
{
if (TradeBars == 0 && bartick == 0)
{
for (int i = 0; i < OrdersTotal(); i++)
{
if (OrderSymbol() == Symbol())
{
TradeBars = MathFloor(CurTime() - OrderOpenTime())/60/Period();
bartime = Time[0];
bartick = TradeBars;
}
}
}
if(bartime!=Time[0])
{
bartime=Time[0];
bartick++;
}
}
return(true);
}
/////////////////////////////////////////////////
// RunAbandonMethods
/////////////////////////////////////////////////
bool RunAbandonMethods()
{
if( OpenOrdersForThisEA() > 0 )
{
for (int i = 0; i < OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (AbandonMethodA && bartick==Abandon)//Force "HEDGE" after abandon
{
// LONG TRADES
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&
OrderMagicNumber()==MagicNumber)
{
OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue);
SetSell=true;
continue;
}
// SHORT TRADES
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&
OrderMagicNumber()==MagicNumber)
{
OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue);
SetBuy=true;
continue;
}
}
if (AbandonMethodB && bartick==Abandon)//Indicators decide direction after abandon
{
// LONG TRADES
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&
OrderMagicNumber()==MagicNumber)
{
OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);
continue;
}
// SHORT TRADES
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&
OrderMagicNumber()==MagicNumber)
{
OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
continue;
}
}
}
}
return(true);
}
/////////////////////////////////////////////////
// RunPairSpesificSettings
/////////////////////////////////////////////////
bool RunPairSpesificSettings()
{
// set up the symbol optimizations
if (Symbol()=="GBPUSD")
{
TakeProfit=55; StopLoss=100; Abandon=69;
}
return(true);
}
/////////////////////////////////////////////////
// RunNewOrderManagement
/////////////////////////////////////////////////
bool RunNewOrderManagement()
{
double TP,SL;
if( OpenOrdersForThisEA() < maxTradesPerPair )
{
//ENTRY Ask(buy, long)
if (BuySignal || SetBuy)
{
SL = Ask - StopLoss*Point;
TP = Ask + TakeProfit*Point;
OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP,"TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);
bartick=0;
if (SetBuy) SetBuy=false;
return(true);
}
//ENTRY Bid (sell, short)
if (SellSignal || SetSell)
{
SL = Bid + StopLoss*Point;
TP = Bid - TakeProfit*Point;
OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,TP,"TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);
bartick=0;
if (SetSell) SetSell=false;
return(true);
}
}
return(true);
}
Hi Guys,
I have this EA that I cannot seem to change the Stop Loss on it.
No matter what I change, it will not change. I would like to change the stop loss to at least 300. Any ideas?
Thanks in advance
this is the code for it:
// generic user input
extern double Lots=1.0;
extern int TakeProfit=44;
extern int StopLoss=90;
extern bool RSIMethodA=false;
extern bool RSIMethodB=true;
extern int RSIValue=50;
extern bool AbandonMethodA=true;
extern bool AbandonMethodB=false;
extern int Abandon=101;
extern bool MoneyManagement=true;
extern int Risk=2;
extern int Slippage=3;
extern bool UseProfitLock=true;
extern int BreakEvenTrigger=25;
extern int BreakEven=3;
extern bool LiveTrading=false;
extern bool AccountIsMini=false;
extern int maxTradesPerPair=1;
extern int MagicNumber=5432;
double lotMM;
bool BuySignal=false;
bool SetBuy=false;
bool SellSignal=false;
bool SetSell=false;
// Bar handling
datetime bartime=0;
int bartick=0;
int TradeBars=0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if (UseProfitLock) ProfitLockStop();
if (AbandonMethodA || AbandonMethodB)
{
RunAbandonCheck();
RunAbandonMethods();
}
if (!SetLotsMM()) return(0);
RunOrderTriggerCalculations();
RunPairSpesificSettings();
RunNewOrderManagement();
//----
return(0);
}
/////////////////////////////////////////////////
// SetLotsMM - By Robert Cochran Welcome autoforex.biz - BlueHost.com
/////////////////////////////////////////////////
bool SetLotsMM()
{
double MarginCutoff;
if(!AccountIsMini) MarginCutoff = 1000;
if( AccountIsMini) MarginCutoff = 100;
if(AccountFreeMargin() < MarginCutoff) return(false);
if(MoneyManagement)
{
lotMM = MathCeil(AccountBalance() * Risk / 10000) / 10;
if(lotMM < 0.1) lotMM = Lots;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
// Enforce lot size boundaries
if(LiveTrading)
{
if( AccountIsMini) lotMM = lotMM * 10;
if(!AccountIsMini && lotMM < 1.0) lotMM = 1.0;
}
if(lotMM > 100) lotMM = 100;
}
else
{
lotMM = Lots; // Change MoneyManagement to 0 if you want the Lots parameter to be in effect
}
return(true);
}
//+------------------------------------------------------------------+
/////////////////////////////////////////////////
// RunOrderTriggerCalculations
/////////////////////////////////////////////////
bool RunOrderTriggerCalculations()
{
bool RSIPOS=false;
bool RSINEG=false;
// 3-period moving average on Bar[1]
double bullMA3=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,1);
// 7-period moving average on Bar[1]
double bearMA7=iMA(Symbol(),0,7,0,MODE_EMA,PRICE_CLOSE,1);
// 2-period moving average on Bar[2]
double RSI=iRSI(Symbol(),0,2,PRICE_CLOSE,2);
double RSI2=iRSI(Symbol(),0,2,PRICE_CLOSE,1);
// Determine what polarity RSI is in
if (RSIMethodA)
{
if(RSI>RSIValue && RSI2<RSIValue)
{
RSIPOS=true;
RSINEG=false;
}
else RSIPOS=false;
if(RSIRSIValue)
{
RSIPOS=false;
RSINEG=true;
}
else RSINEG=false;
}
if (RSIMethodB)
{
if(RSI>RSIValue)
{
RSIPOS=true;
RSINEG=false;
}
if(RSI<RSIValue)
{
RSIPOS=false;
RSINEG=true;
}
}
if ((bullMA3 > (bearMA7+Point)) && RSINEG)
{
BuySignal=true;
}
else BuySignal=false;
if ((bullMA3 < (bearMA7-Point)) && RSIPOS)
{
SellSignal=true;
}
else SellSignal=false;
return(true);
}
/////////////////////////////////////////////////
// OpenOrdersBySymbolAndComment
/////////////////////////////////////////////////
int OpenOrdersForThisEA()
{
int ofts=0;
for(int x=0;x<OrdersTotal();x++)
{
OrderSelect(x, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
ofts++;
}
}
return(ofts);
}
/////////////////////////////////////////////////
// PROFIT LOCK - By Robert Cochran - Welcome autoforex.biz - BlueHost.com
/////////////////////////////////////////////////
bool ProfitLockStop()
{
if( OpenOrdersForThisEA() > 0 )
{
for ( int i = 0; i < OrdersTotal(); i++){
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
//--- LONG TRADES
if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber()== MagicNumber)
{
if (Bid >= OrderOpenPrice() + BreakEvenTrigger*Point &&
OrderOpenPrice() > OrderStopLoss())
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + BreakEven * Point, OrderTakeProfit(), Green);
}
}
//--- SHORT TRADES
if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==MagicNumber)
{
if (Ask <= OrderOpenPrice() - BreakEvenTrigger*Point &&
OrderOpenPrice() < OrderStopLoss())
{
OrderModify(OrderTicket(), OrderOpenPrice(),OrderOpenPrice() - BreakEven * Point, OrderTakeProfit(), Blue);
}
}
}
}
}
/////////////////////////////////////////////////
// ABANDON CHECK
/////////////////////////////////////////////////
bool RunAbandonCheck()
{
if( OpenOrdersForThisEA() > 0 )
{
if (TradeBars == 0 && bartick == 0)
{
for (int i = 0; i < OrdersTotal(); i++)
{
if (OrderSymbol() == Symbol())
{
TradeBars = MathFloor(CurTime() - OrderOpenTime())/60/Period();
bartime = Time[0];
bartick = TradeBars;
}
}
}
if(bartime!=Time[0])
{
bartime=Time[0];
bartick++;
}
}
return(true);
}
/////////////////////////////////////////////////
// RunAbandonMethods
/////////////////////////////////////////////////
bool RunAbandonMethods()
{
if( OpenOrdersForThisEA() > 0 )
{
for (int i = 0; i < OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (AbandonMethodA && bartick==Abandon)//Force "HEDGE" after abandon
{
// LONG TRADES
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&
OrderMagicNumber()==MagicNumber)
{
OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue);
SetSell=true;
continue;
}
// SHORT TRADES
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&
OrderMagicNumber()==MagicNumber)
{
OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue);
SetBuy=true;
continue;
}
}
if (AbandonMethodB && bartick==Abandon)//Indicators decide direction after abandon
{
// LONG TRADES
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&
OrderMagicNumber()==MagicNumber)
{
OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);
continue;
}
// SHORT TRADES
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&
OrderMagicNumber()==MagicNumber)
{
OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
continue;
}
}
}
}
return(true);
}
/////////////////////////////////////////////////
// RunPairSpesificSettings
/////////////////////////////////////////////////
bool RunPairSpesificSettings()
{
// set up the symbol optimizations
if (Symbol()=="GBPUSD")
{
TakeProfit=55; StopLoss=100; Abandon=69;
}
return(true);
}
/////////////////////////////////////////////////
// RunNewOrderManagement
/////////////////////////////////////////////////
bool RunNewOrderManagement()
{
double TP,SL;
if( OpenOrdersForThisEA() < maxTradesPerPair )
{
//ENTRY Ask(buy, long)
if (BuySignal || SetBuy)
{
SL = Ask - StopLoss*Point;
TP = Ask + TakeProfit*Point;
OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP,"TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);
bartick=0;
if (SetBuy) SetBuy=false;
return(true);
}
//ENTRY Bid (sell, short)
if (SellSignal || SetSell)
{
SL = Bid + StopLoss*Point;
TP = Bid - TakeProfit*Point;
OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,TP,"TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);
bartick=0;
if (SetSell) SetSell=false;
return(true);
}
}
return(true);
}It will always set StopLoss to 100 if the symbol is GBPUSD
For others it should work OK (except that you should multiply the stop loss by 10 for 5 digit brokers since the EA works with points not pips)
I am using it on USD/JPY at the moment and stop loss still stays at 100.
Where would i find the stop loss multiplier?
I am using it on USD/JPY at the moment and stop loss still stays at 100. Where would i find the stop loss multiplier?
Stop loss and take profit are set in this part :
{
double TP,SL;
if( OpenOrdersForThisEA() < maxTradesPerPair )
{
//ENTRY Ask(buy, long)
if (BuySignal || SetBuy)
{
SL = Ask - StopLoss*Point;
TP = Ask + TakeProfit*Point;
OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP ,"TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);
bartick=0;
if (SetBuy) SetBuy=false;
return(true);
}
//ENTRY Bid (sell, short)
if (SellSignal || SetSell)
{
SL = Bid + StopLoss*Point;
TP = Bid - TakeProfit*Point;
OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,T P,"TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);
bartick=0;
if (SetSell) SetSell=false;
return(true);
}
}
return(true);
}[/PHP]
As of stop loss that stays 100 : this part of code
[PHP]bool RunPairSpesificSettings()
{
// set up the symbol optimizations
if (Symbol()=="GBPUSD")
{
TakeProfit=55; StopLoss=100; Abandon=69;
}
return(true);
}is activated only if the symbol is "GBPUSD" (as it is seen from the code) so only in that case it reverts. Check your code again and look for 100 and you will find what is going on with your stop losses since in the code you attached stop loss is reverted only in the case of GBPUSD
It still wont change stop loss, even if I change the currency pairs to the ones I am trading with. This EA would of been perfect if the stop loss could be changed
Thank you for trying to help anyway.
Hi coders,
Could anyone help modify this squeeze break indicator to have a EMA bollinger band option as well as an EMA keltner channel option?
Thanks
:)
Hi coders,
Could anyone help modify this squeeze break indicator to have a EMA bollinger band option as well as an EMA keltner channel option?
ThanksHi Iwillsurvive, changed the indicator so you will have a choice of ma's in both the keltner and bollinger bands, by default it's set to EMA.