could anyone explain this? it sounds like using icustom in reverse mode?!
i want a variable that says : "supertrend is green" or "red", so i have to get back the buffer value.
maybe i should be calling 2 supertrends (one in mode 0, one in mode 1) and discard one "obviously wrong" value, thus knowing wich mode is the good one at the moment??? is it a good way or is there a better option?
as u can c here
SetIndexStyle(0, DRAW_LINE, 0, 2); SetIndexBuffer(0, TrendUp); SetIndexStyle(1, DRAW_LINE, 0, 2); SetIndexBuffer(1, TrendDown);
Buffer 0 is green
& Buffer 1 is red
i made something approaching what i want but i cant understand the behaviour of this EA : its following supertrend switches sometimes, but it also reacts when the market reaches supertrend value...
here are the interresting lines of this code :
//green supertrend and previous value
double super0 = iCustom(NULL,0,"SuperTrend",0,1);
double prevsuper0 = iCustom(NULL,0,"SuperTrend",0,2);
//red supertrend and previous value
double super1 = iCustom(NULL,0,"SuperTrend",1,1);
double prevsuper1 = iCustom(NULL,0,"SuperTrend",1,2);
// turns to red
if ((super1!=2147483647) && (prevsuper1==2147483647)) Order=SIGNAL_CLOSEBUY;
if ((super1!=2147483647) && (prevsuper1==2147483647)) Order=SIGNAL_SELL;
//turns to green
if ((super0!=2147483647) && (prevsuper0==2147483647)) Order=SIGNAL_CLOSESELL;
if ((super0!=2147483647) && (prevsuper0==2147483647)) Order=SIGNAL_BUY;
i also wonder why this weird value of 2147483647 when the line isnt of the same color as the buffer, instead of a clean EMPTY_VALUE...
thanks again!!!
when i say "the EA reacts", it means it was supposed to keep the order runing until the new color change, and when the market price reaches supertrend, the EA dismisses the order...very strange_ i tried to spot the value of supertrend at this moment, and theres apparently nothing wrong ( like a micropscopic color change i would not have seen)
by the way, supertrend isnt supposed to make such tiny flips.
any idea??
clean EMPTY_VALUE... Gives the result of 2147483647
thanks for the hint!
is it possible that the supertrend dispayed on the graph is just an approximation? i just cant understand why the ea ignores some color changes, or why it closes orders in the middle of nowhere?!
I must tell you something, The EA is doing exactly what he was told to do, he is not doing anything what is not written in, so if there's a problem, that can only on the programmers hand

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi!
im quite new at coding and i discover many new features every day. i use to find my answers by googling but here im stuck with a -rather simple for experienced programmers- issue.
id like to get the color of supertrend in a variable, to trigger orders. i just dont find any info about this kind of operation anywhere...
im using the "SuperTrend.mq4" found on this reference website. i tried to understand the code by myself but i have to admit i havent understood a single thing in it...
thanks a lot!!!
den