Need help, couldn't manage on my own

To add comments, please log in or register
algomakina
8
algomakina  

my goal is: creating an indicator, which keeps track of trending indicator values. specifically using moving average, as a trailing stop level

I couldn't solve the issue:

if ma  [i] > ma [i+1] >> then this is a trend and, ma [i] is my indicator value at buffer[i]

     else >> ma [i+1] is my indicator value.

but... whenever this condition holds again at lower levels, my indicator starts adding ma[i] values as ordered with codes. my intention is holding the level same until price crosses the level.

to overcome the issue I tried different solutions but indicator stopped drawing line  when I added lines to this logic.

if anyone can help, how can I hold the indicator value same?  i.e. last indicator value at highest ma value - until the loop is stopped with another event.


thanks in advance.

M.R.
46
M.R.  
ma(shift,price_high) for short/sell, and v.v. ma(shift,price_low) for longs/buys. Can that do the job for trailing ^. Example:
int shifts = 5;
ma_trail_level_longs  = iMA(NULL,0,5,shifts,0,PRICE_LOW,0);
ma_trail_level_shorts = iMA(NULL,0,5,shifts,0,PRICE_HIGH,0);
ffoorr
1154
ffoorr  
algomakina:

my goal is: creating an indicator, which keeps track of trending indicator values. specifically using moving average, as a trailing stop level

I couldn't solve the issue:

if ma  [i] > ma [i+1] >> then this is a trend and, ma [i] is my indicator value at buffer[i]

     else >> ma [i+1] is my indicator value.

but... whenever this condition holds again at lower levels, my indicator starts adding ma[i] values as ordered with codes. my intention is holding the level same until price crosses the level.

to overcome the issue I tried different solutions but indicator stopped drawing line  when I added lines to this logic.

if anyone can help, how can I hold the indicator value same?  i.e. last indicator value at highest ma value - until the loop is stopped with another event.


thanks in advance.



double valeur[5];

if( ma[i] > ma [i+1] ) valeur[i] = ma[i];
else                   valeur[i] = ma[i];   

//------------------------------------------

#define up 0
#define down 1 
double valeur[5][2];
if( ma[i] > ma [i+1] ) valeur[i][up] = ma[i];
else                   valeur[i][down] = ma[i];    

if( close[i] > valeur[i][down] )  valeur[i][down] = 0.0;

or change name to have up and down MA buffers
To add comments, please log in or register