lowest or highest of an indicator

 

i am trying to program finding the highest high or lowest low of the rsi indicator in X number of bars but i keep getting error codes/messages and just cant seem to get it right.

Any suggestions would really be helpful, below are a few examples of what i have tried with no success.

i have tried double val=RSI[iLowest(NULL,0,MODE_LOW,10,10)]; (UNEXPECTED TOKEN)
VAL=RSI(iLowest(NULL,0,MODE_LOW,10,10)); RSI FUNCTION NOT DEFINED EVEN THOUGH I HAVE IT defined IN THE double,
VAL=iRSI(NULL,0,(iLowest(NULL,0,PRICE_CLOSE,10,0),0,0)); wrong parameters count;
VAL=iRSI(NULL,0,(iLowest(NULL,0,MODE_LOW,10,0),PRICE_CLOSE,0));
is it even possible to to do the lowest low or highest high of a function?
Thaanks for any help in advance.
Bruce

 

"i am trying to program finding the highest high or lowest low of the rsi indicator"

... where is your code? Inside the RSI indicator or someplace else? Show all of your code please.

 
phy wrote >>

"i am trying to program finding the highest high or lowest low of the rsi indicator"

... where is your code? Inside the RSI indicator or someplace else? Show all of your code please.

phy
wrote
>>

"i am trying to program finding the highest high or lowest low of the rsi indicator"

... where is your code? Inside the RSI indicator or someplace else? Show all of your code please.

phy thanks for your help in advance, this is inside an ea that i have built. i have lots of stuff in it and i kknow it works but i have separated a lot of stuff out and looking at getting this parameter to be added and works based on divergence of the rsi

HERE IS COMPLET CODE SO FAR

extern string EAName = "2689AG"; //Name to put in the Orders Comment
extern double Lots = 1; //Lots Value

extern int StopLoss = 50; //Number of Pips above/below High/Low Last bar
extern int Slippage = 3;

int TakeProfit = 0;


extern int RSI_Value = 6; //
extern int RSI_Value2 = 10;

extern double PercentRisk = 0 ; //If "0" The lots value will be the same of (Lots=0.10;) variable, else,
//will use MoneyManagment to calculate lots value

extern string StartHour = "00:01"; //
extern string StopHour = "23:59"; //

extern int MAGIC_Number = 111;
int MAGIC_Number2 = 1; //serve pra nada
extern bool IsIBFXMiniAccount = true; // True if you use InterbankFX Mini-Account


//--------- //--------- //--------- //--------- //--------- //--------- //--------- //---------
//--------- //---------
//---------
//--------- //--------- //--------- //--------- //--------- //--------- //--------- //---------
int DayTrend=3;
int metodo,dia2,ContarNumeroOrdensDia,DeterminarTrend,dia,myBars,OrdemBS,Ponto,FFractalB,FFractalS,pontoS,pontoB,FSell,direc,Barra,Control,i,erro,Ticket,Total,Tipo;
double RSI,RSI_LOWP,RSI_LOW,RSIP,tpExitRule1,L,H,BU,BD;
string TodosPares[20]={"GBPUSD","EURUSD","USDJPY","USDCHF","EURCHF","AUDUSD","USDCAD","NZDUSD","EURCAD","EURJPY","GBPJPY","CHFJPY","GBPCHF","AUDNZD","EURGBP","AUDCAD","AUDJPY","NZDJPY","EURAUD"};
string TodosParesm[20]={"GBPUSDm","EURUSDm","USDJPYm","USDCHFm","EURCHFm","AUDUSDm","USDCADm","NZDUSDm","EURCADm","EURJPYm","GBPJPYm","CHFJPYm","GBPCHFm","AUDNZDm","EURGBPm","AUDCADm","AUDJPYm","NZDJPYm","EURAUDm"};
string HorarioAgora;
bool debug = false;
bool SendEmail = false;
datetime Hoje,Expira;
int Ftime=1;
int Direc=3;

