Hi guys,
I have created an indicator that will sum the volume from a custom time session. The indicator is running on a 24 hour time template on CME futures. Indicator is using DDE links to export the value to the excel. Here is my code working as it should:
Thing is that I need to export highest values from the session for last 20 days. Here is the code I came up with:
Problem is that the indicator needs to run on 24 hour time template and I have a problem with getting the correct values for the previous days (number of bars back). Number of bars for each day is changing so the hard numbers are not really helping here:
Is there a way that I can get it working properly?
Any help would be greatly appreciated.
Thank you.
I have created an indicator that will sum the volume from a custom time session. The indicator is running on a 24 hour time template on CME futures. Indicator is using DDE links to export the value to the excel. Here is my code working as it should:
Code:
function preMain() { setPriceStudy(false); setStudyTitle("CME US Vol"); setCursorLabelName("CME US Vol"); setDefaultBarStyle(PS_SOLID, 0); setDefaultBarFgColor(Color.blue, 0); setDefaultBarThickness(1, 0); setPlotType(PLOTTYPE_HISTOGRAM, 0); } var USVol=0; function main() { if (getHour(0) >= 18 || getHour(0) <7 || day(0) != day(-1)) { USVol=0; }else{ if(getBarState()==BARSTATE_NEWBAR && day(0) == day(-1)){ USVol+=volume(-1); if (USVol != null){ var sName = "USVol" + getSymbol() + getInterval(); sName = sName.replace(/\$/g, ""); sName = sName.replace(/\#/g, ""); sName = sName.replace(/\-/g, ""); sName = sName.replace(/\(/g, ""); sName = sName.replace(/\!/g, ""); sName = sName.replace(/\=/g, ""); sName = sName.replace(/\:/g, ""); sName = sName.replace(/\)/g, ""); sName = sName.replace(/\ /g, "_") debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName); ddeUSVol = new DDEOutput(sName); } ddeUSVol.set(USVol); } } return USVol; }
Thing is that I need to export highest values from the session for last 20 days. Here is the code I came up with:
Code:
var ddeAHH=null; var avg=null var tvol = null; var tvolf = null; function preMain() { setPriceStudy(false); setStudyTitle("CME Tokyo Vol 20"); setCursorLabelName("CME Tokyo Vol 20"); setDefaultBarStyle(PS_SOLID, 0); setDefaultBarFgColor(Color.blue, 0); setDefaultBarThickness(1, 0); setPlotType(PLOTTYPE_HISTOGRAM, 0); } function main() { tvol = efsInternal("TVol"); tvolf = highest(250,tvol); avg = tvolf.getValue(0) avg1 = tvolf.getValue(-100) avg2 = tvolf.getValue(-200) avg3 = tvolf.getValue(-300) avg4 = tvolf.getValue(-400) avg5 = tvolf.getValue(-500) avg6 = tvolf.getValue(-600) avg7 = tvolf.getValue(-700) avg8 = tvolf.getValue(-800) avg9 = tvolf.getValue(-900) avg10 = tvolf.getValue(-1000) avg11 = tvolf.getValue(-1100) avg12 = tvolf.getValue(-1200) avg13 = tvolf.getValue(-1300) avg14 = tvolf.getValue(-1400) avg15 = tvolf.getValue(-1500) avg16 = tvolf.getValue(-1600) avg17 = tvolf.getValue(-1700) avg18 = tvolf.getValue(-1800) avg19 = tvolf.getValue(-1900) if (ddeAHH == null) { var sName = "AHH" + getSymbol() + getInterval(); sName = sName.replace(/\$/g, ""); // remove $ from string sName = sName.replace(/\#/g, ""); // remove # from string sName = sName.replace(/\-/g, ""); sName = sName.replace(/\(/g, ""); sName = sName.replace(/\)/g, ""); sName = sName.replace(/\ /g, "_") // replace space with underscore debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName); ddeAHH = new DDEOutput(sName); var sName1 = "avg1" + getSymbol() + getInterval(); sName1 = sName1.replace(/\$/g, ""); // remove $ from string sName1 = sName1.replace(/\#/g, ""); // remove # from string sName1 = sName1.replace(/\-/g, ""); sName1 = sName1.replace(/\(/g, ""); sName1 = sName1.replace(/\)/g, ""); sName1 = sName1.replace(/\ /g, "_") // replace space with underscore debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName1); ddeavg1 = new DDEOutput(sName1); var sName2 = "avg2" + getSymbol() + getInterval(); sName2 = sName2.replace(/\$/g, ""); // remove $ from string sName2 = sName2.replace(/\#/g, ""); // remove # from string sName2 = sName2.replace(/\-/g, ""); sName2 = sName2.replace(/\(/g, ""); sName2 = sName2.replace(/\)/g, ""); sName2 = sName2.replace(/\ /g, "_") // replace space with underscore debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName2); ddeavg2 = new DDEOutput(sName2); var sName3 = "avg3" + getSymbol() + getInterval(); sName3 = sName3.replace(/\$/g, ""); // remove $ from string sName3 = sName3.replace(/\#/g, ""); // remove # from string sName3 = sName3.replace(/\-/g, ""); sName3 = sName3.replace(/\(/g, ""); sName3 = sName3.replace(/\)/g, ""); sName3 = sName3.replace(/\ /g, "_") // replace space with underscore debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName3); ddeavg3 = new DDEOutput(sName3); REST OF THE DDE LINKS FORMULA WAS CUT OUT AS THE CODE WAS TOO LONG FOR POSTING!!! >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> } ddeAHH.set(avg); ddeavg1.set(avg1); ddeavg2.set(avg2); ddeavg3.set(avg3); ddeavg4.set(avg4); ddeavg5.set(avg5); ddeavg6.set(avg6); ddeavg7.set(avg7); ddeavg8.set(avg8); ddeavg9.set(avg9); ddeavg10.set(avg10); ddeavg11.set(avg11); ddeavg12.set(avg12); ddeavg13.set(avg13); ddeavg14.set(avg14); ddeavg15.set(avg15); ddeavg16.set(avg16); ddeavg17.set(avg17); ddeavg18.set(avg18); ddeavg19.set(avg19); return tvolf; } var TokyoVol = null; function TVol(){ if (getHour(0) >= 3 && getHour(0) <18) { TokyoVol=0; }else{ if(getBarState()==BARSTATE_NEWBAR){ TokyoVol+=volume(-1); } } return TokyoVol; }
Problem is that the indicator needs to run on 24 hour time template and I have a problem with getting the correct values for the previous days (number of bars back). Number of bars for each day is changing so the hard numbers are not really helping here:
Code:
avg = tvolf.getValue(0) avg1 = tvolf.getValue(-100) avg2 = tvolf.getValue(-200) avg3 = tvolf.getValue(-300) avg4 = tvolf.getValue(-400) avg5 = tvolf.getValue(-500) avg6 = tvolf.getValue(-600) avg7 = tvolf.getValue(-700) avg8 = tvolf.getValue(-800) avg9 = tvolf.getValue(-900) avg10 = tvolf.getValue(-1000) avg11 = tvolf.getValue(-1100) avg12 = tvolf.getValue(-1200) avg13 = tvolf.getValue(-1300) avg14 = tvolf.getValue(-1400) avg15 = tvolf.getValue(-1500) avg16 = tvolf.getValue(-1600) avg17 = tvolf.getValue(-1700) avg18 = tvolf.getValue(-1800) avg19 = tvolf.getValue(-1900)
Any help would be greatly appreciated.
Thank you.
Comment