You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I wanted to develop an indicator that when RSI is below 30 on H1 interval I can see blue arrows on other intervals - ex. M5, M15, H1, even H4.
But I have a problem - on live data it draws correctly - but when I attach my idicator to the window it doesn't show arrows in some places on H1 interval and H4.
In strategy tester I see that problematic periods are when RSI was below 30 only for short amount of time, for example 3:25 - 3:50. If that's the case it doesn't show the arrow on H1 interval. So what I tried to do is to check if RSI was below of 30 at any moment in this hour and if so I always draw an arrow even when RSI no logner is below 30.
It works on live data (in the tester). But after attaching my indicator to the window I still don't see arrows in the places when rsi was only briefly below 30. Maybe I should remember here about something? Or I have a flaw in my logic?
int lastDirection=EMPTY_VALUE;
bool isFirstChangeInTheHour(datetime currentDate)
{
if(lastChangeTime==currentDate)
{
return false;
}
return true;
}
void markChange(datetime currentDate)
{
lastChangeTime=currentDate;
}
// in oncalulate
for(int barNumber=0; barNumber<limit; barNumber++)
{
//For every bar
int h1BarIndex=iBarShift(NULL,PERIOD_H1,Time[barNumber]);
int h1Direction = getDirection(h1BarIndex); //this check for now if RSI is below 30, maybe the problem lies in the interval//
// this is what I tried to fix the issue
// get opening time of a bar
datetime beginningOfH1 = iTime(Symbol(),PERIOD_H1,h1BarIndex);
if(isFirstChangeInTheHour(beginningOfH1))
{
// if it changes for the first time in this hour
if(h1Direction==GOING_DOWN)
{
// prevent from drawing two overlapping shapes
lastDirection=GOING_DOWN;
Alert("First change in"+beginningOfH1+" date: "+Time[barNumber]);
arrowUp[barNumber]=EMPTY_VALUE;
arrowNothing[barNumber]=EMPTY_VALUE;
arrowDown[barNumber]=0;
markChange(beginningOfH1);
}
else if(h1Direction==GOING_UP)
{
lastDirection=GOING_UP;
Alert("First change in"+beginningOfH1+" date: "+Time[barNumber]);
arrowUp[barNumber]=0;
arrowDown[barNumber]=EMPTY_VALUE;
arrowNothing[barNumber]=EMPTY_VALUE;
markChange(beginningOfH1);
}
else if(h1Direction==NOTHING)
{
lastDirection=NOTHING;
if(arrowDown[barNumber]==EMPTY_VALUE && arrowUp[barNumber]==EMPTY_VALUE)
{
arrowNothing[barNumber]=0;
}
}
}
else
{
// Use global value after the first change was noticed
// so till the end of the hour we draw the same shape
if(lastDirection==GOING_DOWN)
{
arrowDown[barNumber]=0;
arrowUp[barNumber]=EMPTY_VALUE;
arrowNothing[barNumber]=EMPTY_VALUE;
}
else if(h1Direction==GOING_UP)
{
arrowUp[barNumber]=0;
arrowDown[barNumber]=EMPTY_VALUE;
arrowNothing[barNumber]=EMPTY_VALUE;
}
else if(h1Direction==NOTHING)
{
if(arrowDown[barNumber]==EMPTY_VALUE && arrowUp[barNumber]==EMPTY_VALUE)
{
arrowNothing[barNumber]=0;
}
}
}
}