Copy Close/Open/High/Low()

To add comments, please log in or register
GrumpyDuckMan
882
GrumpyDuckMan  

Hello everyone,

I don't don't understand the error I get. The error always points to this area

Close_Array [limit]);
#property strict

double High_Array[12],
       Low_Array[12],
       Close_Array[12],
       Open_Array[12],
       Target_Array[12];
       
int    Candle_Count=8,
       Time_Be_Counted=0,
       limit=0,
       start_copy=0,
       New_Target[];
//+---------------------------------------------------------------------------------------------------------+
extern ENUM_CHART_MODE CHART_MODES=1;
extern ENUM_TIMEFRAMES TIME_FRAME=0;
extern bool CHART_PERIOD=false;
extern bool SCROLL_ON=true;
extern long CHARTS_SIZE=2;
extern bool GRID=false;
extern bool OHLC=true;
//+---------------------------------------------------------------------------------------------------------+
int OnInit(){
   bool T=ChartSetSymbolPeriod(0,Symbol(),TIME_FRAME); 
          ChartSetInteger(0,CHART_SHOW_PERIOD_SEP,CHART_PERIOD); 
          ChartSetInteger(0,CHART_COLOR_BACKGROUND,clrBlack);
          ChartSetInteger(0,CHART_AUTOSCROLL,SCROLL_ON);    
          ChartSetInteger(0,CHART_SCALE,CHARTS_SIZE);   
          ChartSetInteger(0,CHART_MODE,CHART_MODES);  
          ChartSetInteger(0,CHART_SHIFT,1);      
          ChartSetInteger(0,CHART_SHOW_GRID,GRID);   
          ChartSetInteger(0,CHART_SHOW_OHLC,OHLC);
 
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnTick()
  {}
  
void Get_Rates()  
{
// int  CopyClose (symbol_name, timeframe, start_pos,  count,     close_array[]);
// int  CopyClose (symbol_name, timeframe, start_time, count,     close_array[]);
// int  CopyClose (symbol_name, timeframe, datetime,   stop_time, close_array[]);

int MyClose=  CopyClose(Symbol(),TIME_FRAME, start_copy, Time_Be_Counted, Close_Array [limit]); // 'Close_Array' - array required
int MyOpen=   CopyOpen(Symbol() ,TIME_FRAME, start_copy, Time_Be_Counted, Open_Array  [limit]);
int MyHigh=   CopyHigh(Symbol() ,TIME_FRAME, start_copy, Time_Be_Counted, High_Array  [limit]);
int MyLow=    CopyLow(Symbol()  ,TIME_FRAME, start_copy, Time_Be_Counted, Low_Array   [limit]);
   }
Carl Schreiber
Moderator
8834
Carl Schreiber  

Try this:

int MyClose=  CopyClose(Symbol(),TIME_FRAME, start_copy, Time_Be_Counted, Close_Array); // 'Close_Array' - array required
GrumpyDuckMan
882
GrumpyDuckMan  

Hello again,

Thank you sir, some more help required please.

From my own experience. There appears to be a more technical approach to reading data. Regardless of experience, or knowledge. 

      int slippage=int((Ask-Bid)*0.18/_Point);

The above was found on MQL forum. To me this reads as slippage = spread * factor/points.

Now the "factor" bit has stumped me.

      int slippage=int((Ask-Bid)*Magnitude/_Point);

Now where I put ( multiply Magnitude / _point);

Basically, I am still struggling with the meaning behind slippage.  

GrumpyDuckMan
882
GrumpyDuckMan  

Hello again,

I have been trying to work on Correlations lately, but I have already run into my first problem. The first "AUD_Symbols()" works fine. I tried to change the code to make an array

"string AUD_Symbols[]={"AUDUSD","AUDCAD","AUDNZD","AUDCHF","AUDJPY"};" . How would I be able to run the for loop on the first array until its finished writing to the first "AUD_Symbols_Close"..etc?

Afterwards count backwards or forwards on the string "AUD_Symbols[]={"AUDUSD","AUDCAD","AUDNZD","AUDCHF","AUDJPY"};".




//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void AUD_Symbols()
  {
   for(i=0; i<50; i++)
     {
      Chart_ID = ChartOpen ("AUDUSD",TIME_FRAME);
      MyClose  = CopyClose ("AUDUSD",TIME_FRAME,0,i, AUD_Symbols_Close);
      MyOpen   = CopyOpen  ("AUDUSD",TIME_FRAME,0,i, AUD_Symbols_Open);
      MyHigh   = CopyHigh  ("AUDUSD",TIME_FRAME,0,i, AUD_Symbols_High);
      MyLow    = CopyLow   ("AUDUSD",TIME_FRAME,0,i, AUD_Symbols_Low);
      MyTime   = CopyTime  ("AUDUSD",TIME_FRAME,0,i, AUD_Symbols_Time);
     }
  }
//+------------------------------------------------------------------+
//|  AUD_Symbols[]={"AUDUSD","AUDCAD","AUDNZD","AUDCHF","AUDJPY"};   |
//+------------------------------------------------------------------+
void AUD_Symbols()
  {
   int x=ArraySize(AUD_Symbols); 

   AUD_Symbols[x]=SymbolName(x,true);
   for(i=0; i<50; i++)
     {
      Chart_ID = ChartOpen (AUD_Symbols[x],TIME_FRAME);
      MyClose  = CopyClose (AUD_Symbols[x],TIME_FRAME,0,i, AUD_Symbols_Close);
      MyOpen   = CopyOpen  (AUD_Symbols[x],TIME_FRAME,0,i, AUD_Symbols_Open);
      MyHigh   = CopyHigh  (AUD_Symbols[x],TIME_FRAME,0,i, AUD_Symbols_High);
      MyLow    = CopyLow   (AUD_Symbols[x],TIME_FRAME,0,i, AUD_Symbols_Low);
      MyTime   = CopyTime  (AUD_Symbols[x],TIME_FRAME,0,i, AUD_Symbols_Time);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Marco vd Heijden
Moderator
12688
Marco vd Heijden  
string symbols[];
ArrayResize(symbols,SymbolsTotal(1),0);

//--- pre-loader
for(int i=0;i<SymbolsTotal(1);i++)
  {
   symbols[i]=SymbolName(i,1);
  }

//--- re-loader
for(int i=0;i<SymbolsTotal(1);i++)
  {
   Print("SYMBOL: ",symbols[i]," Found At: ",i);
   
   // Do Something for symbol[i]...
  }

Also you can use:

iOpen(symbols[i],PERIOD_CURRENT,bar);
iHigh(symbols[i],PERIOD_CURRENT,bar);
iLow(symbols[i],PERIOD_CURRENT,bar);
iClose(symbols[i],PERIOD_CURRENT,bar);
iTime(symbols[i],PERIOD_CURRENT,bar);

Etc...

GrumpyDuckMan
882
GrumpyDuckMan  

Hello friends,

I am still struggling with this code. I keep on getting array out of range error. I know why it happens, but I am a bit lost as to how to make AUD only increment after "I" is >= to 10 and not leave the for loop until AUD = x

Anyone with some new ideas to make this possible ?


void AUD_Symbols()
  { 
   int x=ArraySize(AUD_Symbols); // x = 5

      
   for(i = 0; i < 10; i++)
     {
      AUD_Symbols[AUD]=SymbolName(AUD,true);
      Chart_ID = ChartOpen (AUD_Symbols[AUD],TIME_FRAME);
      MyClose  = CopyClose (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_Close);
      MyOpen   = CopyOpen  (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_Open);
      MyHigh   = CopyHigh  (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_High);
      MyLow    = CopyLow   (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_Low);
    if(i <= 10 )   AUD++;
    continue; 
    }
  }
GrumpyDuckMan
882
GrumpyDuckMan  

Hello again,

I came up with this code. It sort of does the trick, but is badly floored in its execution.

int AUD_Symbols()
  { 
     int x=ArraySize(AUD_Symbols);   ArrayResize(AUD_Symbols,x);
     for(i = 0; i < COUNT_TO; i++)
   {  
      AUD_Symbols[AUD]=SymbolName(AUD,true);
      MyClose  = CopyClose (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_Close);
      MyOpen   = CopyOpen  (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_Open);
      MyHigh   = CopyHigh  (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_High);
      MyLow    = CopyLow   (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_Low);
      MyTime   = CopyTime  (AUD_Symbols[AUD],TIME_FRAME,0,i, AUD_Symbols_Time); 
     continue; 
    }
    AUD++;
    return(AUD);
  }
To add comments, please log in or register