A little help for modifying an indicator

Moderator: admin

A little help for modifying an indicator

Postby 030985 » Wed Feb 15, 2017 3:14 am

Hello everyone ,

I somes times use an indicator that, to make his calculations, look for the last time the High of the candle was visited, in the past. That means the calculation looks for this price on the 'left' side of the current candle.

I would like to do exactly the same, but that the calculation looks for this High price on the right side of the current candle, to make the calculation.

The code part associated with this function is this :
Code: Select all
function FindHigh(index)
  local i=index-1;
  while i>first do
    if source.high[i]>=source.high[index] then
      return i;
    end
    i=i-1;
  end
  return nil;


What should I modify to make the change ? (if possible)

Thank you very muchfor your help ! :)

030985
030985
 
Posts: 53
Joined: Sun Apr 01, 2012 12:04 pm

Re: A little help for modifying an indicator

Postby Apprentice » Thu Feb 16, 2017 7:17 am

Code: Select all
function R_FindHigh(start)
  local last=source:size()-1;
 
  local max;
  local Return;
  for index=start, last,  1 do
    if source.high[index]>=source.high[start] then
     Return = index;
    end
    return Return;
  end


 function L_FindHigh(start)
 
  local max;
  local Return;

  for index=start, source:first() , - 1 do
    if source.high[index]>=source.high[start] then
     Return = index;
    end
    return Return;
  end
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 19800
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: A little help for modifying an indicator

Postby 030985 » Sat Feb 25, 2017 3:46 am

Good afternoon,

Thank you very much for your reply Apprentice. But it seems there is something I do not get :

I assume that R_Findhigh is to look at the right ? And L_Findhigh to look at the left ?

If I change this function in the original indicator :
Code: Select all
function FindHigh(index)
  local i=index-1;
  while i>first do
    if source.high[i]>=source.high[index] then
      return i;
    end
    i=i-1;
  end
  return nil;


for

Code: Select all
function R_FindHigh(start)
  local last=source:size()-1;
 
  local max;
  local Return;
  for index=start, last,  1 do
    if source.high[index]>=source.high[start] then
     Return = index;
    end
    return Return;
  end


The value calculated by the indicator is wrong ( it is always equal to the close of current bar).

Because the logic of the indicator is still the same but I just want to look at the right of candle instead of the left, I assumed that only the funtion part looking for the High had to be changed.
Is it wrong assumption ?

Thank you again for your assistance.

030985
030985
 
Posts: 53
Joined: Sun Apr 01, 2012 12:04 pm

Re: A little help for modifying an indicator

Postby Apprentice » Tue Feb 28, 2017 4:43 am

I assume that R_Findhigh is to look at the right ? And L_Findhigh to look at the left ?

Can you share the entire code.


For the last candle, there is no right.
Therefore, the current high candle will be will be High of the period.
Write a detailed description, so I can understand your trading ideas.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 19800
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 4 guests