Thanks Steve,
Will be trying this out later on today. Have chores to do first.
Paul Murray.
Will be trying this out later on today. Have chores to do first.
Paul Murray.
// Add this section as global, outside mmain
var todayBar;
var today;
var chartDay;
var clockDay;
var myDayTest;
function Check_Time(){
today = new Date();
todayBar = new Date(getValue("time",0)); // alternately getValue("time",0);
chartDay = today.getDate(); // alternately day(0)
clockDay = todayBar.getDate();
myDayTest = (chartDay == clockDay);
}
var bInit = false;
function preMain(){
setStudyTitle("MyDayTest");
setShowCursorLabel(false);
}
function main(){
if(!bInit){
Check_Time();
bInit = true;
}
//checks once every new bar
if (getBarState() == BARSTATE_NEWBAR ){
// checked once per hour
if(hour(0)!=hour(-1)){ // by sticking this in here, it decreases number of times the Date object it is called
Check_Time();
}
// then to check if the day is the current one
if(myDayTest){
debugPrintln("37: myDayTest = "+myDayTest+" clockDay = "+clockDay+" chartDay = "+chartDay);
}
else{
debugPrintln("39: myDayTest = "+myDayTest+" clockDay = "+clockDay+" chartDay = "+chartDay);
}
} //end barcheck
}
if (reload) { if(vLastCount == null) vLastCount = getNumBars(); if(vLastCount != getNumBars()) { vLastCount = getNumBars(); reloadEFS(); return; } }
function preMain()
{
setStudyTitle("Test");
setPriceStudy(true);
setDefaultBarFgColor(Color.RGB(0, 0, 114), 0);
setPlotType( PLOTTYPE_INSTANTCOLORLINE, 0 );
}
var Value1_1 = 0.0;
var close0, close1;
var vLastCount = null;
var reload = false;
var init = true;
function main(period, factor1, factor2, thickness, shift, vol)
{
if (period == null)
period = 3;
if (factor1 == null)
factor1 = 2;
if (factor2 == null)
factor2 = 2;
if (thickness == null)
thickness = 4;
if (shift == null)
shift = 0.998;
// reload
/*if (reload) {
if(vLastCount == null)
vLastCount = getNumBars();
if(vLastCount != getNumBars()) {
vLastCount = getNumBars();
reloadEFS();
return;
}
}*/
if (init) {
setDefaultBarThickness(thickness, 0);
var sym = new String(getSymbol());
/*if (sym.indexOf(" - ") || sym.indexOf(" + ") ||
sym.indexOf(" * ") || sym.indexOf(" / "))*/
//reload = true;
init = false;
}
close0 = close(), close1 = close(-1);
if (vol) {
var volume0 = volume();
// do something with volume
}
//var Price = "Close";
//if (sPrice != null) Price = sPrice;
var vPrice = close0;
//(open+high+low90+close())/4
var MARK = 0.8;
if (period != null) MARK = period;
var Value2 = factor1 / MARK-1;
var mark = 0.0;
if ((Value2) != 0) mark = factor2 / Value2;
var Value1 = -1 * (mark * vPrice + Value1_1);
var factor3 = Value1 / vPrice;
if (Value1 > Value1_1)//( nPlot>nPlot_1 )
setBarFgColor(Color.RGB(0, 192, 0), 0);
else if (Value1 < Value1_1)//( nPlot<nPlot_1 )
setBarFgColor(Color.RGB(255, 0, 0), 0);
else setBarFgColor(Color.RGB(76, 76, 76), 0);
if (getBarState() == BARSTATE_NEWBAR) Value1_1 = Value1;
return (Value1 / factor3) *shift;
}
Comment