double DgGMTTime;
double Max = -999999; // maximo do periodo
double Min = 999999; // Minimo do periodo
int GMT = 0; // Horario normal de brasilia
color color1=Blue;
color color2=Red;
color color3=Yellow;
int Digito;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
if (Symbol()=="USDJPY" ||Symbol()=="EURJPY" ||Symbol()=="GBPJPY" ||Symbol()=="CHFJPY" ||Symbol()=="AUDJPY" ||Symbol()=="NZDJPY" )Ponto=100; else Ponto=10000;
if (IsIBFXMiniAccount==true)ArrayCopy(TodosPares,TodosParesm,0,0,WHOLE_ARRAY );

if (!debug){color1=CLR_NONE;color2=CLR_NONE;}

if ( MarketInfo(Symbol(),MODE_POINT)==0.0001)Digito=10000;else Digito=100;

return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit(){ return(0);}

//+------------------------------------------------------------------+
//| expert start function
//+------------------------------------------------------------------+
int start()
{

if (debug==true)comentarios();

if (ChecarHorarioTrabalho()==1)return(0);

if( (isNewBar()) ){
if ( OrdensEmAndamento(MAGIC_Number,001,0)==1 )ChekExit(0);
if ( OrdensEmAndamento(MAGIC_Number,001,1)==1 )ChekExit(1);

}

if (OrdensEmAndamento(MAGIC_Number,001,2)==0) CheckEntry();

return(0);
}

//----------- VOIDS --------------------------------------------------------------------------------------
void UpdateValues(){

RSI=iRSI(NULL,0,RSI_Value,PRICE_CLOSE,0);
RSI_LOWP=iRSI(NULL,0,(iLowest(NULL,0,MODE_LOW,10,0),PRICE_CLOSE,0));
RSI_LOW=iRSI(NULL,0,(iLowest(NULL,0,MODE_LOW,10,0),PRICE_CLOSE,0));

}

bool CheckEntry(){

UpdateValues();
if(RSI_LOW>RSI_LOWP && Ask>=(Open[0]+(0*Point)))
SendOrder(0);

if ( RSI>=85 )
SendOrder(1);
}

void ChekExit(int bs)
{
UpdateValues();

if (bs==0){
if (RSI>=95) {
closeallBS(0,99,MAGIC_Number,001);
Print("Closed Buy ");
}
}

if (bs==1){
if (RSI<20){
closeallBS(1,99,MAGIC_Number,001);
Print("Closed Sell ");
}
}

}


void SendOrder(int bs)
{
double lt,price,t,s,sl,tp;
int erro;

if (bs==0){
int count=0;
int Ticket=-99;

while(Ticket<0)
{
RefreshRates();

if (StopLoss==0) sl=0;else sl=Low[1]-(StopLoss*Point);
if (TakeProfit==0)tp=0;else tp=Ask+(TakeProfit*Point);


Ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,5,sl,tp,EAName,MAGIC_Number,0,color1);

ContarNumeroOrdensDia++;
if(Ticket<0){
Print("erro = ",erro," GetLastError = ",GetLastError());
count++;
}
OrdemBS=0;
while (IsTradeContextBusy()) Sleep(250);
if (count>10)return(0);
}//while
}



if (bs==1) {
Ticket=-1;
count=0;

while(Ticket<0)
{
RefreshRates();

if (StopLoss==0) sl=0;else sl=High[1]+(StopLoss*Point);
if (TakeProfit==0)tp=0;else tp=Bid-(TakeProfit*Point);

Ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,5,sl,tp,EAName,MAGIC_Number,0,color2);

if(Ticket<0){
Print("erro = ",erro," GetLastError = ",GetLastError());
count++;
}

while (IsTradeContextBusy()) Sleep(250);
OrdemBS=1;
if (count>10)return(0);
}
}

}//void

void EsperarServidorDisponivel()
{
Sleep(250);
while (IsTradeContextBusy()) Sleep(250);
return(0);
}


