help with ibands

 

hey

please guys any one can help me with my expert ..

 

i wanna make a buystop in the upper line of the ibands and a sellstop in the lower line of the ibands ..of the candle of 00:00  every day

so i write it like that ..but it wouldnt work.. can u guys pliizz help me

 double BuyLevel1=iBands(NULL,0,15,2,0,PRICE_MEDIAN,MODE_UPPER,1);
int B1=OrderSend(Symbol() , OP_BUYSTOP , lot , BuyLevel1 , Slippage , BuyLevel1-SL*pte , BuyLevel1+TP*pte, "" ,MagicNumber , TimeCurrent()+expiration , Green); 
       
 
What doesn't work?
 
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. Check your return codes and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
 

hahahahhaha sorry i didn't explain ..

doesn't work that men it doesn't put  the orders the Buy Stop and the Sell Stop  as shown in the pic

 

my question is ..is there something to know when i affect a value from ibands to a  variable ? 

because the rest of the code work fin when i change it to this for exmpl

double BuyLevel1=Close[1]+10*pte;
int B1=OrderSend(Symbol() , OP_BUYSTOP , lot , BuyLevel1 , Slippage , BuyLevel1-SL*pte , BuyLevel1+TP*pte, "" ,MagicNumber , TimeCurrent()+expiration , Green); 

 

thank you in advance :)

https://charts.mql5.com/10/344/usdjpy-h1-fxpro-financial-services-2.png

 

Your image shows the USDJPY chart. The trade log shows the EA running on GBPUSD opened an order.

  1. Post the rest of the code.
  2. How do you stop opening infinite number of trades?
 
extern int TP=40;
extern int SL=30;
extern double lot=0.01;
extern int ExpirationTime = 22;
//////////////////////////
int MagicNumber=26091;
int Slippage=10;
int mypoint;
double pte;
int BarsCount = 0;
int  expiration=60*60*ExpirationTime;
//////////////////////////

int init() {

////////////////////////////////////////////////////////////////////////////
if(MarketInfo(Symbol(), MODE_DIGITS)==3||MarketInfo(Symbol(), MODE_DIGITS)==5)
mypoint=10;
else mypoint=1; 
pte=Point*mypoint;
///////////////////////////////////////////////////////////////////////////
   return (0);
}
int start()
  {
  
  if( Hour()==1 && Minute()==59)
 {
  ////////////////////////////////////// this is how i stop opening infinite number of trades
  int Orders= OrdersTotal();           // Number of orders
   if (Orders==0)                      // If numb. of ord. = 0
      Comment("No orders");            // Comment to the window corner
   else                                // If there are orders
      Comment("Available ",Orders," orders." );// Comment
     {
int orders=0; 
for (int i=0; i<OrdersTotal(); i++){ 
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
if(OrderSymbol()==Symbol()) 
orders++; 
      }
  if(orders==0)
////////////////////////////////////////////////////////////////////////// 
  {
           
 double BuyLevel=iBands(NULL,0,15,2,0,PRICE_MEDIAN,MODE_UPPER,1);
 int B=OrderSend(Symbol() , OP_BUYSTOP , lot , BuyLevel , Slippage , BuyLevel-SL*pte , BuyLevel+TP*pte, "" ,MagicNumber , TimeCurrent()+expiration , Green);
              
 double SellLevel=iBands(NULL,0,15,2,0,PRICE_MEDIAN,MODE_LOWER,1);
 int S=OrderSend(Symbol() , OP_SELLSTOP , lot , SellLevel , Slippage ,SellLevel+SL*pte , SellLevel-TP*pte, "" ,MagicNumber , TimeCurrent()+expiration , Blue);

  }
   
}

   BarsCount = Bars; 
   
  }
  return (0);
    }

the pic was just  an exempel..to show u ..wher it most normaly open the orders ... 

sooryy for the disturbance :( 

 

You need to Normalize the entry levels

            
 double BuyLevel=NormalizeDouble(iBands(NULL,0,15,2,0,PRICE_MEDIAN,MODE_UPPER,1),Digits);
              
 double SellLevel=NormalizeDouble(iBands(NULL,0,15,2,0,PRICE_MEDIAN,MODE_LOWER,1),Digits);


You use int A and int B in your code. Print an error report if these==-1

 
GumRai: You need to Normalize the entry levels
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
 
oh thanks guys its working ... thanks aloot ;)
Reason: