Change the symbol in a script execution

Back to topics list To post a new topic, please log in or register
avatar
13
Jusyer 2015.02.25 05:15
 

Hi.

I wonder if you can change the symbol in a single execution of the script. I have a script that analyzes various candles symbol of the window where I throw it, and I would like, in the same execution, change the symbol and also analyze candles of the new symbol.

All this is to not have to go putting the script in all windows, and work less well :)

Thanks, greetings.

avatar
164
rod178 2015.02.25 06:43 #
 
Jusyer:

Hi.

I wonder if you can change the symbol in a single execution of the script. I have a script that analyzes various candles symbol of the window where I throw it, and I would like, in the same execution, change the symbol and also analyze candles of the new symbol.

All this is to not have to go putting the script in all windows, and work less well :)

Thanks, greetings.

Yes, it is possible to run code on a Symbol(s) other than the current Chart, although without seeing your code cannot provide further advice.
avatar
13
Jusyer 2015.02.25 07:44 #
 
Thanks for responding.
The code is simple, measures a number of candles and returns how many over a certain size.
Would I have to change the core of the code? or you can put some instruction before, which change the symbol and then run the core of the code?
avatar
1211
deysmacro 2015.02.25 10:28 #
 
No code no help. Sorry. Use SRC when posting code.
avatar
108
BigAl 2015.02.25 10:35 #
 
Look at documentation on MarketInfo
avatar
Moderator
3427
GumRai 2015.02.25 10:57 #
 
Jusyer:
Thanks for responding.
The code is simple, measures a number of candles and returns how many over a certain size.
Would I have to change the core of the code? or you can put some instruction before, which change the symbol and then run the core of the code?

One way of doing it would be to put the symbols in a string array

ie

string Symbs="EURUSD,GBPUSD,USDJPY"

You can change and/or add symbol names. Just separate them with a comma. The symbol names must be the same as your broker uses 

string Symbs="EURUSDm,GBPUSDm,USDJPYm,USDCHFm,EURJPYm" 

input string Symbs="EURUSD,GBPUSD,USDJPY";

  string SymbolArray[];
  int array_size; 
     
  //in onOnit
    
  ushort u_sep=StringGetCharacter(",",0);
  StringSplit(Symbs,u_sep,SymbolArray);
  array_size=ArraySize(SymbolArray);

  //In Main code

  for(int x=0;x<array_size;x++)
    {
    double last_candle_close=iClose(SymbolArray[x],PERIOD_H1,1);
    int dig=(int)MarketInfo(SymbolArray[x],MODE_DIGITS);
    string lcc=DoubleToStr(last_candle_close,dig);
    Print(SymbolArray[x]+"Last candle close="+lcc);
    //The Print is just to show that it works. 
    }
  

 

 

avatar
13
Jusyer 2015.02.25 11:02 #
 
input int Puntos = 100;
input int Velas = 7200;

void OnStart()
{
  int contador=0;
  
  for (int i=0; i<Velas; i++) 
  {
     
     if(Open[i]-Close[i]>Puntos*Point || Close[i]-Open[i]>Puntos*Point)
     {
         contador++;
         ObjectCreate(ChartID(),"flecha"+i,OBJ_VLINE,0,Time[i],High[i]);
     }
  }
  Alert(Symbol() + ": Analizadas: " + Velas + ". Tamaño: " + Puntos + ". Total: " + contador);   
}    
             
This is the code, very simple.
avatar
13012
WHRoeder 2015.02.25 13:46 #
 
Jusyer: I wonder if you can change the symbol in a single execution of the script.  change the symbol and also analyze candles of the new symbol.
Not possible. If you change the chart, you get a pop up message, the script exits and it's gone.
  1. Keep the chart as is, look at other symbols (e.g. GumRai ,) change at the end if needed.
  2. Use an EA.
avatar
13
Jusyer 2015.02.25 20:21 #
 
Thanks guys.
I think with "iOpen" and "iClose" I can do. I'll try and tell you the result.
Greetings.
Back to topics list  

To add comments, please log in or register