"mohsin360", the compiler is telling you what is wrong. Why do you not read the error report and follow up.
If it says, that you have a variable which has not been defined, then define the variable so that it does not cause the error.
If it says that you have an unbalance parenthesis ")" that means you have to check that you place the correct number of left and right parenthesis and that one or more are probably missing.
These are simple errors for someone who already knows how to code a little.
If you do not know anything about programing, then maybe you should dedicate some time to first learning the basics of programming and using a compiler and correcting the syntax errors in code in general, before trying to write an EA or Indicator.
A good place to start is the "MQL4 Book", right here on this site!
Alternatively maybe a beginners book on "C Programing" or maybe some online tutorials on "C" for beginners. That will start you off so as to understand the basics and then you can proceed with MQL4.
yes i read error report and it contains first and second errors eight in numbers b coz of my trailing start code and i come to know that alpari or mt4 does not allow a minimum trailing of 30 pips so i decided to change code a little bit and using straight order modifying code instead of trailing start code .thanks u all for co operating with me so much . dont be so relax ill ask again if i need help after making and compiling the new changes
my meta editor shows some errors first one is (145,51) when i search in errors list i fine no 145 saying that :[Modification denied because order too close to market.] and thts true b coz at that line i enterd code to modify order in plus of just 5 pips but when i search other errors like (153,62),(158,8),(164,8),(170,55),(180,60)and (185,8).i cant fine any error no listed in the list here is the list where i fine ones meaning and failed to find others .please can any one tell me what is the meaning of the errors and where i can find meanings b coz i searched "unexpected token" and find that i only comes when there is some problem with the code syntax but as u can see i have two errors at top say wrong parameters count @(145,51) and (153,62) and only 145 listed in the index but 153,62 is not Y
//+------------------------------------------------------------------+//| every tick20.mq4 |//| mohsin mewati |//| |//+------------------------------------------------------------------+#property copyright"mohsin mewati"#property link""//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init()
{
//----int order_open_time_buy =0;//intiger to save buy open Timeint order_open_time_sell =0;//intiger to save sell open Timebool err_close_all_orders =0;//bolean to save get last error for close all opened orders codebool err_sell=0;
bool err_buy=0;
bool err_selection_buy=0;
bool err_selection_sell=0;
bool buy_modified=0;
bool sell_modified=0;
double mf_buy=0;
double mf_sell=0;
int buy_trail=0;
int err_trail_buy=0;
int err_modify_sell=0;
int buy_selection=0;
bool buy_open_price=0;
int sell_selection=0;
//----return(0);
}
//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+//----int start()
{
bool err_buy;
int buy_ticket;
bool err_sell;
int sell_ticket;
bool err_selection_buy;
int buy_selection;
double buy_open_price;
bool err_selection_sell;
int sell_selection;
bool err_mf_buy;
bool srr_mf_sell;
bool err_mf_sell;
bool err_trail_buy;
bool err_modify_sell;
bool buy_modified;
bool err_trail_sell;
bool err_modify_buy;
int buy_trail=0;
int sell_trail=0;
string buy="open";
string sell="open";
int bp=20;
int sp=20;
double buy_ans;
double sell_ans;
double slbuy;
double slsell;
double tp_sell;
double tp_buy;
//coding startswhile(err_buy==0){//for loop started to execute a buy Order
buy_ticket=OrderSend("GBPUSD",OP_BUY,1,Ask,3,Ask+20*Point,0,Green); //code to execute a buy (buy order placed without SL but with a TP of 20 pips
err_buy=GetLastError();//code to check either buy is executed or not?
}//for loop endwhile(err_sell==0){//for loop to place a sell order
sell_ticket = OrderSend("GBPUSD",OP_SELL,1,Ask,3,Ask-20*Point,0,Red);//code to place a sell ,order placed without SL but with a TP of 20 pips
err_sell=GetLastError();//code to check either sell is placed or not?
}//for loop endsAlert("buy/sell executed");
//__________________________________________________________________________________________________________________________________while(err_selection_buy==0){// for loop start to selection of first executed order for further procedure
buy_selection=OrderSelect("Buy_ticket",SELECT_BY_TICKET);//order select and stored in intiger
err_selection_buy=GetLastError();//code to check eithet order is selected or not
}//for loop ends
buy_open_price=OrderOpenPrice();//taking open price for the first selected order
buy_ans=buy_open_price;
while(err_selection_sell==0){// for loop start to selection of second executed order for further procedure
sell_selection=OrderSelect("Sell_ticket",SELECT_BY_TICKET);//order select and stored in intiger
err_selection_sell=GetLastError();//code to check eithet order is selected or not
}//for loop endsdouble sell_open_price=OrderOpenPrice();//taking open price for the second selected order
sell_ans=sell_open_price;
while("buy_trail==0" && "Sell_trail==0"){// while loop started to check if thow of them or one is truewhile ("err_mf_buy==0" && "err_mf_sell==0"){//while loop start to take price quote every time for buy and selldouble mf_buy=MarketInfo("GBPUSD",MODE_POINT);//code to store markeet info in integer mf_buy
err_mf_buy=GetLastError();//code to confirm the previous line of code executed? double mf_sell=MarketInfo("GBPUSD",MODE_POINT);//code to store markeet info in integer mf_sell
err_mf_sell=GetLastError();//code to confirm the previous line of code executed?
}
if (mf_buy==slbuy){
buy="closed";}
else{
if( mf_sell==slsell){
sell="closed";}
else{}
}
if("mf_buy-bp == buy_ans" && "Buy==open"){//if condition to compare if current markeet quote which stored in mf_buy is 20 times greater than the open price of buy Order?while(err_trail_buy==0){//if above condition true for loop started to start trailing on buy order.OrderModify(buy_ticket,buy_open_price,slbuy);
bp="(bp+5)";
err_trail_buy=GetLastError();//code to confirm the previous line of code executed?
}
if(bp>=30){
tp_sell=0.00005;
while(err_modify_sell==0){//if buy is in profit for 20 pips and trailing stop started on it i want my sell to modify for take profit for just 5 pips.OrderModify(sell_ticket,sell_open_price,slsell,tp_sell);
err_modify_sell=GetLastError();//code to confirm the previous line of code executed?
buy_trail=1;//intiger use to remember that the buy was in profit and all the cooding associated with it was executed there is no need to check .
}
}
else{
}
elseif ("mf_sell+sp"<="Sell_ans" && "Sell"=="open"){//another logical test to check if buy was not in 20 pips if our sell is in 20 pips profit if so then in the next for loop statrtedwhile(err_trail_sell==0){//for loop start to modify sell for trailOrderModify(sell_ticket,sell_open_price,slsell);
sp="(sp+5)";
err_trail_sell=GetLastError();//code to confirm the previous line of code executed?
}
if(sp>=30){
tp_buy=0.00005;
while(err_modify_buy==0){//if our sell is in 20 pips profit and trailing executed on it while loop start to modify buy for tp for just 5 pips OrderModify(buy_ticket,buy_open_price,slbuy,tp_buy);
err_modify_buy=GetLastError();//code to confirm the previous line of code executed?
sell_trail=1;//intiger use to remember that the sell was in profit and all the cooding associated with it was executed there is no need to check .
}
}
else{
}
}
}
}
double ab=AccountBalance();
//----return(0);
}
//+------------------------------------------------------------------+//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----//----return(0);
}
my meta editor shows some errors first one is (145,51) when i search in errors list i fine no 145 saying that :[Modification denied because order too close to market.] and thts true b coz at that line i enterd code to modify order in plus of just 5 pips but when i search other errors like (153,62),(158,8),(164,8),(170,55),(180,60)and (185,8).i cant fine any error no listed in the list here is the list where i fine ones meaning and failed to find others .please can any one tell me what is the meaning of the errors and where i can find meanings b coz i searched "unexpected token" and find that i only comes when there is some problem with the code syntax but as u can see i have two errors at top say wrong parameters count @(145,51) and (153,62) and only 145 listed in the index but 153,62 is not Y
145 is the line number not the error number . . . 51 is the character column number. These are coding errors not execution errors . . . fix your braces.
i already declared Buy_ticket as intiger containing value of ticket recieved from the server @ ordersend Buy and same for sell.
if u say that the first parameter of orderselect must be in numbers then how i got the no obviously i first stored it in an intiger and then call that intiger and thts what im doing.
i already declared Buy_ticket as intiger containing value of ticket recieved from the server @ ordersend Buy and same for sell.
if u say that the first parameter of orderselect must be in numbers then how i got the no obviously i first stored it in an intiger and then call that intiger and thts what im doing.
i removed these and the metaeditor ask abt predefined variables showing error variable not defined
buy_ticket
sell_ticket
now i fix these double commas and having only two errors
here is the code
//+------------------------------------------------------------------+//| every tick20.mq4 |//| mohsin mewati |//| |//+------------------------------------------------------------------+#property copyright"mohsin mewati"#property link""//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init()
{
//----int order_open_time_buy =0;//intiger to save buy open Timeint order_open_time_sell =0;//intiger to save sell open Timebool err_close_all_orders =0;//bolean to save get last error for close all opened orders codebool err_sell=0;
bool err_buy=0;
bool err_selection_buy=0;
bool err_selection_sell=0;
bool buy_modified=0;
bool sell_modified=0;
double mf_buy=0;
double mf_sell=0;
int buy_trail=0;
int err_trail_buy=0;
int err_modify_sell=0;
int buy_selection=0;
bool buy_open_price=0;
int sell_selection=0;
//----return(0);
}
//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+//----int start()
{
bool err_buy;
int buy_ticket;
bool err_sell;
int sell_ticket;
bool err_selection_buy;
int buy_selection;
double buy_open_price;
bool err_selection_sell;
int sell_selection;
bool err_mf_buy;
bool srr_mf_sell;
bool err_mf_sell;
bool err_trail_buy;
bool err_modify_sell;
bool buy_modified;
bool err_trail_sell;
bool err_modify_buy;
int buy_trail=0;
int sell_trail=0;
string buy;
string sell;
int bp=20;
int sp=20;
double buy_ans;
double sell_ans;
double slbuy;
double slsell;
double tp_sell;
double tp_buy;
//coding startswhile(err_buy==0){//for loop started to execute a buy Order
buy_ticket=OrderSend("GBPUSD",OP_BUY,1,Ask,3,Ask+20*Point,0,Green); //code to execute a buy (buy order placed without SL but with a TP of 20 pips
err_buy=GetLastError();//code to check either buy is executed or not?
}//for loop endwhile(err_sell==0){//for loop to place a sell order
sell_ticket = OrderSend("GBPUSD",OP_SELL,1,Ask,3,Ask-20*Point,0,Red);//code to place a sell ,order placed without SL but with a TP of 20 pips
err_sell=GetLastError();//code to check either sell is placed or not?
}//for loop endsAlert("buy/sell executed");
//__________________________________________________________________________________________________________________________________while(err_selection_buy==0){// for loop start to selection of first executed order for further procedure
buy_selection=OrderSelect(Buy_ticket,SELECT_BY_TICKET);//order select and stored in intiger
err_selection_buy=GetLastError();//code to check eithet order is selected or not
}//for loop ends
buy_open_price=OrderOpenPrice();//taking open price for the first selected order
buy_ans=buy_open_price;
while(err_selection_sell==0){// for loop start to selection of second executed order for further procedure
sell_selection=OrderSelect(Sell_ticket,SELECT_BY_TICKET);//order select and stored in intiger
err_selection_sell=GetLastError();//code to check eithet order is selected or not
}//for loop endsdouble sell_open_price=OrderOpenPrice();//taking open price for the second selected order
sell_ans=sell_open_price;
while("buy_trail"==0 && "Sell_trail"==0){// while loop started to check if thow of them or one is truewhile (err_mf_buy==0 && err_mf_sell==0){//while loop start to take price quote every time for buy and selldouble mf_buy=MarketInfo("GBPUSD",MODE_POINT);//code to store markeet info in integer mf_buy
err_mf_buy=GetLastError();//code to confirm the previous line of code executed? double mf_sell=MarketInfo("GBPUSD",MODE_POINT);//code to store markeet info in integer mf_sell
err_mf_sell=GetLastError();//code to confirm the previous line of code executed?
}
if (mf_buy==slbuy){
buy="closed";}
else{
if( mf_sell==slsell){
sell="closed";}
else{}
}
if(mf_buy-bp == buy_ans && "Buy"=="open"){//if condition to compare if current markeet quote which stored in mf_buy is 20 times greater than the open price of buy Order?while(err_trail_buy==0){//if above condition true for loop started to start trailing on buy order.OrderModify(buy_ticket,buy_open_price,slbuy);
bp="(bp+5)";
err_trail_buy=GetLastError();//code to confirm the previous line of code executed?
}
if(bp>=30){
tp_sell=0.00005;
while(err_modify_sell==0){//if buy is in profit for 20 pips and trailing stop started on it i want my sell to modify for take profit for just 5 pips.OrderModify(sell_ticket,sell_open_price,slsell,tp_sell);
err_modify_sell=GetLastError();//code to confirm the previous line of code executed?
buy_trail=1;//intiger use to remember that the buy was in profit and all the cooding associated with it was executed there is no need to check .
}
}
else{
}
elseif ("mf_sell"+"sp"<="Sell_ans" && "Sell"=="open"){//another logical test to check if buy was not in 20 pips if our sell is in 20 pips profit if so then in the next for loop statrtedwhile(err_trail_sell==0){//for loop start to modify sell for trailOrderModify(sell_ticket,sell_open_price,slsell);
sp="(sp+5)";
err_trail_sell=GetLastError();//code to confirm the previous line of code executed?
}
if(sp>=30){
tp_buy=0.00005;
while(err_modify_buy==0){//if our sell is in 20 pips profit and trailing executed on it while loop start to modify buy for tp for just 5 pips OrderModify(buy_ticket,buy_open_price,slbuy,tp_buy);
err_modify_buy=GetLastError();//code to confirm the previous line of code executed?
sell_trail=1;//intiger use to remember that the sell was in profit and all the cooding associated with it was executed there is no need to check .
}
}
else{
}
}
}
}
double ab=AccountBalance();
//----return(0);
}
//+------------------------------------------------------------------+//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----//----return(0);
}
and please fix its errors or give me some hints
"mohsin360", the compiler is telling you what is wrong. Why do you not read the error report and follow up.
If it says, that you have a variable which has not been defined, then define the variable so that it does not cause the error.
If it says that you have an unbalance parenthesis ")" that means you have to check that you place the correct number of left and right parenthesis and that one or more are probably missing.
These are simple errors for someone who already knows how to code a little.
If you do not know anything about programing, then maybe you should dedicate some time to first learning the basics of programming and using a compiler and correcting the syntax errors in code in general, before trying to write an EA or Indicator.
A good place to start is the "MQL4 Book", right here on this site!
Alternatively maybe a beginners book on "C Programing" or maybe some online tutorials on "C" for beginners. That will start you off so as to understand the basics and then you can proceed with MQL4.
yes i read error report and it contains first and second errors eight in numbers b coz of my trailing start code and i come to know that alpari or mt4 does not allow a minimum trailing of 30 pips so i decided to change code a little bit and using straight order modifying code instead of trailing start code .thanks u all for co operating with me so much . dont be so relax ill ask again if i need help after making and compiling the new changes
Regards
Mohsin.meo
my meta editor shows some errors first one is (145,51) when i search in errors list i fine no 145 saying that :[Modification denied because order too close to market.] and thts true b coz at that line i enterd code to modify order in plus of just 5 pips but when i search other errors like (153,62),(158,8),(164,8),(170,55),(180,60)and (185,8).i cant fine any error no listed in the list here is the list where i fine ones meaning and failed to find others .please can any one tell me what is the meaning of the errors and where i can find meanings b coz i searched "unexpected token" and find that i only comes when there is some problem with the code syntax but as u can see i have two errors at top say wrong parameters count @(145,51) and (153,62) and only 145 listed in the index but 153,62 is not Y
my meta editor shows some errors first one is (145,51) when i search in errors list i fine no 145 saying that :[Modification denied because order too close to market.] and thts true b coz at that line i enterd code to modify order in plus of just 5 pips but when i search other errors like (153,62),(158,8),(164,8),(170,55),(180,60)and (185,8).i cant fine any error no listed in the list here is the list where i fine ones meaning and failed to find others .please can any one tell me what is the meaning of the errors and where i can find meanings b coz i searched "unexpected token" and find that i only comes when there is some problem with the code syntax but as u can see i have two errors at top say wrong parameters count @(145,51) and (153,62) and only 145 listed in the index but 153,62 is not Y
145 is the line number not the error number . . . 51 is the character column number. These are coding errors not execution errors . . . fix your braces.
This is wrong . . .
OrderSelect() the first parameter must be an int not a string, read the documentation.
Same here . . .
These are string and will not work . . .
same here . . .
i already declared Buy_ticket as intiger containing value of ticket recieved from the server @ ordersend Buy and same for sell.
if u say that the first parameter of orderselect must be in numbers then how i got the no obviously i first stored it in an intiger and then call that intiger and thts what im doing.
?
i already declared Buy_ticket as intiger containing value of ticket recieved from the server @ ordersend Buy and same for sell.
if u say that the first parameter of orderselect must be in numbers then how i got the no obviously i first stored it in an intiger and then call that intiger and thts what im doing.
?
This is an integer . . .
this is a string
"Buy_ticket"if ur telling abt "" ?
i removed these and the metaeditor ask abt predefined variables showing error variable not defined
buy_ticket
sell_ticket
now i fix these double commas and having only two errors
here is the code
if ur telling abt "" ?
i removed these and the metaeditor ask abt predefined variables showing error variable not defined
buy_ticket
sell_ticket
now i fix these double commas and having only two errors
here is the code
buy_ticket is not the same as Buy_ticket
You still have many other errors . . .
OrderModify() (please read the documentation) takes at least 5 parameters . . .
OrderModify(buy_ticket, buy_open_price, slbuy);. . . not three. colour is optional . . .
else what ?
else{ }