Hello everyone, I have an indicator that define 2 market condition: uptrend (status =1) downtrend (status = 0 ). When trend change I want to draw n. lines with a fixed distance from a chosen price level. The problem would be that until the trend has changed current lines must be "extended" to the right so that they advance with price. Here's what I did:
I hope the code is clear enough... Basically it is:
Condition = true ? -> Draw NEW n lines
Contion = false ? -> Extend current lines to the current prices
Thank you
I've managed to fix the code, before it was not working at all giving no error message. Now it gives error "array out of range", but I declared the array with the right size, why it does not work?
I've managed to fix the code, before it was not working at all giving no error message. Now it gives error "array out of range", but I declared the array with the right size, why it does not work?
Solution:
if(status[iBar] == 1 && status[iBar+1] == 0) { for(int i=0; i<=ArraySize(level)-1; i++) { string obj2name = StringConcatenate("grid"+DoubleToString(i)+" "+time_day(Time[iBar])); //Time day is a function that return a string "DD-MM-YYYY HH.mm" current_lines[i] = obj2name; double price = status[iBar] == 0 ? ...[iBar]+...*level[i] : ...[iBar]-...*level[i]; ObjectCreate(0,obj2name,OBJ_TREND,0,Time[reverse_],price,Time[iBar],price); ObjectSetInteger(0,obj2name,OBJPROP_COLOR,clrOrange); ObjectSetInteger(0,obj2name,OBJPROP_WIDTH,2); ObjectSetInteger(0,obj2name,OBJPROP_RAY,false); ObjectSetInteger(0,obj2name,OBJPROP_SELECTABLE,false); } } else { for(int i=0; i<=ArraySize(level); i++) { ObjectSetInteger(0,current_lines[i],OBJPROP_TIME2,Time[iBar]); } }
I had to add "-1".
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone, I have an indicator that define 2 market condition: uptrend (status =1) downtrend (status = 0 ). When trend change I want to draw n. lines with a fixed distance from a chosen price level. The problem would be that until the trend has changed current lines must be "extended" to the right so that they advance with price. Here's what I did:
I hope the code is clear enough... Basically it is:
Condition = true ? -> Draw NEW n lines
Contion = false ? -> Extend current lines to the current prices
Thank you