I want to let you display a Leading Span earlier than candle.
This one is a right Ichimoku chart.
Please teach it. Thanking you in advance.
/************************************************** ***************
Provided By : eSignal. (c) Copyright 2004
************************************************** ***************/
var vTurn = new DonchianStudy(9, 0);
var vStandard = new DonchianStudy(26, 0);
var vLead1a = new DonchianStudy(26, 26);
var vLead1b = new DonchianStudy(9, 26);
var vLead2 = new DonchianStudy(52, 26);
var vCntr = 0;
var vICntr = 0;
function preMain() {
setPriceStudy(true);
setStudyTitle("Ichimoku");
setCursorLabelName("Turning Line", 0);
setCursorLabelName("Standard Line", 1);
setCursorLabelName("Delayed Line", 2);
setCursorLabelName("Leading Span 1", 3);
setCursorLabelName("Leading Span 2", 4);
setDefaultBarFgColor(Color.RGB(255, 102, 255), 0);
setDefaultBarFgColor(Color.RGB(255, 0, 0), 1);
setDefaultBarFgColor(Color.RGB(0, 0, 255), 2);
setDefaultBarFgColor(Color.RGB(204, 204, 204), 3);
setDefaultBarFgColor(Color.RGB(0, 153, 0), 4);
setShowTitleParameters(false);
setDefaultBarThickness(1,2)
var fp1 = new FunctionParameter("sCloud", FunctionParameter.STRING);
fp1.setName("Ichimoku Cloud Style");
fp1.addOption("Striped");
fp1.addOption("Solid");
fp1.setDefault("Striped");
var fp2 = new FunctionParameter("cCloud", FunctionParameter.COLOR);
fp2.setName("Ichimoku Cloud Color");
fp2.setDefault(Color.RGB(102, 255, 102));
}
function main(sCloud, cCloud) {
if(getBarState() == BARSTATE_NEWBAR){
vCntr +=1;
vICntr +=1;
if (vICntr > 350) vICntr = 0;
}
if(vCntr<53) return;
var nTurningLine = vTurn.getValue(DonchianStudy.BASIS);
var nStandardLine = vStandard.getValue(DonchianStudy.BASIS);
var nLeadingSpan1 = (vLead1a.getValue(DonchianStudy.BASIS) + vLead1b.getValue(DonchianStudy.BASIS)) / 2;
var nLeadingSpan2 = vLead2.getValue(DonchianStudy.BASIS);
if (nTurningLine == null || nStandardLine == null ||
nLeadingSpan1 == null || nLeadingSpan2 == null) return;
if (sCloud == "Striped") {
drawLineRelative(0, nLeadingSpan1, 0, nLeadingSpan2, PS_SOLID, 1, cCloud, "Cloud"+vICntr);
} else {
if(nLeadingSpan1>nLeadingSpan2)
setBarBgColor(Color.RGB(102,255,102), 0, nLeadingSpan2, nLeadingSpan1);
if(nLeadingSpan1<nLeadingSpan2)
setBarBgColor(Color.RGB(204,204,204), 0, nLeadingSpan1, nLeadingSpan2);
}
if(getBarState() == BARSTATE_NEWBAR){
var nNum = 1;
}else{
var nNum = 0;
}
return new Array(nTurningLine, nStandardLine, close(-26), nLeadingSpan1, nLeadingSpan2);
}
This one is a right Ichimoku chart.
Please teach it. Thanking you in advance.
/************************************************** ***************
Provided By : eSignal. (c) Copyright 2004
************************************************** ***************/
var vTurn = new DonchianStudy(9, 0);
var vStandard = new DonchianStudy(26, 0);
var vLead1a = new DonchianStudy(26, 26);
var vLead1b = new DonchianStudy(9, 26);
var vLead2 = new DonchianStudy(52, 26);
var vCntr = 0;
var vICntr = 0;
function preMain() {
setPriceStudy(true);
setStudyTitle("Ichimoku");
setCursorLabelName("Turning Line", 0);
setCursorLabelName("Standard Line", 1);
setCursorLabelName("Delayed Line", 2);
setCursorLabelName("Leading Span 1", 3);
setCursorLabelName("Leading Span 2", 4);
setDefaultBarFgColor(Color.RGB(255, 102, 255), 0);
setDefaultBarFgColor(Color.RGB(255, 0, 0), 1);
setDefaultBarFgColor(Color.RGB(0, 0, 255), 2);
setDefaultBarFgColor(Color.RGB(204, 204, 204), 3);
setDefaultBarFgColor(Color.RGB(0, 153, 0), 4);
setShowTitleParameters(false);
setDefaultBarThickness(1,2)
var fp1 = new FunctionParameter("sCloud", FunctionParameter.STRING);
fp1.setName("Ichimoku Cloud Style");
fp1.addOption("Striped");
fp1.addOption("Solid");
fp1.setDefault("Striped");
var fp2 = new FunctionParameter("cCloud", FunctionParameter.COLOR);
fp2.setName("Ichimoku Cloud Color");
fp2.setDefault(Color.RGB(102, 255, 102));
}
function main(sCloud, cCloud) {
if(getBarState() == BARSTATE_NEWBAR){
vCntr +=1;
vICntr +=1;
if (vICntr > 350) vICntr = 0;
}
if(vCntr<53) return;
var nTurningLine = vTurn.getValue(DonchianStudy.BASIS);
var nStandardLine = vStandard.getValue(DonchianStudy.BASIS);
var nLeadingSpan1 = (vLead1a.getValue(DonchianStudy.BASIS) + vLead1b.getValue(DonchianStudy.BASIS)) / 2;
var nLeadingSpan2 = vLead2.getValue(DonchianStudy.BASIS);
if (nTurningLine == null || nStandardLine == null ||
nLeadingSpan1 == null || nLeadingSpan2 == null) return;
if (sCloud == "Striped") {
drawLineRelative(0, nLeadingSpan1, 0, nLeadingSpan2, PS_SOLID, 1, cCloud, "Cloud"+vICntr);
} else {
if(nLeadingSpan1>nLeadingSpan2)
setBarBgColor(Color.RGB(102,255,102), 0, nLeadingSpan2, nLeadingSpan1);
if(nLeadingSpan1<nLeadingSpan2)
setBarBgColor(Color.RGB(204,204,204), 0, nLeadingSpan1, nLeadingSpan2);
}
if(getBarState() == BARSTATE_NEWBAR){
var nNum = 1;
}else{
var nNum = 0;
}
return new Array(nTurningLine, nStandardLine, close(-26), nLeadingSpan1, nLeadingSpan2);
}
Comment