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
Never seem to get anyone to help, guys please respond
With a moderate amount of guess work, I would suggest that the problem is with the indicator, or your extension to it, and not your use of iCustom. Perhaps it would be better to assign buffers 2 and 3 together with the alerts? (Though I couldn't work out how/when their index-zero ([0]) values would be assigned anyhow.)
Price Data Information
My exits and entry are based on signals generating a condition on the open of the next bar (entry and exit), should I be using the open prices for indicators and moving averages? I always have used end of day data for stock trades, so naturally that's what I've gravitated toward. What's the consensus out there?
Just thinking
how do you set a trailing stop at the pairs minimum Stop Level so if the stop level is at 4 pip or 25 pip the sl will kick in at that depending on the pair.
I should say that how do you use the contract specification for each pair.
Cheers
Beno
Sidus_Bago indicator
Hi increase,
I wonder if you can help me to code Sidus_Bago to be a MTF indicator. I think this indicator very good too.
Sidus_Bago is here:
Sidus System confirmation' indicator?
Thank you very much.
Can anyone help me with this EA?
Hi all,
I've had a go at my first EA but it won't compile; I get an error "'\end of program' - unbalanced left parenthesis" and I've gone through it a few times but can't find the problem. Don't worry about the logic of the trading strategy (unless you're keen), I'll work on that once it compiles and runs...
Apparently I don't have permission to attach files, so sorry about the cut and paste too.
Thanks,
Rob,
Perth, Aus
//---------------
//+------------------------------------------------------------------+
//| Rob_Ea.mq4 |
//| Rob Cousins |
//| |
//+------------------------------------------------------------------+
#property copyright "Rob Cousins"
#property link ""
#define MAGICMA 20090216
//---- input parameters
extern double Lots;
extern int Short_MA=5;
extern int Long_MA=15;
extern double Stoch_Upper=70.0;
extern double Stoch_Lower=30.0;
extern double RSI_Upper=80.0;
extern double RSI_Lower=20.0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
string Current_Indication()
{
// Moving Average variables
double MA_Short;
double MA_Long;
string Current_MA_Indicator;
string Previous_MA_Indicator;
string MA_Indicator;
// Stochastic Variables
string Current_Stoch_Indicator;
string Previous_Stoch_Indicator;
string Stoch_Indicator;
// RSI Variables
string Current_RSI_Indicator;
string Previous_RSI_Indicator;
string RSI_Indicator;
// --------------------------------------
// first get MAs and check for a MA Cross
// --------------------------------------
MA_Short=iMA(NULL,0,Short_MA,0,1,PRICE_MEDIAN,0);
MA_Long=iMA(NULL,0,Long_MA,0,0,PRICE_MEDIAN,0);
if (MA_Short>MA_Long) Current_MA_Indicator="BUY";
if (MA_Short<MA_Long) Current_MA_Indicator="SELL";
// set the previous and current value using the shifted MA (the last '1' in the options)
if (iMA(NULL,0,Short_MA,0,1,PRICE_MEDIAN,1)>iMA(NULL,0,Long_MA,0,0,PRICE_MEDIAN,1)) Previous_MA_Indicator="BUY";
if (iMA(NULL,0,Short_MA,0,1,PRICE_MEDIAN,1)<iMA(NULL,0,Long_MA,0,0,PRICE_MEDIAN,1)) Previous_MA_Indicator="SELL";
if ((Current_MA_Indicator=="BUY") && (Previous_MA_Indicator=="BUY")) MA_Indicator="BUY";
if ((Current_MA_Indicator=="SELL") && (Previous_MA_Indicator=="SELL")) MA_Indicator="SELL";
// ----------------------------
// Stochastic Indicator check
// ----------------------------
if(iStochastic(NULL,0,6,3,3,MODE_SMA,0,MODE_MAIN,0)>Stoch_Upper) Current_Stoch_Indicator="BUY";
if(iStochastic(NULL,0,6,3,3,MODE_SMA,0,MODE_MAIN,0)<Stoch_Lower) Current_Stoch_Indicator="SELL";
if(iStochastic(NULL,0,6,3,3,MODE_SMA,0,MODE_MAIN,1)>Stoch_Upper) Previous_Stoch_Indicator="BUY";
if(iStochastic(NULL,0,6,3,3,MODE_SMA,0,MODE_MAIN,1)<Stoch_Lower) Previous_Stoch_Indicator="SELL";
if ((Current_Stoch_Indicator=="BUY") && (Previous_Stoch_Indicator=="BUY")) Stoch_Indicator="BUY";
if ((Current_Stoch_Indicator=="SELL") && (Previous_Stoch_Indicator=="SELL")) Stoch_Indicator="SELL";
// ----------------------------
// RSI Indicator check
// ----------------------------
if(iRSI(NULL,0,3,PRICE_CLOSE,0)>RSI_Upper) Current_RSI_Indicator="BUY";
if(iRSI(NULL,0,3,PRICE_CLOSE,0)<RSI_Lower) Current_RSI_Indicator="SELL";
if(iRSI(NULL,0,3,PRICE_CLOSE,1)>RSI_Upper) Previous_RSI_Indicator="BUY";
if(iRSI(NULL,0,3,PRICE_CLOSE,1)<RSI_Lower) Previous_RSI_Indicator="SELL";
if ((Current_RSI_Indicator=="BUY") && (Previous_RSI_Indicator=="BUY")) RSI_Indicator="BUY";
if ((Current_RSI_Indicator=="SELL") && (Previous_RSI_Indicator=="SELL")) RSI_Indicator="SELL";
//----------------------------------------
// Figure out if you're in a buy or sell situation
//----------------------------------------
if((MA_Indicator=="BUY") && (Stoch_Indicator=="BUY") && (RSI_Indicator=="BUY") return("BUY");
if((MA_Indicator=="SELL") && (Stoch_Indicator=="SELL") && (RSI_Indicator=="SELL") return("SELL");
}
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
string Current_Trade(string symbol)
{
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
{
return ("NONE");
break;
}
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) return("BUY");
if(OrderType()==OP_SELL) return("SELL");
}
}
}
//----------------------------------------------------------------------
// If the signal has changed direction the first thing to do is Close
// the current open trade before opening another.
//-----------------------------------------------------------------------
void CloseTrade(string symbol)
{
// double ma;
//---- go trading only for first tiks of new bar
// if(Volume[0]>1) return;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; // there are no open trades
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
// leaving both options for the moment in case I want to do it differently
// eg have a different colour, or whatever. Otherwise the two commands are the same
// and you'd only need one. Except the different prices I suppose... Doh!
if(OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
break;
}
}
//----
}
//-----------------------------------------------------------
// Open a position if that's what the tea leaves say
//------------------------------------------------------------
void OpenTrade(string symbol,string Type)
{
int res;
//---- buy conditions
if(Type=="BUY") OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"ROB EA TEST",MAGICMA,0,Blue);
//---- sell conditions
if(Type=="SELL") OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"ROB EA TEST",MAGICMA,0,Red);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
void start()
{
//----
//---- calculate open orders by current symbol
//--- If there are no open trades, then simply open one...
if(Current_Trade(Symbol())=="NONE") OpenTrade(Symbol(),Current_Indication());
// But if there is an open trade we need to close it first before opening the new one.
if ((Current_Trade(Symbol())=="BUY") && (Current_Indication()=="SELL"));
{
CloseTrade(Symbol());
OpenTrade(Symbol(),Current_Indication());
}
if ((Current_Trade(Symbol())=="SELL") && (Current_Indication()=="BUY"));
{
CloseTrade(Symbol());
OpenTrade(Symbol(),Current_Indication());
}
return;
}
there you go.........................................
OK, that was fast! Thanks a lot. What was the problem?
Rob.
Problem with writing file
I'm programming ea witch uses files to keep results of trade (loss, win) with indicators values .So when EA enters trade i write values of indicators and time ,when trade was made, to file "sellOpenInd.tab":
After this operation file includes:
CCISDivPresent 22 69 0.000024 0.000046 0.000045 -0.000015 2002.05.07 13:00
CCISDivPresent 66 85 0.000064 0.000032 0.000037 -0.000033 2002.05.15 07:00
CCISDivPresent 77 90 0.000041 -0.000029 0.000008 -0.000020 2002.06.03 08:00
etc...
In next stage i open this file and look into history for dates of opened orders then i check results of this trades and write into file "sellResults.tab"+indicators values writen in previous stage(above) .And here problem occures, only one same trade is recorded:
Rule7 Rule6 Rule5 Rule4 Rule3 Rule2 Rule1 TradeOutcome
-0.000015 0.000045 0.000046 0.000024 69 22 CCISDivPresent win
-0.000015 0.000045 0.000046 0.000024 69 22 CCISDivPresent win
-0.000015 0.000045 0.000046 0.000024 69 22 CCISDivPresent win
etc..
Here is my code(i know is not looking nice ):
int dates=FileOpen("sellOpenInd.tab", FILE_CSV|FILE_READ,"\t");
if(dates>0){
for(k=0;k<=10;k++){ //i use for loop instead of while(!FileIsEnding(dates) ) because ea enters in infinite loop for unknown reasons
dates=FileOpen("sellOpenInd.tab", FILE_CSV|FILE_READ,"\t");
FileSeek(dates,filepos,SEEK_SET);
while (FileIsLineEnding(dates)==FALSE){filestr=FileReadString(dates)+"\t"+filestr;filepos=filepos+FileTell(dates);}
decodeFile(filestr);//calling function which decodes readed string line, then writing results to global varaiables filter7 ,filter6 etc.
Comment(filterS7);
for (i =OrdersHistoryTotal()-1; i>=0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if (OrderSymbol() == Currencies) {
if((OrderMagicNumber()==16381||OrderMagicNumber()==16383)&&OrderCloseTime()!=0){
historyDateTime=TimeToStr(OrderOpenTime());
OrderP=OrderProfit();
if(OrderP>0)orderresult="win";if(OrderP<=0)orderresult="loss";
if(filterS7==historyDateTime) {
testFline=filterS6+"\t"+filterS5+"\t"+filterS4+"\t"+filterS3+"\t"+filterS2+"\t"+filterS1+"\t"+filterS0+"\t"+orderresult;
results=FileOpen("sellResults.tab", FILE_READ|FILE_WRITE,"\t");
FileSeek(results,0,SEEK_END);
FileWrite(results,testFline);
testFline="";
filestr="";
}
}
}
}
if(!FileIsEnding(dates)){FileClose(dates);FileClose(results);filepos=0;break;
}
}
}
Every step in your cicle you open file "sellOpenInd.tab" again and again.
Try this:
if(dates>0){
for(k=0;k<=10;k++){ //i use for loop instead of while(!FileIsEnding(dates) ) because ea enters in infinite loop for unknown reasons
FileSeek(dates,filepos,SEEK_SET);
while (FileIsLineEnding(dates)==FALSE){filestr=FileReadString(dates)+"\t"+filestr;filepos=filepos+FileTell(dates);}
decodeFile(filestr);//calling function which decodes readed string line, then writing results to global varaiables filter7 ,filter6 etc.
Comment(filterS7);
for (i =OrdersHistoryTotal()-1; i>=0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if (OrderSymbol() == Currencies) {
if((OrderMagicNumber()==16381||OrderMagicNumber()==16383)&&OrderCloseTime()!=0){
historyDateTime=TimeToStr(OrderOpenTime());
OrderP=OrderProfit();
if(OrderP>0)orderresult="win";if(OrderP<=0)orderresult="loss";
if(filterS7==historyDateTime) {
testFline=filterS6+"\t"+filterS5+"\t"+filterS4+"\t"+filterS3+"\t"+filterS2+"\t"+filterS1+"\t"+filterS0+"\t"+orderresult;
results=FileOpen("sellResults.tab", FILE_READ|FILE_WRITE,"\t");
FileSeek(results,0,SEEK_END);
FileWrite(results,testFline);
testFline="";
filestr="";
}
}
}
}
if(!FileIsEnding(dates)){FileClose(dates);FileClose(results);filepos=0;break;
}
}
}Hi Roger09 i tried this before and it dosn't help .It looks as if pointer isn't moving into next line but i don't know why.
Anyway thanks for reply.