Export to Excel

Back to topics list To post a new topic, please log in or register
avatar
23
Dtfrancis15 2016.07.11 21:16
 
I am new to this and have done my first script to collect information from multiple time frames, review the profit ratios and if criteria all met, then place an OCO given parameters I have been  set.  However, I want to take this portion of the script and run a script that exports all this information to a spreadsheet across multiple currency pairs.  How do I do this?

Print("Current bar for "Symbol()" H1: ",iTime(NULL,PERIOD_H1,0),", ", iOpen(NULL,PERIOD_H1,0),", ",
iHigh(NULL,PERIOD_H1,0),", ", iLow(NULL,PERIOD_H1,0),", ",
iClose(NULL,PERIOD_H1,0),", ", iVolume(NULL,PERIOD_H1,0));

Print("Current bar for "Symbol()" D1: ",iTime(NULL,PERIOD_D1,0),", ", iOpen(NULL,PERIOD_D1,0),", ",
iHigh(NULL,PERIOD_D1,0),", ", iLow(NULL,PERIOD_D1,0),", ",
iClose(NULL,PERIOD_D1,0),", ", iVolume(NULL,PERIOD_D1,0));


Print ("Lowest Range value between 12am and 7am: ",Low[iLowest(NULL,PERIOD_H1,MODE_LOW,7,0)]);

Print ("Highest Range value between 12am and 7am: ",High[iHighest(NULL,PERIOD_H1,MODE_HIGH,7,0)]);
avatar
164
rod178 2016.07.12 06:21 #
 
Dtfrancis15:
I am new to this and have done my first script to collect information from multiple time frames, review the profit ratios and if criteria all met, then place an OCO given parameters I have been  set.  However, I want to take this portion of the script and run a script that exports all this information to a spreadsheet across multiple currency pairs.  How do I do this?

Print("Current bar for "Symbol()" H1: ",iTime(NULL,PERIOD_H1,0),", ", iOpen(NULL,PERIOD_H1,0),", ",
iHigh(NULL,PERIOD_H1,0),", ", iLow(NULL,PERIOD_H1,0),", ",
iClose(NULL,PERIOD_H1,0),", ", iVolume(NULL,PERIOD_H1,0));

Print("Current bar for "Symbol()" D1: ",iTime(NULL,PERIOD_D1,0),", ", iOpen(NULL,PERIOD_D1,0),", ",
iHigh(NULL,PERIOD_D1,0),", ", iLow(NULL,PERIOD_D1,0),", ",
iClose(NULL,PERIOD_D1,0),", ", iVolume(NULL,PERIOD_D1,0));


Print ("Lowest Range value between 12am and 7am: ",Low[iLowest(NULL,PERIOD_H1,MODE_LOW,7,0)]);

Print ("Highest Range value between 12am and 7am: ",High[iHighest(NULL,PERIOD_H1,MODE_HIGH,7,0)]);

 

FileOpen(sFileName,FILE_CSV|FILE_WRITE|FILE_READ, ';')

 after writing  text data import into excel    

 

avatar
2017
gooly 2016.07.12 07:46 #
 
What about using the example of the editor's reference? Just place the cursor above FileOpen, press F1 and read...
avatar
164
rod178 2016.07.14 07:06 #
 
FileOpen(sFileName,FILE_CSV|FILE_WRITE|FILE_READ, ';')
 LOL  happy?
avatar
23
Dtfrancis15 2016.07.14 17:14 #
 
rod178:
 LOL  happy?
Thanks Rod178 - will try that tonight.
avatar
23
Dtfrancis15 2016.07.14 18:13 #
 
That was spot on - thanks again Rod.

Now to work out how to do this for multiple pairs in sequence, not just the active pair you drag the script to.
avatar
23
Dtfrancis15 2016.07.14 20:57 #
 
I have amended the script to now capture the relevant values and successfully right to Excel - using the Symbol () command, this works well, but when I substitute this for the currency pair name, as below, it reports "Array Out of Range" for the two range variables.

//---Display Values of candles
//--- Hourly Candle
double H1_High_b = iHigh("USDJPY",PERIOD_H1,0);
double H1_Low_b = iLow("USDJPY",PERIOD_H1,0);
datetime H1_Date_b = iTime("USDJPY", PERIOD_H1,0);
//--- Daily Candle
double D1_High_b = iHigh("USDJPY",PERIOD_D1,1);
double D1_Low_b = iLow("USDJPY",PERIOD_D1,1);
datetime D1_Date_b = iTime("USDJPY", PERIOD_D1,1);
//--- Candle Ranges 7 candles hourly
double Low_Range_b = Low[iLowest("USDJPY",PERIOD_H1,MODE_LOW,7,1)];
double High_Range_b = High[iHighest("USDJPY",PERIOD_H1,MODE_HIGH,7,1)];
//--- Calculations

Does this need to be run an active chart to calculate the range?
avatar
164
rod178 2016.07.15 19:25 #
 
double PriceHigh(string symbol, int countPeriod, datetime time1, datetime time2)
{   
    if(time1>iTime(symbol,countPeriod,0) || time2>iTime(symbol,countPeriod,0)) return(iHigh(symbol,PERIOD_W1,0)); 
    time1=time1-1;
    time2=time2-1;
    double priceHigh;
    priceHigh=iHigh(symbol,countPeriod,iHighest(symbol,countPeriod,MODE_HIGH,iBarShift(symbol,countPeriod,time1)-iBarShift(symbol,countPeriod,time2),iBarShift(symbol,countPeriod,time2)));
    if(priceHigh==0) priceHigh=iOpen(symbol,countPeriod,iBarShift(symbol,countPeriod,time1));
    return(priceHigh);
}

try this little method 

 

PS  use the SRC to paste code, ie as in my example 

avatar
23
Dtfrancis15 2016.07.18 23:03 #
 
Thanks Rod178!!!!
Back to topics list  

To add comments, please log in or register