compile error

Questions about MultiCharts and user contributed studies.
drudominique
Posts: 70
Joined: 17 Mar 2010

compile error

Postby drudominique » 13 May 2010

Good morning.
I have a compile error but I do not find it, could you help me :-)
cordially



Code: Select all

inputs: BarWidth(3);
variables: UpTrend(false), LowPainted(false), HighPainted(false),
ExtremeBar(0), TriggerBarLow(0), ExtremeBarHigh(0), TriggerBarHigh(0), ExtremeBarLow(0), counter(-1);
// Compare the 9-period MA to the previous bar's value as the basis for determining
   //   if we are in an uptrend or a downtrend at this moment.
   // // We will NOT check for the presence of a trend if we are
   // "waiting for a confirmation of a trigger (i.e. Extreme Bar <> 0)" ??
   //Downtrend -- Look to paint a low bar
   if (AverageFC(Close[3],9) < AverageFC(Close[4],9) and ExtremeBar=0) or
   ((AverageFC(Close[3],9) = AverageFC(Close[4],9) and ExtremeBar=0) and (UpTrend=False)) then begin UpTrend=False;
   HighPainted=false;
    if low[3] > low then LowPainted=false;
end;
 //Uptrend -- Look to paint a high bar
   if AverageFC(Close[3],9) > AverageFC(Close[4],9) and ExtremeBar=0 or
   ((AverageFC(Close[3],9) = AverageFC(Close[4],9) and ExtremeBar=0) and (UpTrend=True)) then begin UpTrend=True;
LowPainted=false;
if high[3] < high then HighPainted=false;
end;
   //Check for triggers and paint the extreme bar on confirmation //Uptrend
   if UpTrend = True and HighPainted=false then begin if high[2] < high[3] and ExtremeBar=0 then begin ExtremeBar = 3;
   ExtremeBarHigh = high[3];
   TriggerBarLow = low[2];
 end;
 if high[1] > ExtremeBarHigh then begin ExtremeBar = 0;
 ExtremeBarHigh = 0;
 TriggerBarLow = 0;
 counter=-1;
 end;
 if ExtremeBar <> 0 then counter=counter+1;
   // Paint an "Extreme Bar" if it exists based on the two if blocks above
      // OR if the earlier close was above the 8-EMA and the later close was
      // below the 8-EMA)
if (close[1] < TriggerBarLow and ExtremeBar <> 0) or ((Close[3] > XAverage(Close[3],8)) and (Close[1] < XAverage(Close[1],8)))
      then begin ExtremeBar = ExtremeBar + counter;
 PlotPaintBar[ExtremeBar](High[ExtremeBar],Low[ExtremeBar],"ScalperSig",white);
 SetPlotWidth[ExtremeBar](1,BarWidth);
 SetPlotColor[ExtremeBar](1,white);
alert("Scalper Sell Detected!");
HighPainted = true; counter=-1; ExtremeBar=0;
end;
end;
//Downtrend
   if UpTrend = False and LowPainted=false then begin    if low[2] > low[3] and ExtremeBar=0 then begin ExtremeBar = 3;
ExtremeBarLow = low[3];
TriggerBarHigh = high[2];
if ExtremeBarLow > low[4] then ExtremeBar = 4;
end;
if low[1] < ExtremeBarLow then begin ExtremeBar = 0;
ExtremeBarLow = 0;
TriggerBarHigh = 0;
counter=-1; end;
if ExtremeBar <> 0 then counter=counter+1;
if close[1] > TriggerBarHigh and ExtremeBar <> 0 then begin ExtremeBar = ExtremeBar + counter;
PlotPaintBar[ExtremeBar](Low[ExtremeBar],High[ExtremeBar],"ScalperSig",white);
SetPlotWidth[ExtremeBar](1,BarWidth);
SetPlotColor[ExtremeBar](1,white);
alert("Scalper Buy Detected!");
LowPainted = true;
counter=-1;
ExtremeBar=0;
end;
end;

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Re: compile error

Postby TJ » 13 May 2010

Good morning.
I have a compile error but I do not find it, could you help me :-)
cordially
...


pls copy and paste the error message here.
or take a screen shot of the error.

pls also let us know your MC version, OS, etc.

drudominique
Posts: 70
Joined: 17 Mar 2010

Postby drudominique » 14 May 2010

Excuse me this is not an error message but when I put in my chart jai this error message:

Message : Error in study "tt11" : : Trying access at data to future.Bar reference value: -1

User avatar
Anastassia
Posts: 179
Joined: 18 Jan 2010
Been thanked: 4 times

Postby Anastassia » 14 May 2010

Hello Drudominique,

There is a reference to High[ExtremeBar], Low[ExtremeBar] with ExtremeBar < 0 when applying your code. It is not possible to have negative values in the brackets. You need to add the check that extremebar>=0 before the reference to High[ExtremeBar], Low[ExtremeBar].


