Hi,
I am new here and hope that someone could help
I have a problem with the function of " While ....Loop".
I ran my indicator with "While...Loop" with different date range set.
Date Range 1 = From 2005 May 15 to 2013 June 02
First Result data Point = 2008 Mar 11
Date Range 2 = From 2000 May 15 to 2013 June 02
First Result data Point = 2006 Sept 29
I believe that there is some error in my coding because some data has been skipped in the analysis. How Shall I check it ??
Kam
Problem While....Loop
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Problem While....Loop
HI .....
Hope Someone could help me out .... thks
Vars: Counter(1), NEW(0), MyAVG(0);
MyAvg = Average(Close,3);
Counter = 1 ;
IF High > High[1] then
WHILE low < MyAvg[Counter]
BEGIN
NEW = lOW[Counter];
Counter = Counter +1 ;
PLot5(NEW, "XXX",RED);
END;
Hope Someone could help me out .... thks
Vars: Counter(1), NEW(0), MyAVG(0);
MyAvg = Average(Close,3);
Counter = 1 ;
IF High > High[1] then
WHILE low < MyAvg[Counter]
BEGIN
NEW = lOW[Counter];
Counter = Counter +1 ;
PLot5(NEW, "XXX",RED);
END;
Re: Problem While....Loop
Code: Select all
Vars: Counter(1), NEW(0), MyAVG(0);
MyAvg = Average(Close,3);
Counter = 1 ;
IF High > High[1] then
WHILE low < MyAvg[Counter]
BEGIN
NEW = lOW[Counter];
Counter = Counter +1 ;
plot6(MyAvg ,"3");
PLot5(nEW, "XXX",RED);
END;
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Problem While....Loop
Can't help you just by looking at the codes.HI .....
Hope Someone could help me out .... thks
Vars: Counter(1), NEW(0), MyAVG(0);
MyAvg = Average(Close,3);
Counter = 1 ;
IF High > High[1] then
WHILE low < MyAvg[Counter]
BEGIN
NEW = lOW[Counter];
Counter = Counter +1 ;
PLot5(NEW, "XXX",RED);
END;
Please explain what are you trying to achieve?
Maybe include a mock up chart (with arrows and notes) to demonstrate your vision?
Re: Problem While....Loop
HI TJ.
The code is compiled. However, there is one thing that I don't quite understand. My data started from 2003 Dec 15 to 2013 June 02, the first plot was shown 2006 Aug 22. When I used the "Print" function; the first plot was show on 2003 Dec 29. This was totally confusing me. Those plot should point at the same date. I am new in the multichart. What I have been doing was playing around with each function.
What I am trying to achieve is to count how many backward point of moving average is greater than the current low when today high is greater than yesterday's high. The result is LOW[counter].
Kam
The code is compiled. However, there is one thing that I don't quite understand. My data started from 2003 Dec 15 to 2013 June 02, the first plot was shown 2006 Aug 22. When I used the "Print" function; the first plot was show on 2003 Dec 29. This was totally confusing me. Those plot should point at the same date. I am new in the multichart. What I have been doing was playing around with each function.
What I am trying to achieve is to count how many backward point of moving average is greater than the current low when today high is greater than yesterday's high. The result is LOW[counter].
Kam
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Problem While....Loop
You have not posted the code with the "print", so I can't comment on your bug.HI TJ.
The code is compiled. However, there is one thing that I don't quite understand. My data started from 2003 Dec 15 to 2013 June 02, the first plot was shown 2006 Aug 22. When I used the "Print" function; the first plot was show on 2003 Dec 29. This was totally confusing me. Those plot should point at the same date. I am new in the multichart. What I have been doing was playing around with each function.
What I am trying to achieve is to count how many backward point of moving average is greater than the current low when today high is greater than yesterday's high. The result is LOW[counter].
Kam
My suggestions:
You should add more plot statements to your code, so that you can track the changes of your variables in the indicator.
Try not to use the WHILE loop. It is a more advanced form of loop; you can debug easier if you use IF-THEN-ELSE;
Good luck.
eg. of plots to track variables.
Code: Select all
Vars: Counter(1), NEW(0), MyAVG(0);
MyAvg = Average(Close,3);
plot10(myavg, "MyAvg");
Counter = 1 ;
IF High > High[1] then
begin
plot20(h, "h>h1");
WHILE low < MyAvg[Counter]
BEGIN
plot7(counter, "counter");
NEW = lOW[Counter];
Counter = Counter +1 ;
plot6(MyAvg ,"3");
PLot5(nEW, "XXX",RED);
end;
END;
Re: Problem While....Loop
HI TJ,
Many Thks.
I used your code but the result was the same. The first plot was shown on Aug 2006 but the data was start as of Dec 2003.
Please find below is my print function.
Print(" Symbol ", Symbol, " Date ", Date:7:0, "MyAvg" , MyAvg, "HIGH", HIGH ,"nEW ",nEW );
kam
Many Thks.
I used your code but the result was the same. The first plot was shown on Aug 2006 but the data was start as of Dec 2003.
Please find below is my print function.
Print(" Symbol ", Symbol, " Date ", Date:7:0, "MyAvg" , MyAvg, "HIGH", HIGH ,"nEW ",nEW );
kam
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Problem While....Loop
Of course the result is the same, that was only an example to show you how to add plots to trace your variables. Your logic is at fault, that is why you are not getting the result you want. You will need to draw a chart with arrows and notes to illustrate what you want before you can develop a logic to plot the right dot on the right chart.HI TJ,
Many Thks.
I used your code but the result was the same. The first plot was shown on Aug 2006 but the data was start as of Dec 2003.
Please find below is my print function.
Print(" Symbol ", Symbol, " Date ", Date:7:0, "MyAvg" , MyAvg, "HIGH", HIGH ,"nEW ",nEW );
kam
ps. your PRINT snippet in isolation is of no use for debugging.
Re: Problem While....Loop
HI TJ..
THks
I am sure my coding is correct because all dots was at the correct place I expected.
The only thing I have been confused that is the first dot placement.
It should be occurred at somewhere earlier than Aug 2006 because My data was started as of Dec 2003.
Anyway , thks a lot
Kam
THks
I am sure my coding is correct because all dots was at the correct place I expected.
The only thing I have been confused that is the first dot placement.
It should be occurred at somewhere earlier than Aug 2006 because My data was started as of Dec 2003.
Anyway , thks a lot
Kam
Re: Problem While....Loop
Kam, is your problem resolved? I had a similar problem when I started with MC.HI TJ..
THks
I am sure my coding is correct because all dots was at the correct place I expected.
The only thing I have been confused that is the first dot placement.
It should be occurred at somewhere earlier than Aug 2006 because My data was started as of Dec 2003.
Anyway , thks a lot
Kam
If not, you may check your indicator properties, ....Max numbers bars of reference
If autodetect, then your code will start running at the first bar that is valid for your code witch should be related to your average value. Meaning, if your average is on 10 bars, your code will be started after the 10' bars because it need to do is computation on at least 10 bars
If the selection is on user specified and the value = 50 then your code will start after the 50' bars on the chart
Martin
Re: Problem While....Loop
HI Martin,
Thank for your email.
I did change it to manual input from auto-detection.
My problem has not resolved.
I guess the fundamental question is associated to the logic of multicharts. It seems to me that multicharts ( version 8.5) cannot deal with something is changing. As advised by the support, I upgrade to version 8.7 beta 2, the result has been improved but the first dot was roughly 3.5 years different from the result which was coded in VBA.
KAm
Thank for your email.
I did change it to manual input from auto-detection.
My problem has not resolved.
I guess the fundamental question is associated to the logic of multicharts. It seems to me that multicharts ( version 8.5) cannot deal with something is changing. As advised by the support, I upgrade to version 8.7 beta 2, the result has been improved but the first dot was roughly 3.5 years different from the result which was coded in VBA.
KAm
Re: Problem While....Loop
OK then maybe you could have a chat session with MC supportHI Martin,
Thank for your email.
I did change it to manual input from auto-detection.
My problem has not resolved.
I guess the fundamental question is associated to the logic of multicharts. It seems to me that multicharts ( version 8.5) cannot deal with something is changing. As advised by the support, I upgrade to version 8.7 beta 2, the result has been improved but the first dot was roughly 3.5 years different from the result which was coded in VBA.
KAm
Good luck
Martin