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);
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
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.