
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 mntiwana and malden. but why do I have to buy again? Can you send these indicators in messages
Send the original email with a link you have received when you bought that indicator to support@forex-tsd.com and, if all is correct, you shall receive an updated version.
Okay mlanden. but the indicator before nmc looks interesting than after nmc . Is it just my feelings?
Okay mlanden. but the indicator before nmc looks interesting than after nmc . Is it just my feelings?
The results of the "nmc" version are not changed compared to the "pre-nmc" version at all. "nmc" stands for "new metatrader compatible"
all the best
Why ?
Mladen,
Please can you give me the reason why this ea doesn't work.
//----------------------- EA PARAMETER
extern string
Expert_Name = "---------- Pending Order EA v1",
Expert_Name2 = "---------- For current price set EntryLevel = 0";
extern double
EntryLevel = 1.8600,
Distance = 100,
StopLoss = 50,
TakeProfit = 50,
TrailingStop = 50;
extern string
Order_Setting = "---------- Order Setting";
extern int
NumberOfTries = 5,
Slippage = 5,
MagicNumber = 1234;
extern string
MM_Parameters = "---------- Money Management";
extern double
Lots =0.01;
extern bool
MM = false, //Use Money Management or not
AccountIsMicro = true; //Use Micro-Account or not
extern int
Risk = 0; //10%
extern string
Testing_Parameters= "---------- Back Test Parameter";
extern bool
Show_Settings = true;
//----------------------- GLOBAL VARIABLE
static int
TimeFrame = 0;
string
TicketComment = "PendingOrderEA v2",
LastTrade;
bool
TradeAllow = true,
EntryAllow = true;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----------------------- GENERATE MAGIC NUMBER AND TICKET COMMENT
//----------------------- SOURCE : PENGIE
MagicNumber = subGenerateMagicNumber(MagicNumber, Symbol(), Period());
TicketComment = StringConcatenate(TicketComment, "-", Symbol(), "-", Period());
//----------------------- SHOW EA SETTING ON THE CHART
//----------------------- SOURCE : CODERSGURU
if(Show_Settings) subPrintDetails();
else Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----------------------- PREVENT RE-COUNTING WHILE USER CHANGING TIME FRAME
//----------------------- SOURCE : CODERSGURU
TimeFrame=Period();
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double
// BuyLevel,
SellLevel;
int
cnt,
ticket,
total;
//----------------------- SET BUY and SELL PRICE
if(EntryLevel==0) EntryLevel = Bid;
// BuyLevel = EntryLevel + Distance*Point;
SellLevel = EntryLevel - Distance*Point;
// if((BuyLevel-Ask)<10*Point || (Bid-SellLevel)<10*Point)
// {
// Comment("Invalid Entry Price or Distance");
// return(0);
// }
//----------------------- ADJUST LOTS IF USING MONEY MANAGEMENT
if(MM) Lots = subLotSize();
//----------------------- ENTRY
//----------------------- TOTAL ORDER BASE ON MAGICNUMBER AND SYMBOL
total = subTotalTrade();
//----------------------- SET THE ORDER ONLY 1 TIME
if(TradeAllow)
{
//----------------------- IF NO TRADE
if(total<1 && EntryAllow)
{
ticket = OrderSend(Symbol(),OP_SELLSTOP,Lots,SellLevel,Slippage,SellLevel+StopLoss*Point,SellLevel-TakeProfit*Point,TicketComment,MagicNumber,0,Red);
// ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyLevel,Slippage,BuyLevel-StopLoss*Point,BuyLevel+TakeProfit*Point,TicketComment,MagicNumber,0,Green);
EntryAllow = false;
return(0);
}
if(total==1)
{
subDeleteOrder();
TradeAllow = false;
}
}
//----------------------- TRAILING STOP SECTION
if(TrailingStop>0 && subTotalTrade()>0){
total = OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber)
{
subTrailingStop(OrderType());
return(0);
}
}
}
return(0);
}
//----------------------- END PROGRAM
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS
//+------------------------------------------------------------------+
//----------------------- MONEY MANAGEMENT FUNCTION
//----------------------- SOURCE : CODERSGURU
double subLotSize()
{
double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;
if(AccountIsMicro==false) //normal account
{
if(lotMM < 0.1) lotMM = Lots;
if((lotMM > 0.5) && (lotMM < 1)) lotMM = 0.5;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
if(lotMM > 100) lotMM = 100;
}
else //micro account
{
if(lotMM < 0.01) lotMM = Lots;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
if(lotMM > 100) lotMM = 100;
}
return (lotMM);
}
//----------------------- NUMBER OF ORDER BASE ON SYMBOL AND MAGICNUMBER FUNCTION
int subTotalTrade()
{
int
cnt,
total = 0;
for(cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber) total++;
}
return(total);
}
//----------------------- DELETE ORDER FUNCTION
void subDeleteOrder()
{
int
cnt,
total = 0;
total = OrdersTotal();
for(cnt=total-1;cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber)
{
switch(OrderType())
{
// case OP_BUYLIMIT :
// case OP_BUYSTOP :
case OP_SELLLIMIT:
case OP_SELLSTOP :
OrderDelete(OrderTicket());
}
}
}
}
//----------------------- TRAILING STOP FUNCTION
//----------------------- SOURCE : CODERSGURU
//----------------------- MODIFIED : FIREDAVE
void subTrailingStop(int Type)
{
if(Type==OP_BUY) // buy position is opened
{
if(Bid-OrderOpenPrice()>Point*TrailingStop &&
OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
if(Type==OP_SELL) // sell position is opened
{
if(OrderOpenPrice()-Ask>Point*TrailingStop)
{
if(OrderStopLoss()>Ask+Point*TrailingStop || OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
//----------------------- GENERATE MAGIC NUMBER BASE ON SYMBOL AND TIME FRAME FUNCTION
//----------------------- SOURCE : PENGIE
//----------------------- MODIFIED : FIREDAVE
int subGenerateMagicNumber(int MagicNumber, string symbol, int timeFrame)
{
int isymbol = 0;
if (symbol == "EURUSD") isymbol = 1;
else if (symbol == "GBPUSD") isymbol = 2;
else if (symbol == "USDJPY") isymbol = 3;
else if (symbol == "AUDCAD") isymbol = 4;
else if (symbol == "AUDUSD") isymbol = 5;
else if (symbol == "USDCAD") isymbol = 6;
else if (symbol == "EURGBP") isymbol = 7;
else if (symbol == "EURJPY") isymbol = 8;
else if (symbol == "EURCHF") isymbol = 9;
else if (symbol == "EURAUD") isymbol = 10;
else if (symbol == "EURCAD") isymbol = 11;
else if (symbol == "GBPUSD") isymbol = 12;
else if (symbol == "GBPJPY") isymbol = 13;
else if (symbol == "GBPCHF") isymbol = 14;
else if (symbol == "GBPAUD") isymbol = 15;
else if (symbol == "GBPCAD") isymbol = 16;
else isymbol = 17;
if(isymbol<10) MagicNumber = MagicNumber * 10;
return (StrToInteger(StringConcatenate(MagicNumber, isymbol, timeFrame)));
}
//----------------------- PRINT COMMENT FUNCTION
//----------------------- SOURCE : CODERSGURU
void subPrintDetails()
{
string sComment = "";
string sp = "----------------------------------------\n";
string NL = "\n";
sComment = sp;
sComment = sComment + "TakeProfit=" + DoubleToStr(TakeProfit,0) + " | ";
sComment = sComment + "TrailingStop=" + DoubleToStr(TrailingStop,0) + " | ";
sComment = sComment + "StopLoss=" + DoubleToStr(StopLoss,0) + NL;
sComment = sComment + sp;
sComment = sComment + "Lots=" + DoubleToStr(Lots,2) + " | ";
sComment = sComment + "MM=" + subBoolToStr(MM) + " | ";
sComment = sComment + "Risk=" + DoubleToStr(Risk,0) + "%" + NL;
sComment = sComment + sp;
Comment(sComment);
}
//----------------------- BOOLEN VARIABLE TO STRING FUNCTION
//----------------------- SOURCE : CODERSGURU
string subBoolToStr ( bool value)
{
if(value) return ("True");
else return ("False");
}
//----------------------- END FUNCTION
Thanks in advance.
Jo
mladen,
hope you well. the below has two errors on compiling. kindly assist
mladen, hope you well. the below has two errors on compiling. kindly assist
candyman752
Try it out now : rstochalert-4tf_1.mq4
Dearest MLADEN,
(my questions are always about repairing help more than coding help)
i have a request to understand.....see at 2 pictures i added,1st is with 1 error and 2 warnings concerning line 70 and 72....as you can see in picture 2nd,i replaced and 1 error and 1 warning removed......my question is...is it right to do this way....and second question about the 2nd warning that is still behind at line 80...if leaved as it is,no problem in functioning ?
regards
mntiwana
Dearest MLADEN,
(my questions are always about repairing help more than coding help)
i have a request to understand.....see at 2 pictures i added,1st is with 1 error and 2 warnings concerning line 70 and 72....as you can see in picture 2nd,i replaced and 1 error and 1 warning removed......my question is...is it right to do this way....and second question about the 2nd warning that is still behind at line 80...if leaved as it is,no problem in functioning ?
regards
mntiwanamntiwana
that way all is OK. you did the changes OK
mntiwana that way all is OK. you did the changes OK
so so much thanks great boss for encouraging a curious student.
my best regards
Mladen,
Please can you give me the reason why this ea doesn't work.
//----------------------- EA PARAMETER
extern string
Expert_Name = "---------- Pending Order EA v1",
Expert_Name2 = "---------- For current price set EntryLevel = 0";
extern double
EntryLevel = 1.8600,
Distance = 100,
StopLoss = 50,
TakeProfit = 50,
TrailingStop = 50;
extern string
Order_Setting = "---------- Order Setting";
extern int
NumberOfTries = 5,
Slippage = 5,
MagicNumber = 1234;
extern string
MM_Parameters = "---------- Money Management";
extern double
Lots =0.01;
extern bool
MM = false, //Use Money Management or not
AccountIsMicro = true; //Use Micro-Account or not
extern int
Risk = 0; //10%
extern string
Testing_Parameters= "---------- Back Test Parameter";
extern bool
Show_Settings = true;
//----------------------- GLOBAL VARIABLE
static int
TimeFrame = 0;
string
TicketComment = "PendingOrderEA v2",
LastTrade;
bool
TradeAllow = true,
EntryAllow = true;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----------------------- GENERATE MAGIC NUMBER AND TICKET COMMENT
//----------------------- SOURCE : PENGIE
MagicNumber = subGenerateMagicNumber(MagicNumber, Symbol(), Period());
TicketComment = StringConcatenate(TicketComment, "-", Symbol(), "-", Period());
//----------------------- SHOW EA SETTING ON THE CHART
//----------------------- SOURCE : CODERSGURU
if(Show_Settings) subPrintDetails();
else Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----------------------- PREVENT RE-COUNTING WHILE USER CHANGING TIME FRAME
//----------------------- SOURCE : CODERSGURU
TimeFrame=Period();
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double
// BuyLevel,
SellLevel;
int
cnt,
ticket,
total;
//----------------------- SET BUY and SELL PRICE
if(EntryLevel==0) EntryLevel = Bid;
// BuyLevel = EntryLevel + Distance*Point;
SellLevel = EntryLevel - Distance*Point;
// if((BuyLevel-Ask)<10*Point || (Bid-SellLevel)<10*Point)
// {
// Comment("Invalid Entry Price or Distance");
// return(0);
// }
//----------------------- ADJUST LOTS IF USING MONEY MANAGEMENT
if(MM) Lots = subLotSize();
//----------------------- ENTRY
//----------------------- TOTAL ORDER BASE ON MAGICNUMBER AND SYMBOL
total = subTotalTrade();
//----------------------- SET THE ORDER ONLY 1 TIME
if(TradeAllow)
{
//----------------------- IF NO TRADE
if(total<1 && EntryAllow)
{
ticket = OrderSend(Symbol(),OP_SELLSTOP,Lots,SellLevel,Slippage,SellLevel+StopLoss*Point,SellLevel-TakeProfit*Point,TicketComment,MagicNumber,0,Red);
// ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyLevel,Slippage,BuyLevel-StopLoss*Point,BuyLevel+TakeProfit*Point,TicketComment,MagicNumber,0,Green);
EntryAllow = false;
return(0);
}
if(total==1)
{
subDeleteOrder();
TradeAllow = false;
}
}
//----------------------- TRAILING STOP SECTION
if(TrailingStop>0 && subTotalTrade()>0){
total = OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber)
{
subTrailingStop(OrderType());
return(0);
}
}
}
return(0);
}
//----------------------- END PROGRAM
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS
//+------------------------------------------------------------------+
//----------------------- MONEY MANAGEMENT FUNCTION
//----------------------- SOURCE : CODERSGURU
double subLotSize()
{
double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;
if(AccountIsMicro==false) //normal account
{
if(lotMM < 0.1) lotMM = Lots;
if((lotMM > 0.5) && (lotMM < 1)) lotMM = 0.5;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
if(lotMM > 100) lotMM = 100;
}
else //micro account
{
if(lotMM < 0.01) lotMM = Lots;
if(lotMM > 1.0) lotMM = MathCeil(lotMM);
if(lotMM > 100) lotMM = 100;
}
return (lotMM);
}
//----------------------- NUMBER OF ORDER BASE ON SYMBOL AND MAGICNUMBER FUNCTION
int subTotalTrade()
{
int
cnt,
total = 0;
for(cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber) total++;
}
return(total);
}
//----------------------- DELETE ORDER FUNCTION
void subDeleteOrder()
{
int
cnt,
total = 0;
total = OrdersTotal();
for(cnt=total-1;cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber)
{
switch(OrderType())
{
// case OP_BUYLIMIT :
// case OP_BUYSTOP :
case OP_SELLLIMIT:
case OP_SELLSTOP :
OrderDelete(OrderTicket());
}
}
}
}
//----------------------- TRAILING STOP FUNCTION
//----------------------- SOURCE : CODERSGURU
//----------------------- MODIFIED : FIREDAVE
void subTrailingStop(int Type)
{
if(Type==OP_BUY) // buy position is opened
{
if(Bid-OrderOpenPrice()>Point*TrailingStop &&
OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
if(Type==OP_SELL) // sell position is opened
{
if(OrderOpenPrice()-Ask>Point*TrailingStop)
{
if(OrderStopLoss()>Ask+Point*TrailingStop || OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
//----------------------- GENERATE MAGIC NUMBER BASE ON SYMBOL AND TIME FRAME FUNCTION
//----------------------- SOURCE : PENGIE
//----------------------- MODIFIED : FIREDAVE
int subGenerateMagicNumber(int MagicNumber, string symbol, int timeFrame)
{
int isymbol = 0;
if (symbol == "EURUSD") isymbol = 1;
else if (symbol == "GBPUSD") isymbol = 2;
else if (symbol == "USDJPY") isymbol = 3;
else if (symbol == "AUDCAD") isymbol = 4;
else if (symbol == "AUDUSD") isymbol = 5;
else if (symbol == "USDCAD") isymbol = 6;
else if (symbol == "EURGBP") isymbol = 7;
else if (symbol == "EURJPY") isymbol = 8;
else if (symbol == "EURCHF") isymbol = 9;
else if (symbol == "EURAUD") isymbol = 10;
else if (symbol == "EURCAD") isymbol = 11;
else if (symbol == "GBPUSD") isymbol = 12;
else if (symbol == "GBPJPY") isymbol = 13;
else if (symbol == "GBPCHF") isymbol = 14;
else if (symbol == "GBPAUD") isymbol = 15;
else if (symbol == "GBPCAD") isymbol = 16;
else isymbol = 17;
if(isymbol<10) MagicNumber = MagicNumber * 10;
return (StrToInteger(StringConcatenate(MagicNumber, isymbol, timeFrame)));
}
//----------------------- PRINT COMMENT FUNCTION
//----------------------- SOURCE : CODERSGURU
void subPrintDetails()
{
string sComment = "";
string sp = "----------------------------------------\n";
string NL = "\n";
sComment = sp;
sComment = sComment + "TakeProfit=" + DoubleToStr(TakeProfit,0) + " | ";
sComment = sComment + "TrailingStop=" + DoubleToStr(TrailingStop,0) + " | ";
sComment = sComment + "StopLoss=" + DoubleToStr(StopLoss,0) + NL;
sComment = sComment + sp;
sComment = sComment + "Lots=" + DoubleToStr(Lots,2) + " | ";
sComment = sComment + "MM=" + subBoolToStr(MM) + " | ";
sComment = sComment + "Risk=" + DoubleToStr(Risk,0) + "%" + NL;
sComment = sComment + sp;
Comment(sComment);
}
//----------------------- BOOLEN VARIABLE TO STRING FUNCTION
//----------------------- SOURCE : CODERSGURU
string subBoolToStr ( bool value)
{
if(value) return ("True");
else return ("False");
}
//----------------------- END FUNCTION
Thanks in advance.
JoJo,
Can you please attach the mq4 file? Very difficult to test it this way