Open Position (X)

 

Dear Coder, i need for help to fix my e.a which can't op_position base on indicator.

thks.

//+------------------------------------------------------------------+
//|                                                     RSIARROW.mq4 |
//|          Copyright 2012, Multitrade-International Software Corp. |
//|                                            febrianto21@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, Multitrade-International Software Corp."
#property link      "febrianto21@yahoo.com"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green

int RSI_Period = 9; 

double dUpRSIBuffer[];
double dDownRSIBuffer[];

int init() {    
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,233);
    SetIndexBuffer(0,dUpRSIBuffer);  
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,234); 
    SetIndexBuffer(1,dDownRSIBuffer);    
   return(0);
  }
int start() {
   for (int i=Bars; i>0; i--){
      double iRsi0 = iRSI(NULL,0,RSI_Period,PRICE_WEIGHTED,i);
      double iRsi1 = iRSI(NULL,0,RSI_Period,PRICE_WEIGHTED,i+1);  
      if (iRsi0>=50) {
         if(iRsi0>50 && iRsi1<50) {  
            dUpRSIBuffer[i] = Low[i] - 2 * MarketInfo(Symbol(),MODE_POINT);
         }
      }    
      if(iRsi0<=50)  {
         if(iRsi0<50 && iRsi1>50) {      
            dDownRSIBuffer[i] = High[i] + 2 * MarketInfo(Symbol(),MODE_POINT);

         }            
      } 
   Comment(dUpRSIBuffer[i], "\n",
           dDownRSIBuffer[i]);
   }
   return(0);
}
//+------------------------------------------------------------------+
//|                                            RSI ARROW ADVISOR.mq4 |
//|          Copyright 2012, Multitrade-International Software Corp. |
//|                                            febrianto21@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, Multitrade-International Software Corp."
#property link      "febrianto21@yahoo.com"
 

int start() {
   //-------------------SIGNAL PROVIDER------------------------------
   string n;
   double irsi0 = iCustom(NULL,PERIOD_M1,"RSI ARROW",0,0);
   double irsi1 = iCustom(NULL,PERIOD_M1,"RSI ARROW",1,0);  
   //------------------FIRS TRADE CONDITION--------------------------
   if (OrdersTotal() < 0) {
      if (irsi0 != 2147483647 && irsi1 == 2147483647) OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,"",777,Lime);
      else
         if (irsi0 == 2147483647 && irsi1 != 2147483647) OrderSend(Symbol(),OP_SELL,0.01,Bid,3,0,0,"",777,Red);
   }
   Comment(irsi0, "\n",
           irsi1);
   return(0); 
}
 
Febrianto: Dear Coder, i need for help to fix my e.a which can't op_position base on indicator.
Detailed explanation of iCustom - MQL4 forum
 

that's not what i meant my friend, actually i can't access the buffer from the indicator by using iCustom,

i've tried to insert GlobalVariableSet() to the indicator and access the value from e.a by using GlobalVariableGet(), it work now.
 
Febrianto:

that's not what i meant my friend, actually i can't access the buffer from the indicator by using iCustom,

i've tried to insert GlobalVariableSet() to the indicator and access the value from e.a by using GlobalVariableGet(), it work now.

You are using a standard MT4 Technical Indicator, iRSI, so you don't even need you r indicator, just use the iRSI function call in your EA.


Also, you do realise that by using bar 0 your iRSI value will very likely change from tick to tick ?

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

The close price for bar 0 is the current Bid price.

Reason: