Re: Coding Help

512
Thank you so much mladen this is what I needed.
I have looked at your posts in many places here and others, and I can't tell you how much I admire you for your wisdom in coding, not only in MT4, 5 but other platforms as well, this is just one big WOW from me!!!
good for you and thank you for helping all of us here

though if you don't mind, could you please put arrows in the dss bressert I have posted?
I wanted it in that version and not others, I have found others with arrows but this version is a bit different as I have compared them

I thank you for that

Re: Coding Help

515
Hello mladen , i want to build a simple close ea follow by Bbandsstop .
I wish you can give advise for me and point me out where i have wrong in this code .

Thank you.

Code: Select all

 //----- close order By Bbandsstop signal-----
int Bbandsstopclose() {

      double trendCurr = iCustom(Symbol(),0,"@BBands stop v3",0,UpBandPrice, LoBandPrice, MA_Length, MA_Mode,Deviation,DeviationLength,MoneyRisk,SignalMode,LineMode,6,shift);
          
      for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) {
      if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && (OrderMagicNumber() == MagicNumberBuy || OrderMagicNumber() == MagicNumberSell))      
      if (trendCurr ==-1 && OrderType() == OP_BUY)  closeAll(OP_BUY); 
      if (trendCurr ==1 && OrderType() == OP_SELL) closeAll(OP_SELL);
      }
   }
   return(0);      
} 

void closeAll(int OrdrType) {
   double closePrice = 0;
   for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) {
      if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() != MagicNumberBuy && OrderMagicNumber() != MagicNumberSell && OrderSymbol() == Symbol() && OrderType() == OrdrType) {
         for (int retries =0; retries<3; retries++) {
            RefreshRates();
           { 
            if((OrderType()==OP_BUY)&&(( OrdrType==0)||( OrdrType==1))) 
            if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),MarketInfo(OrderSymbol(),MODE_DIGITS)),5*Spread,Blue))
            if((OrderType()==OP_SELL)&&(( OrdrType==0)||( OrdrType==-1))) 
            if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),MarketInfo(OrderSymbol(),MODE_DIGITS)),5*Spread,Red))break;
        }
      }
    }
  }
}  


Re: Coding Help

516
Steven wrote: Sat Sep 09, 2017 1:10 pm Hello mladen , i want to build a simple close ea follow by Bbandsstop .
I wish you can give advise for me and point me out where i have wrong in this code .

Thank you.

Code: Select all

 //----- close order By Bbandsstop signal-----
int Bbandsstopclose() {

      double trendCurr = iCustom(Symbol(),0,"@BBands stop v3",0,UpBandPrice, LoBandPrice, MA_Length, MA_Mode,Deviation,DeviationLength,MoneyRisk,SignalMode,LineMode,6,shift);
          
      for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) {
      if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && (OrderMagicNumber() == MagicNumberBuy || OrderMagicNumber() == MagicNumberSell))      
      if (trendCurr ==-1 && OrderType() == OP_BUY)  closeAll(OP_BUY); 
      if (trendCurr ==1 && OrderType() == OP_SELL) closeAll(OP_SELL);
      }
   }
   return(0);      
} 

void closeAll(int OrdrType) {
   double closePrice = 0;
   for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) {
      if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() != MagicNumberBuy && OrderMagicNumber() != MagicNumberSell && OrderSymbol() == Symbol() && OrderType() == OrdrType) {
         for (int retries =0; retries<3; retries++) {
            RefreshRates();
           { 
            if((OrderType()==OP_BUY)&&(( OrdrType==0)||( OrdrType==1))) 
            if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),MarketInfo(OrderSymbol(),MODE_DIGITS)),5*Spread,Blue))
            if((OrderType()==OP_SELL)&&(( OrdrType==0)||( OrdrType==-1))) 
            if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),MarketInfo(OrderSymbol(),MODE_DIGITS)),5*Spread,Red))break;
        }
      }
    }
  }
}  
Guys, please : to be able to answer questions like that I need to know what exactly do you expect from some code to do.
So : what exactly it does not do the way you expect it to do?

Re: Coding Help

517
mladen wrote: Sat Sep 09, 2017 5:33 pm Guys, please : to be able to answer questions like that I need to know what exactly do you expect from some code to do.
So : what exactly it does not do the way you expect it to do?
Hi , sorry about not explain clearly .
I have use bbandsstop indicator for my trading signal .
So i want to make a ea to close my position went the signal is reverse , so i no need to sit in front the monitor for few hour.
Example : The signal is up i have buy position , when the signal is reverse to sell and the ea will close all my buy position on chart .

My problem is now the ea does not close any position , so i need help to check is that my code have any problem ?
I not good in mql , but i want to learn somethings new .
Thanks .

Re: Coding Help

518
Hi All
How can i protect my indicator with password or Time expiry or User account?, the methods that are on MQL4 site give errors like "'start' - function already defined and has different type" or "function defination unexpected"

this is the code i inserted in the indicator:

int start()
{
string expire_date = "2017.09.12"; //<-- hard coded datetime
datetime e_d = StrToTime(expire_date);
if (CurTime() >= e_d)
{
Alert ("The trial version has been expired!");
return(0);
}
// your normal code!
return(0);
}


your help will be appreciated

Re: Coding Help

519
Sanele wrote: Tue Sep 12, 2017 3:09 am Hi All
How can i protect my indicator with password or Time expiry or User account?, the methods that are on MQL4 site give errors like "'start' - function already defined and has different type" or "function defination unexpected"


your help will be appreciated
That means you already have two " int start() " in your indicator , you only need place the code without the " int start() " in your indicator .
Try it .

Re: Coding Help

520
Steven wrote: Sat Sep 09, 2017 7:06 pm

Hi , sorry about not explain clearly .
I have use bbandsstop indicator for my trading signal .
So i want to make a ea to close my position went the signal is reverse , so i no need to sit in front the monitor for few hour.
Example : The signal is up i have buy position , when the signal is reverse to sell and the ea will close all my buy position on chart .

My problem is now the ea does not close any position , so i need help to check is that my code have any problem ?
I not good in mql , but i want to learn somethings new .
Thanks .
Problem solve .


Who is online

Users browsing this forum: No registered users and 15 guests