hi dottormarket,
just add a value so the name of object will be different :
string instrument[]; int size_inst = ArrayResize(instrument,SymbolsTotal(true) ); // ??????? for(B=0; B<size_inst; B++) { instrument[B] = SymbolName(B,true); if(Percentuale[B]>Signal) { ObjectCreate("PerValuta"+instrument[B],OBJ_LABEL,0,0,0); ObjectSet ("PerValuta"+instrument[B],OBJPROP_CORNER,CORNER_LEFT_UPPER); ObjectSet ("PerValuta"+instrument[B],OBJPROP_YDISTANCE,(15*B)+40); ObjectSet ("PerValuta"+instrument[B],OBJPROP_XDISTANCE,10); ObjectSet ("PerValuta"+instrument[B],OBJPROP_HIDDEN,True); ObjectSet ("PerValuta"+instrument[B],OBJPROP_SELECTABLE,false); ObjectSetText("PerValuta"+instrument[B],""+ instrument[B]+" "+(string)NumeroValuta[B],8,"Calibri",clrBlack);// ?????? WindowRedraw(); } }
DottorMarket: The main problem is that data "Percentuale" is sorted in descending order but the currency names are wrong...
The moment you sort Percentuale, there is no longer a connection to NumeroValuta and the symbol. Either don't sort as suggested by ffoorr, or you must keep the connection via a 2d array:Percentuale[i] = Percent; NumeroValuta[i] = i; // ????? ArraySort(Percentuale,WHOLE_ARRAY,0,MODE_DESCEND); // The problem is here, infact I lose data "valuta"
#define Percentuale 0 #define NumeroValuta 1 #define COUNT 2 double Array[][COUNT]; ArrayResize(Array,SymbolsTotal(StrumentiWatchList)); for(int i=0; SymbolsTotal(StrumentiWatchList)>i; i++){ : Array[i][Percentuale] = Percent; Array[i][NumeroValuta] = i; } ArraySort(Array,WHOLE_ARRAY,0,MODE_DESCEND); for(B=0; SymbolsTotal(StrumentiWatchList)>B; B++) { if(Array[B][Percentuale]>Signal) { int iSymbol = Array[B][NumeroValuta] string Instrument = SymbolName(iSymbol,true); ObjectCreate("PerValuta"+Instrument,OBJ_LABEL,0,0,0); :
You where right WHRoeder, I have followed your code line, but nothing show up in the window, maybe someone will be more lucky :
#define Percentuale 0 #define NumeroValuta 1 #define COUNT 2 double Array[][2]; int CreateIndi_2() { double open,close,pourcent;int B=0; double Signal = 0.5; int Divisore[]; string symb[]; ObjectsDeleteAll(); string Instrument; int size_arr = ArrayResize(Array,SymbolsTotal(true)); int size_ins = ArrayResize(symb,SymbolsTotal(true)); int size_div = ArrayResize( Divisore,SymbolsTotal(true)); for(int i=0; i<size_arr; i++) { RefreshRates(); open = iOpen( SymbolName(i,true),PERIOD_D1,0); close = iClose( SymbolName(i,true),PERIOD_D1,0); pourcent = ((close - open)/open)*100; Array[i][0] = pourcent; Array[i][1] = i; symb[i] = SymbolName(i,true); if(MarketInfo(symb[i], MODE_PROFITCALCMODE)==0) Divisore[i]=10; else Divisore[i]=1; } ArraySort(Array,WHOLE_ARRAY,0,MODE_DESCEND); for( B=0; B< size_arr; B++) { // if(Array[B][Percentuale]>Signal) // { int iSymbol = (int) Array[B][NumeroValuta]; Instrument = SymbolName(iSymbol,true); ObjectCreate("PerValuta2"+Instrument,OBJ_LABEL,0,0,0); ObjectSet ("PerValuta2"+Instrument,OBJPROP_CORNER,CORNER_LEFT_UPPER); ObjectSet ("PerValuta2"+Instrument,OBJPROP_YDISTANCE,(15*B)+20); ObjectSet ("PerValuta2"+Instrument,OBJPROP_XDISTANCE,10); ObjectSet ("PerValuta2"+Instrument,OBJPROP_HIDDEN,True); ObjectSet ("PerValuta2"+Instrument,OBJPROP_SELECTABLE,false); ObjectSetText("PerValuta2"+Instrument,"ooo"+Instrument+" "+(string)Array[B][NumeroValuta],8,"Calibri",clrYellow);// ?????? WindowRedraw(); ObjectCreate("PerValore2"+Instrument,OBJ_LABEL,0,0,0); ObjectSet ("PerValore2"+Instrument,OBJPROP_CORNER,CORNER_LEFT_UPPER); ObjectSet ("PerValore2"+Instrument,OBJPROP_YDISTANCE,(15*B)+20); ObjectSet ("PerValore2"+Instrument,OBJPROP_XDISTANCE,125); ObjectSet ("PerValore2"+Instrument,OBJPROP_HIDDEN,True); ObjectSet ("PerValore2"+Instrument,OBJPROP_SELECTABLE,false); ObjectSetText("PerValore2"+Instrument,"ooo"+DoubleToStr(Array[B][Percentuale],2)+" %",8,"Calibri",clrLime); WindowRedraw(); // } } return( 0 ); } //============================================================================
Thanks guys!!!
A very great solution... It works perfectly!
Doc
hello and H.N. year =))
The code posted by ffoorr is perfect but there is a new problem if I impose strict mode.
When I impose strict mode the compiler returns "array out of range" in... etc etc
how can I fix this problem? :(
thanks
Alfredo
nothing?
DottorMarket: returns "array out of range" in...
DottorMarket: nothing? |
|
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
Hello to everyone!
I don't know how to solve this problem....
The main problem is that data "Percentuale" is sorted in descending order but the currency names are wrong... How can I solve?
Thanks