Keith Watford:
Usually if the bar you are checking !=EMPTY_VALUE and the previous bar value ==EMPTY_VALUE, then it has just changed.
Usually if the bar you are checking !=EMPTY_VALUE and the previous bar value ==EMPTY_VALUE, then it has just changed.
Hi, Keith, Thank you for your comment.
Wow,what a simple one.. I did not know it.
In this case,
int ret=0; int limit=1; for(int k=1;k<=limit;k++){ double buy=iCustom(NULL,TimeScale,indicator_name,k); double sell=iCustom(NULL,TimeScale,indicator_name,k);
I can compare with !=EMPTY_VALUE (k) and ==EMPTY_VALUE (k-1) previous one, right?
int ret=0; int limit=1; for(int k=1;k<=limit;k++){ double buy=iCustom(NULL,TimeScale,indicator_name,k); double sell=iCustom(NULL,TimeScale,indicator_name,k);
I don't know what the point of the loop is as it will only loop once.
Your doubles buy and sell are both given the same value - why?
int ret= 0 ; //int limit=1; //for(int k=1;k<=limit;k++){ double buy=iCustom(NULL,TimeScale,indicator_name,1,1); //double buy=iCustom(NULL,TimeScale,indicator_name,k); double sell=iCustom(NULL,TimeScale,indicator_name,2,1); //double sell=iCustom(NULL,TimeScale,indicator_name,k);
Buffer numbers are not specified.
Since k is always 1, there is no need to loop it.
Oh, that is my mistake.... Need buffer#.
Now I see, the loop is only once, so I don't need to loop it.
I will try again. Thank you so much.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, I have a question.
Receiving buffer signal from the indicator, I want to make BUY/SELL order
when trend color changes.
Attached indicator shows buffer signal such as
Buffer1 =BUY
BUffer2 =SELL
I can order if buffer1 or buffer2 is not EMPTY_VALUE.
However,if I do this, so many BUY/SELL orders are made....
How can I know when the signal changes from blue to white/ white to blue?
I just want to place order when color changes..
Appreciate if you give some ideas or an example code.
Thanks a lot!