Hi
Could someone tell me what mistake I am making in the code below
Regardless of whether I call (directly or indirectly) the
high
low
close
I get the same result for a moving average – the sma moving average based on the close price
In the function one of the sma’s / Breakout3 is prefixed as a var to see if that made any difference – it didn’t
var FlagA = 0;
var FlagA1 = 0;
var FlagB = 0;
var FlagB1 = 0;
var Breakout = 0;
var Breakout1 = 0;
var Breakout2 = 0;
var Breakout3 = 0;
var Breakout4 = 0;
var Breakout5 = 0;
function main() {
FlagA1 =low;
FlagB1 =high;
Breakout = sma(10,FlagA1.getValue);
Breakout1 = sma(10,FlagB1.getValue);
Breakout2 = sma(10,high.getValue);
var Breakout3 = sma(10,high.getValue);
Breakout4 = sma(10,low.getValue);
Breakout5 = sma(10,close.getValue);
return new Array (Breakout,Breakout1,Breakout2,Breakout3, Breakout4, Breakout5);
}
The answer to what I am doing wrong is probably pretty obvious but I cant seem to work it out.
The output data which shows each column as identical is below this and after that is the pre main function – all plots OK (ie but with identical numbers) on the charts
Thanks
Robert
Output to csv file
Bar Date Time Open High Low Close Upper Env Lower Env Upper Env1Lower Env1Upper Env2Lower
1 03/16/09 00:00 12608 12622 12409 12431 <None> <None> <None> <None> <None> <None>
2 03/17/09 00:00 12432 12532 12328 12408 <None> <None> <None> <None> <None> <None>
3 03/18/09 00:00 12325 13218 12323 12909 <None> <None> <None> <None> <None> <None>
4 03/19/09 00:00 12916 13108 12827 12915 <None> <None> <None> <None> <None> <None>
5 03/20/09 00:00 12919 13012 12826 12908 <None> <None> <None> <None> <None> <None>
6 03/23/09 00:00 12903 12924 12808 12820 <None> <None> <None> <None> <None> <None>
7 03/24/09 00:00 12811 12912 12625 12904 <None> <None> <None> <None> <None> <None>
8 03/25/09 00:00 12812 12820 12632 12725 <None> <None> <None> <None> <None> <None>
9 03/26/09 00:00 12714 12826 12629 12819 <None> <None> <None> <None> <None> <None>
10 03/27/09 00:00 12815 12913 12731 12818 12731 12731 12731 12731 12731 12731
11 03/30/09 00:00 12818 12931 12808 12831 12812 12812 12812 12812 12812 12812
12 03/31/09 00:00 12829 12930 12820 12923 12830 12830 12830 12830 12830 12830
590 07-12-11 00:00 12604 12715 12600 12615 12404 12404 12404 12404 12404 12404
591 07/13/11 00:00 12628 12702 12526 12623 12412 12412 12412 12412 12412 12412
592 07/14/11 00:00 12620 12627 12520 12526 12419 12419 12419 12419 12419 12419
593 07/15/11 00:00 12522 12605 12503 12601 12429 12429 12429 12429 12429 12429
594 07/18/11 00:00 12531 12616 12508 12522 12506 12506 12506 12506 12506 12506
595 07/19/11 00:00 12515 12702 12500 12620 12517 12517 12517 12517 12517 12517
596 07/20/11 00:00 12628 12628 12526 12528 12525 12525 12525 12525 12525 12525
597 07/21/11 00:00 12600 12601 12423 12503 12530 12530 12530 12530 12530 12530
598 07/22/11 00:00 12503 12531 12502 12527 12601 12601 12601 12601 12601 12601
599 07/25/11 00:00 12506 12603 12424 12502 12530 12530 12530 12530 12530 12530
600 07/26/11 00:00 12506 12530 12422 12526 <None>
preMain
function preMain() {
setPriceStudy(true);
setComputeOnClose()
setStudyTitle("FunctionParameter: TEST-ERROR");
setPlotType(PS_DASH,0);
setPlotType(PS_DASH,1);
setPlotType(PS_DASH,2);
setPlotType(PS_DASH,3);
setCursorLabelName("Upper Env", 0);
setCursorLabelName("Lower Env", 1);
setCursorLabelName("Upper Env1", 2);
setCursorLabelName("Lower Env1", 3);
setCursorLabelName("Upper Env2", 4);
setCursorLabelName("Lower Env2", 5);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.grey, 2);
setDefaultBarFgColor(Color.green, 3);
setDefaultBarFgColor(Color.magenta, 4);
setDefaultBarFgColor(Color.purple, 5);
setDefaultBarThickness(3, 0);
setDefaultBarThickness(3, 1);
setDefaultBarThickness(3, 2);
setDefaultBarThickness(3, 3);
setDefaultBarThickness(3, 4);
setDefaultBarThickness(3, 5);
}
Could someone tell me what mistake I am making in the code below
Regardless of whether I call (directly or indirectly) the
high
low
close
I get the same result for a moving average – the sma moving average based on the close price
In the function one of the sma’s / Breakout3 is prefixed as a var to see if that made any difference – it didn’t
var FlagA = 0;
var FlagA1 = 0;
var FlagB = 0;
var FlagB1 = 0;
var Breakout = 0;
var Breakout1 = 0;
var Breakout2 = 0;
var Breakout3 = 0;
var Breakout4 = 0;
var Breakout5 = 0;
function main() {
FlagA1 =low;
FlagB1 =high;
Breakout = sma(10,FlagA1.getValue);
Breakout1 = sma(10,FlagB1.getValue);
Breakout2 = sma(10,high.getValue);
var Breakout3 = sma(10,high.getValue);
Breakout4 = sma(10,low.getValue);
Breakout5 = sma(10,close.getValue);
return new Array (Breakout,Breakout1,Breakout2,Breakout3, Breakout4, Breakout5);
}
The answer to what I am doing wrong is probably pretty obvious but I cant seem to work it out.
The output data which shows each column as identical is below this and after that is the pre main function – all plots OK (ie but with identical numbers) on the charts
Thanks
Robert
Output to csv file
Bar Date Time Open High Low Close Upper Env Lower Env Upper Env1Lower Env1Upper Env2Lower
1 03/16/09 00:00 12608 12622 12409 12431 <None> <None> <None> <None> <None> <None>
2 03/17/09 00:00 12432 12532 12328 12408 <None> <None> <None> <None> <None> <None>
3 03/18/09 00:00 12325 13218 12323 12909 <None> <None> <None> <None> <None> <None>
4 03/19/09 00:00 12916 13108 12827 12915 <None> <None> <None> <None> <None> <None>
5 03/20/09 00:00 12919 13012 12826 12908 <None> <None> <None> <None> <None> <None>
6 03/23/09 00:00 12903 12924 12808 12820 <None> <None> <None> <None> <None> <None>
7 03/24/09 00:00 12811 12912 12625 12904 <None> <None> <None> <None> <None> <None>
8 03/25/09 00:00 12812 12820 12632 12725 <None> <None> <None> <None> <None> <None>
9 03/26/09 00:00 12714 12826 12629 12819 <None> <None> <None> <None> <None> <None>
10 03/27/09 00:00 12815 12913 12731 12818 12731 12731 12731 12731 12731 12731
11 03/30/09 00:00 12818 12931 12808 12831 12812 12812 12812 12812 12812 12812
12 03/31/09 00:00 12829 12930 12820 12923 12830 12830 12830 12830 12830 12830
590 07-12-11 00:00 12604 12715 12600 12615 12404 12404 12404 12404 12404 12404
591 07/13/11 00:00 12628 12702 12526 12623 12412 12412 12412 12412 12412 12412
592 07/14/11 00:00 12620 12627 12520 12526 12419 12419 12419 12419 12419 12419
593 07/15/11 00:00 12522 12605 12503 12601 12429 12429 12429 12429 12429 12429
594 07/18/11 00:00 12531 12616 12508 12522 12506 12506 12506 12506 12506 12506
595 07/19/11 00:00 12515 12702 12500 12620 12517 12517 12517 12517 12517 12517
596 07/20/11 00:00 12628 12628 12526 12528 12525 12525 12525 12525 12525 12525
597 07/21/11 00:00 12600 12601 12423 12503 12530 12530 12530 12530 12530 12530
598 07/22/11 00:00 12503 12531 12502 12527 12601 12601 12601 12601 12601 12601
599 07/25/11 00:00 12506 12603 12424 12502 12530 12530 12530 12530 12530 12530
600 07/26/11 00:00 12506 12530 12422 12526 <None>
preMain
function preMain() {
setPriceStudy(true);
setComputeOnClose()
setStudyTitle("FunctionParameter: TEST-ERROR");
setPlotType(PS_DASH,0);
setPlotType(PS_DASH,1);
setPlotType(PS_DASH,2);
setPlotType(PS_DASH,3);
setCursorLabelName("Upper Env", 0);
setCursorLabelName("Lower Env", 1);
setCursorLabelName("Upper Env1", 2);
setCursorLabelName("Lower Env1", 3);
setCursorLabelName("Upper Env2", 4);
setCursorLabelName("Lower Env2", 5);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.grey, 2);
setDefaultBarFgColor(Color.green, 3);
setDefaultBarFgColor(Color.magenta, 4);
setDefaultBarFgColor(Color.purple, 5);
setDefaultBarThickness(3, 0);
setDefaultBarThickness(3, 1);
setDefaultBarThickness(3, 2);
setDefaultBarThickness(3, 3);
setDefaultBarThickness(3, 4);
setDefaultBarThickness(3, 5);
}
Comment