I am running the following code in a 150 tick chart for the Russell 2000. The Donchian values for the individual elements displays correctly in the Formula Output Window, but the array returns [object Series].
Is there a way to get the array to display it's values correctly?
Thanks
function preMain()
{
setPriceStudy(true);
setStudyTitle("Donchiantest");
setCursorLabelName("D");
}
var UpperDonchian = 0;
var PrevUpperDonchian = 0;
var MiddleDonchian = 0;
var PrevMiddleDonchian = 0;
var LowerDonchian = 0;
var PrevLowerDonchian = 0;
var UpperDonchianArray = new Array(3);
UpperDonchianArray[0] = 0;
UpperDonchianArray[1] = 0;
UpperDonchianArray[2] = 0;
var LowerDonchianArray = new Array(3);
LowerDonchianArray[0] = 0;
LowerDonchianArray[1] = 0;
LowerDonchianArray[2] = 0;
function main()
{
// Get Donchian Values
if (getBarState() == BARSTATE_NEWBAR)
{
PrevUpperDonchian = UpperDonchian;
}
UpperDonchian = upperDonchian(14);
if (UpperDonchian == null) return;
if (getBarState() == BARSTATE_NEWBAR)
{
PrevMiddleDonchian = MiddleDonchian;
}
MiddleDonchian = middleDonchian(14);
if (MiddleDonchian == null) return;
if (getBarState() == BARSTATE_NEWBAR)
{
PrevLowerDonchian = LowerDonchian;
}
LowerDonchian = lowerDonchian(14);
if (LowerDonchian == null) return;
// Update Donchian Arrays with new values
if (getBarState() == BARSTATE_NEWBAR)
{
LowerDonchianArray[0] = LowerDonchianArray[1];
LowerDonchianArray[1] = LowerDonchianArray[2];
LowerDonchianArray[2] = PrevLowerDonchian;
}
if (getBarState() == BARSTATE_NEWBAR)
{
UpperDonchianArray[0] = UpperDonchianArray[1];
UpperDonchianArray[1] = UpperDonchianArray[2];
UpperDonchianArray[2] = PrevUpperDonchian;
}
debugClear();
debugPrintln(" UpperDonchianArray: " + UpperDonchianArray);
debugPrintln(" UpperDonchianArray[0]: " + UpperDonchianArray[0]);
debugPrintln(" UpperDonchianArray[1]: " + UpperDonchianArray[1]);
debugPrintln(" UpperDonchianArray[2]: " + UpperDonchianArray[2]);
debugPrintln(" ");
debugPrintln(" LowerDonchianArray: " + LowerDonchianArray);
debugPrintln(" LowerDonchianArray[0]: " + LowerDonchianArray[0]);
debugPrintln(" LowerDonchianArray[1]: " + LowerDonchianArray[1]);
debugPrintln(" LowerDonchianArray[2]: " + LowerDonchianArray[2]);
}
Is there a way to get the array to display it's values correctly?
Thanks
function preMain()
{
setPriceStudy(true);
setStudyTitle("Donchiantest");
setCursorLabelName("D");
}
var UpperDonchian = 0;
var PrevUpperDonchian = 0;
var MiddleDonchian = 0;
var PrevMiddleDonchian = 0;
var LowerDonchian = 0;
var PrevLowerDonchian = 0;
var UpperDonchianArray = new Array(3);
UpperDonchianArray[0] = 0;
UpperDonchianArray[1] = 0;
UpperDonchianArray[2] = 0;
var LowerDonchianArray = new Array(3);
LowerDonchianArray[0] = 0;
LowerDonchianArray[1] = 0;
LowerDonchianArray[2] = 0;
function main()
{
// Get Donchian Values
if (getBarState() == BARSTATE_NEWBAR)
{
PrevUpperDonchian = UpperDonchian;
}
UpperDonchian = upperDonchian(14);
if (UpperDonchian == null) return;
if (getBarState() == BARSTATE_NEWBAR)
{
PrevMiddleDonchian = MiddleDonchian;
}
MiddleDonchian = middleDonchian(14);
if (MiddleDonchian == null) return;
if (getBarState() == BARSTATE_NEWBAR)
{
PrevLowerDonchian = LowerDonchian;
}
LowerDonchian = lowerDonchian(14);
if (LowerDonchian == null) return;
// Update Donchian Arrays with new values
if (getBarState() == BARSTATE_NEWBAR)
{
LowerDonchianArray[0] = LowerDonchianArray[1];
LowerDonchianArray[1] = LowerDonchianArray[2];
LowerDonchianArray[2] = PrevLowerDonchian;
}
if (getBarState() == BARSTATE_NEWBAR)
{
UpperDonchianArray[0] = UpperDonchianArray[1];
UpperDonchianArray[1] = UpperDonchianArray[2];
UpperDonchianArray[2] = PrevUpperDonchian;
}
debugClear();
debugPrintln(" UpperDonchianArray: " + UpperDonchianArray);
debugPrintln(" UpperDonchianArray[0]: " + UpperDonchianArray[0]);
debugPrintln(" UpperDonchianArray[1]: " + UpperDonchianArray[1]);
debugPrintln(" UpperDonchianArray[2]: " + UpperDonchianArray[2]);
debugPrintln(" ");
debugPrintln(" LowerDonchianArray: " + LowerDonchianArray);
debugPrintln(" LowerDonchianArray[0]: " + LowerDonchianArray[0]);
debugPrintln(" LowerDonchianArray[1]: " + LowerDonchianArray[1]);
debugPrintln(" LowerDonchianArray[2]: " + LowerDonchianArray[2]);
}
Comment