An advisor that would follow the rate on a five-minute chart with conditions after launch: - page 6
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
Good day.
Can you advise: There is a script that promptly writes the history in the file, but when the file is open the record does not go.... The script you probably know or have seen is called currency_loader
// loading history data from M1
void LoadingM1(){//1
int MaxBars=MaxBarsInFile;
if(LoadM1 && iBars(Symbol(),PERIOD_M1)>BarsMin){ArrayCopyRates(ArrayM1,Symbol(),PERIOD_M1); ArrSizeM1=ArrayRange(ArrayM1,0);}
if(ArrSizeM1>1){//2
if(MaxBars>ArrSizeM1){MaxBars=ArrSizeM1;}
for(i2=1; i2<=Tryes; i2++){//3
h1 = FileWrite(FileNameM1,FILE_WRITE|FILE_CSV);
if(h1==-1){LastError=GetLastError();Info("1.2",1"," There is an error while opening file: "+FileNameM1+" at "+i2+" Try "+ErrorDescription(LastError));Pause=Pause+Pause; Sleep(Pause); continue; }else{Info("1.2",2", "File "+FileNameM1+" successfully opened ");}
FileWrite(h1,FirstLine);
for (i=MaxBars-1; i>=0; i-- ){//4
if(!USRegionSet){
CString=CString+TimeToStr(ArrayM1[i][0],TIME_DATE)+""; // date of bar
CString=CString+TimeToStr(ArrayM1[i][0],TIME_MINUTES)+","; // time of bar
}
else{
BarTime=ArrayM1[i][0];
CString=CString+GetUSFormatTime(BarTime)+" "; // date of bar
BarTime=0;
}
CString=CString+DoubleToStr(ArrayM1[i][1],iDigits)+","; // open price
CString=CString+DoubleToStr(ArrayM1[i][3],iDigits)+","; // High price
CString=CString+DoubleToStr(ArrayM1[i][2],iDigits)+","; // Low price
CString=CString+DoubleToStr(ArrayM1[i][4],iDigits)+""; // Close price
FileWrite(h1,CString);
CString="";
}//4
FileClose(h1);
LCM1 = iTime(Symbol(),PERIOD_M1,0);
return;
}//3
}//2
}//1
As far as I understood there is a problem in the handles, but where is the question...
Still not working!!!!
Help me to understand what is the reason.
So how did you test it? And how does it show a profit if it doesn't work? And how does it not work? What does the magazine print? Did you test it in the tester? Or online?
Also, look at the OrdersTotal function, what it's for and how it's inserted by....
For example, int total=OrdersTotal(); if(total<1) {
{
//----
if (iOpen(NULL,5,0)-Bid>Delta*Point) //The price has dropped more than Delta points
{
ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point, "Bought",MagicNumber,11111,Green);
}
if (iOpen(NULL,5,0)-Bid<Delta*Point) //The price went up more than Delta points
{
ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point, "Sold",MagicNumber,22222,Green);
}
//----
return(0);
}
//+------------------------------------------------------------------+
And you're a pushy guy, get it. It works, but it's just stupid. Copy it to MetaEditor, or you'll mix up the + with the - again.
As far as I understand, the problem is somewhere in the handles, but where is the question...Here is an example of getting Handle
int hwnd1 = WindowHandle(Symbol(), Period());
I haven't noticed anything similar in your code.
If a "csv" file is opened by Excel, it's locked and the file has no write access, is it a mystery?
So how did you test it? And how does it show a profit if it doesn't work? And how does it not work? What does the magazine print? Did you test it in the tester? Or online?
Also, look at the OrdersTotal function, what it's for and how it's inserted by....
For example, int total=OrdersTotal(); if(total<1) {
Shows profit 504, number of trades 432, drawdown $788, 7.31%. In settings I put m5 on pound, 17/03/08 - 19/03/08.
And when I ran it on the chart, my conditions for trades were met, but the Expert Advisor did nothing.......
int start()
{
//----
if (iOpen(NULL,5,0)-Bid>Delta*Point) //The price has dropped more than Delta points
{
ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point, "Bought",MagicNumber,11111,Green)
}
if (iOpen(NULL,5,0)-Bid<Delta*Point) //The price went up more than Delta points
{
ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point, "Sold",MagicNumber,22222,Green);
}
//----
return(0);
}
//+------------------------------------------------------------------+
And you're a stubborn guy, get it. It works, but it's just stupid. Copy it into MetaEditor, or you'll mix up the + with the - again.
How can I make my Expert Advisor open only one trade and not open others until it finishes?
I'm embarrassed to ask :)))
How can I make my Expert Advisor open only one trade, and until it finishes, not open other ones?
Arrange in a loop a search of all open positions and check them for the current symbol and magic number. If none are found, then we turn on the green light. The kodobase is full of such examples, in almost every EA.