Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

set bool parameter to true only for the first candle of a phase.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    set bool parameter to true only for the first candle of a phase.

    ok, im new to realativly programming and im currently working on one basic strategy (to learn more)

    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.

    Code:
    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));
                    }
    the problem here is, that i want the lowest low in the full downtrend period. but whenever im gettin a retracement the lows become bigger too.
    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,

    Code:
    uptrend=true
    downtrend=false
    I fear its actually deleting the values of "low" and "high" once im gettin a trendchange, didnt check this tho.
    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.
    Last edited by BigRo; 09-14-2015, 12:32 PM.

    #2
    nvm, think i got it.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X