[attached code compiles ok but when try to plot on a chart itgives error message "trying to excess future data , bar reference -1" can some one help
code for function DSMI
{Type : Function, Name :DSMI}
input:
length1(NumericSimple),
DMILength( NumericSimple ),
length2(NumericSimple),
length3(NumericSimple);
var:
MyHH(0),DMIOsc( 0 ),MyH(o),MyL(o),MyC(o),
MyLL(0);
MyH=high[DMIOsc][-1];
MyL=low[DMIOsc][-1];
MyC=close[DMIOsc][-1];
MyHH = Highest(MyH,length1);
MyLL = Lowest (MyL,length1);
DMIOsc = _DMI_Oscillator( DMILength ) ;
DSMI = 100 * (XAverage(XAverage(MyC-(0.5*(MyHH+MyLL)),length2),length3) /
(0.5 * XAverage(XAverage(MyHH-MyLL,length2),length3)));
code for Indicator _DSMI
Input:Length1(13),Length2(25),Length3(2),AlertLevel(40),DMILength(10),
UpColor(green), DwnColor(magenta);
var:
double DMIOsc( 0 ) ;
DMIOsc = _DMI_Oscillator( DMILength ) ;
Value1 = DSMI(length1,length2,length3,DMILength);
plot1( value1, "DSMI" );
plot2( AlertLevel, "Sell line" );
plot3(-AlertLevel, "Buy line" );
plot4(0, "Zero");
if plot1 crosses above -AlertLevel then
alert("SMI crosses above buy line");
if plot1 crosses below AlertLevel then
alert("DSMI crosses below sell line");
If value1>value1[1] then begin
plot1[1](value1[1],"DSMI",upcolor);
plot1(value1,"DSMI",upcolor);
end else begin
plot1[1](value1[1],"DSMI",dwncolor);
plot1(value1,"DSMI",dwncolor);
end;
help for debug codes
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: help for debug codes
I did go thru instructions for posting codes but couldn't make it work
Sorry TJ
Sorry TJ
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: help for debug codes
There are only 2 steps. Which step did not work?I did go thru instructions for posting codes but couldn't make it work
Sorry TJ
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: help for debug codes
Try a search; paste the error message in the search box and press enter.[attached code compiles ok but when try to plot on a chart itgives error message "trying to excess future data , bar reference -1" can some one help
The search box is located at the top right corner of this page.
Re: help for debug codes
TJ -Error message appears on chart window onlower right corner with big red x this cannot be copied
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
Re: help for debug codes
Hello Valabhi,
You should modify your strategy. It is trying to access values from next (future) bar. You should get rid out of [-1] or change it to a positive number (reference to past data, not future).
The problem comes from this line:
Somewhere inside the DSMI function the script tries to reference data from future bars. Please debug this function and it will work.
You should modify your strategy. It is trying to access values from next (future) bar. You should get rid out of [-1] or change it to a positive number (reference to past data, not future).
The problem comes from this line:
Code: Select all
Value1 = DSMI(length1,length2,length3,DMILength);
Re: help for debug codes
These are worth a reading.
EL debugging (trouble shooting) guide
viewtopic.php?f=16&t=10397
MC/EL frequently triggered traps (how to avoid)
viewtopic.php?f=16&t=7665
EL debugging (trouble shooting) guide
viewtopic.php?f=16&t=10397
MC/EL frequently triggered traps (how to avoid)
viewtopic.php?f=16&t=7665
Re: help for debug codes
is equal toend;Code: Select all
...
MyH=high[DMIOsc][-1];
MyL=low[DMIOsc][-1];
MyC=close[DMIOsc][-1];
...
Code: Select all
...
MyH=high[DMIOsc-1];
MyL=low[DMIOsc-1];
MyC=close[DMIOsc-1];
...