its a bit diffrent than that but for the purpose of this thread lets say that im looking at 2 SMAs, 100 and 200.
what I want is to save the lowest low of an downtrend and the highest high of an uptrend.
the way approached it is first to check if sma100>sm200 for uptrend and vice versa.
if that happens I just said
uptrend=true
downtrend=false
and the other way round
here is the problem:
now i wanted to get the highs and lows, so i added another variable sayin
private double low = 100; - doesnt really matter what im puttin here i guess
private double high = 100;
now comes the part that went wrong.
if(downtrend){
low=Close[1]; [COLOR=YellowGreen]- had to go a candle back, but isnt really important[/COLOR]
if(Close[0]<low){
low=Close[0];
Print(Time[0] + " - low - "+(low));
}
im guessing bc the statement about the smas gets caluclated for every bar so im gettin an "downtrend" output also with every candle, which is messing up the thing.
so what can i do. link to information regarding this would be enough, i just down know what to search for.
2)further i want to save the lows of the last downtrend even if im goin into an uptrend for later access but since i said,
uptrend=true downtrend=false
even if not. it would definitly change the values if we have multiple downtrends, meaning if i would want to save the values of the last downtrend and the downtrend b4 that separately. this clearly wouldnt be possible with the code I got so far. so any ideas how to approach this?
Im guessing with a list or something but really hard to find something on that topic.
again, links would be enough (for now)
I know thats quite alot but hope u can help anyway.

Comment