Page 1 of 1

A little help for modifying an indicator

PostPosted: Wed Feb 15, 2017 3:14 am
by 030985
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

Re: A little help for modifying an indicator

PostPosted: Thu Feb 16, 2017 7:17 am
by Apprentice
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

Re: A little help for modifying an indicator

PostPosted: Sat Feb 25, 2017 3:46 am
by 030985
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

Re: A little help for modifying an indicator

PostPosted: Tue Feb 28, 2017 4:43 am
by Apprentice
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.