Thank you

drudominique
Posts: 70
Joined: 17 Mar 2010

Postby drudominique » 14 May 2010

hello

I found or I put in the code <0? I <> 0 = 0 but I found no <0 can you tell me where exactly I am wrong (I do not speak English so it's hard to understand :-))
cordially

french

bonjour

je trouve pas ou je met dans le code <0 ? j'ai <>0 et =0 mais je trouve pas de <0 pouvez vous me dire ou exactement je fais une erreur ( je parle pas anglais donc j'ai du mal a comprendre :-) )
cordialement

User avatar
Anastassia
Posts: 179
Joined: 18 Jan 2010
Been thanked: 4 times

Postby Anastassia » 17 May 2010

Hi Drudominique,

Please find the code below.

Code: Select all

inputs: BarWidth(3);
variables: UpTrend(false), LowPainted(false), HighPainted(false),
ExtremeBar(0), TriggerBarLow(0), ExtremeBarHigh(0), TriggerBarHigh(0), ExtremeBarLow(0), counter(-1);
// Compare the 9-period MA to the previous bar's value as the basis for determining
   //   if we are in an uptrend or a downtrend at this moment.
   // // We will NOT check for the presence of a trend if we are
   // "waiting for a confirmation of a trigger (i.e. Extreme Bar <> 0)" ??
   //Downtrend -- Look to paint a low bar
   if (AverageFC(Close[3],9) < AverageFC(Close[4],9) and ExtremeBar=0) or
   ((AverageFC(Close[3],9) = AverageFC(Close[4],9) and ExtremeBar=0) and (UpTrend=False)) then begin UpTrend=False;
   HighPainted=false;
    if low[3] > low then LowPainted=false;
end;
 //Uptrend -- Look to paint a high bar
   if AverageFC(Close[3],9) > AverageFC(Close[4],9) and ExtremeBar=0 or
   ((AverageFC(Close[3],9) = AverageFC(Close[4],9) and ExtremeBar=0) and (UpTrend=True)) then begin UpTrend=True;
LowPainted=false;
if high[3] < high then HighPainted=false;
end;
   //Check for triggers and paint the extreme bar on confirmation //Uptrend
   if UpTrend = True and HighPainted=false then begin if high[2] < high[3] and ExtremeBar=0 then begin ExtremeBar = 3;
   ExtremeBarHigh = high[3];
   TriggerBarLow = low[2];
 end;
 if high[1] > ExtremeBarHigh then begin ExtremeBar = 0;
 ExtremeBarHigh = 0;
 TriggerBarLow = 0;
 counter=-1;
 end;
 if ExtremeBar <> 0 then counter=counter+1;
   // Paint an "Extreme Bar" if it exists based on the two if blocks above
      // OR if the earlier close was above the 8-EMA and the later close was
      // below the 8-EMA)
if (close[1] < TriggerBarLow and ExtremeBar <> 0) or ((Close[3] > XAverage(Close[3],8)) and (Close[1] < XAverage(Close[1],8)))
      then begin ExtremeBar = ExtremeBar + counter;
      if (ExtremeBar >= 0) then begin
 PlotPaintBar[ExtremeBar](High[ExtremeBar],Low[ExtremeBar],"ScalperSig",white);
 SetPlotWidth[ExtremeBar](1,BarWidth);
 SetPlotColor[ExtremeBar](1,white);
end;
alert("Scalper Sell Detected!");
HighPainted = true; counter=-1; ExtremeBar=0;
end;
end;
//Downtrend
   if UpTrend = False and LowPainted=false then begin    if low[2] > low[3] and ExtremeBar=0 then begin ExtremeBar = 3;
ExtremeBarLow = low[3];
TriggerBarHigh = high[2];
if ExtremeBarLow > low[4] then ExtremeBar = 4;
end;
if low[1] < ExtremeBarLow then begin ExtremeBar = 0;
ExtremeBarLow = 0;
TriggerBarHigh = 0;
counter=-1; end;
if ExtremeBar <> 0 then counter=counter+1;
if close[1] > TriggerBarHigh and ExtremeBar <> 0 then begin ExtremeBar = ExtremeBar + counter;
      if (ExtremeBar >= 0) then begin
PlotPaintBar[ExtremeBar](Low[ExtremeBar],High[ExtremeBar],"ScalperSig",white);
SetPlotWidth[ExtremeBar](1,BarWidth);
SetPlotColor[ExtremeBar](1,white);
end;
alert("Scalper Buy Detected!");
LowPainted = true;
counter=-1;
ExtremeBar=0;
end;
end;


Thank you

drudominique
Posts: 70
Joined: 17 Mar 2010

Postby drudominique » 17 May 2010

Good morning.
thank you very much Anastasia
cordially


Return to “MultiCharts”