void closeallBS(int BS,int BS2,int NumeroMagico,int NumeroMagico2)
{
int count=0;
int OK=0;
EsperarServidorDisponivel();

if (OrdersTotal()!=0)
while (OK!=1)
{
Total = OrdersTotal();

for( i=Total-1;i>=0;i--) {
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if ((OrderMagicNumber()==NumeroMagico ||OrderMagicNumber()==NumeroMagico2 )&& OrderSymbol()==Symbol() && (OrderType()==BS))
Ticket = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),10,Yellow);
if (Ticket==true)OK=1;else EsperarServidorDisponivel();
}
count++;
if (count>99){OK=1;Print("OrderClose Failure Tic = ",OrderTicket());}
}


OK=0;
if (OrdersTotal()!=0)
while (OK!=1)
{
Total = OrdersTotal();
for( i=Total-1;i>=0;i--) {

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if ((OrderMagicNumber()==NumeroMagico ||OrderMagicNumber()==NumeroMagico2 )&& OrderSymbol()==Symbol() &&(OrderType()==BS2))
Ticket = OrderDelete(OrderTicket());
if (Ticket==true)OK=1;else EsperarServidorDisponivel();
}
count++;
if (count>99){OK=1;Print("OrderClose OrderDelete Failure Tic = ",OrderTicket());}
}
}

//int tipo 0=buy 1=sell 2=qualqueruma
int OrdensEmAndamento(int Magic,int Magic2,int tipo)
{
//OP_BUY==0 OP_SELL==1
Tipo=111;
int Estado=0;
Total = OrdersTotal();
for (i=0;i<Total;i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES); //aqui Tipo so ta retornando certo pq esse Ea nao aceita ordens inversas abertas,logo so tera sell ou buy. Se fosse um Ea q aceitava tem de mudar isso pq da primeira passada ele pode achar o sell mas na 2 pode achar um buy e retornar o buy por final

if (tipo==0 || tipo==1){
if (OrderSymbol()==Symbol() && (OrderMagicNumber()==Magic ||OrderMagicNumber()==Magic2) && tipo==OrderType())
{Estado=1;Tipo=OrderType();break;}
}

if (tipo==2){
if (OrderSymbol()==Symbol() && (OrderMagicNumber()==Magic ||OrderMagicNumber()==Magic2))
{Estado=1;Tipo=OrderType();break;}
}
}
return(Estado);
}


void comentarios()
{
Comment ("----Working... ","\n",
"DayTrend = ",DayTrend,"\n",
"tpExitRule1 = ",tpExitRule1,"\n",
"L = ",L,"\n",
"H = ",H,"\n",
"BU = ",BU,"\n",
"BD = ",BD,"\n");
}


bool isNewBar()
{
bool res=false;
if (myBars!=Bars)
{
myBars=Bars;
res=true;
}
return(res);
}



int ChecarHorarioTrabalho()
{
DgGMTTime = TimeCurrent();
HorarioAgora=TimeToStr(DgGMTTime,TIME_MINUTES);
//Print("HorarioAgora = ",HorarioAgora);

if (HorarioAgora<StartHour){Comment("Start Hour dont reached....Waiting New Session");return(1);}
if (HorarioAgora>=StopHour){Comment("Stop Hour reached....Waiting New Session");return(1);}
Comment("Working...");


}

 

"i am trying to program finding the highest high or lowest low of the rsi indicator in X number of bars "

Build a series array inside your EA, and collect values of RSI for each of the bars you are interested in.

Examine the array for highest/lowest -- ArrayMax() ArrayMin() can do it.

 

I am newbie.

What I propose is

//////////////////////////////////////////////////////////////

int MaxMinRSI()

double HighestRSI = 0, LowestRSI=0;

int cnt = LastBar; //LastBar is How many bars do you want to look back?

for (int i=1; i < cnt; i++)
{

double RSI_I = iRSI(NULL, 0, RSI.period, RSI.applied_price, i);

HighestRSI = MathMax(RSI_I,HighestRSI);

LowestRSI = MathMin(RSI_I,LowestRSI);

Return (HighestRSI,LowestRSI);

}

//////////////////////////////////////////////////////////////

How do you think?