bands

To add comments, please log in or register
boopa26
92
boopa26  

hello im trying to code an expert advisor that does trade after moving average is higher than bands main (after bar closes. shift 1)

if(iBands(NULL,0,20,2,1,PRICE_CLOSE,MODE_MAIN,1)<iMA(NULL,0,PERIOD_CURRENT,1,MODE_SMA,PRICE_CLOSE,1)&&
   OrdersTotal()==0)

   OrderSend(Symbol(),OP_BUY,lots,Ask,3,Ask-stoploss*Point,0,"",magic_number,0,Blue);

‌the code does not do what i want it to do. i read documentation but it does not give detailed information

https://docs.mql4.com/indicators/ibands

‌‌

iBands - Technical Indicators - MQL4 Reference
iBands - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iBands - Technical Indicators - MQL4 Reference
Carl Schreiber
Moderator
7070
Carl Schreiber  

Do you know what MODE_MAIN means in iBands()?

For you code you don't need iBands() an iMA(..) would be enough - guess why!

boopa26
92
boopa26  
bands exampleCarl Schreiber:

Do you know what MODE_MAIN means in iBands()?

For you code you don't need iBands() an iMA(..) would be enough - guess why!

i think mode_main means middle line inside two lines above below

i‌ want to place trade after ma period 1 shift 1 is above bands middle line. can you show me some code please

whroeder1
17944
whroeder1  
  1. Your code
    Documentation
    iMA(
       NULL,
       0,
       PERIOD_CURRENT,
       1,
       MODE_SMA,
       PRICE_CLOSE,
       1
    )
    double  iMA(
       string       symbol,           // symbol
       int          timeframe,        // timeframe
       int          ma_period,        // MA averaging period
       int          ma_shift,         // MA shift
       int          ma_method,        // averaging method
       int          applied_price,    // applied price
       int          shift             // shift
       );
    What is the length of your moving average?
  2. Why did you post in the Root / MT5 General section instead of the MQL4 section (bottom of the Root page?)
boopa26
92
boopa26  
whroeder1:
  1. Your code
    Documentation
    What is the length of your moving average?
  2. Why did you post in the Root / MT5 General section instead of the MQL4 section (bottom of the Root page?)

the moving average has a period of 1. the moving average is same as price. i posted in the root just because it was at the top of the page

iMA(Symbol(),PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1);
iBands(Symbol(),PERIOD_CURRENT,20,2,1,PRICE_CLOSE,MODE_MAIN,1);
whroeder1
17944
whroeder1  
boopa26: the moving average has a period of 1.
No, it does not! That is you problem.
boopa26
92
boopa26  
whroeder1:
No, it does not! That is you problem.

maybe you can show me some code please

if(iBands(Symbol(),PERIOD_CURRENT,20,2,1,PRICE_CLOSE,MODE_MAIN,1)<iMA(Symbol(),PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1)&&
   OrdersTotal()==0)

   OrderSend(Symbol(),OP_BUY,lots,Ask,3,Ask-stoploss*Point,0,"",magic_number,0,Blue);

bands2

i think its fixed now. thanks all
To add comments, please log in or register