Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Need help for currentbar being reset to 1 of my program
I wrote a program for find top and bottom of the price. But I find it a problem. After few bars, the program will be restarted, the currentbar will be reset to 1. Please anybody help me, what's the problem of my program as follow:
If (LastDingNo>LastDiNO) and (LastDingBarsBack>=5) and Low=Lowest(Low,LastDingBarsBack) then
Begin
Plot1[LastDiBarsBack](High[LastDiBarsBack],"FenXing");
LastDiNo = CurrentBar;
Print("Condition1");
Print("LastDing",LastDingNo);
Print("LastDi",LastDiNo);
Print("LastDingBarsBack",LastDingBarsBack);
Print("LastDiBarsBack",LastDiBarsBack);
End;
If (LastDiNo>LastDingNO) and Low=Lowest(Low,LastDiBarsBack) then
Begin
LastDiNo = CurrentBar;
Print("Condition2");
Print("LastDing",LastDingNo);
Print("LastDi",LastDiNo);
Print("LastDingBarsBack",LastDingBarsBack);
Print("LastDiBarsBack",LastDiBarsBack);
End;
If (LastDiNo>LastDingNO) and (LastDiBarsBack>=5) and High=Highest(High,LastDiBarsBack) then
Begin
Plot1[LastDiBarsBack](Low[LastDiBarsBack],"FenXing");
LastDingNo = CurrentBar;
Print("Condition3");
Print("LastDing",LastDingNo);
Print("LastDi",LastDiNo);
Print("LastDingBarsBack",LastDingBarsBack);
Print("LastDiBarsBack",LastDiBarsBack);
End;
If (LastDingNo>LastDiNO) and High=Highest(High,LastDingBarsBack) then
Begin
LastDingNo = CurrentBar;
Print("Condition4");
Print("LastDing",LastDingNo);
Print("LastDi",LastDiNo);
Print("LastDingBarsBack",LastDingBarsBack);
Print("LastDiBarsBack",LastDiBarsBack);
End;
And the following picture is the printlog:
Can you help answer these questions from other members on NexusFi?
from your description it sounds like the Max Bars for the study are set to automatic and when TS encountered a situation were it had to look back further than this setting, it reloaded the code.
I would try to use a specific value instead of automatic and make sure that this value is higher than the highest values your variables for "LastDingBarsBack" and "LastDiBarsBack" can have.
I try to comstomized the MaxBarsBack with different value, but it seems work like the same.
Do you have any information for TS operation mechanism, i would like to learn it and try to analyze this problem.
I had tried 1 to 10,20,30,50,100, but the printlog stays the same. Actually it stays the same while the MaxBarsBack is "Auto-detect".
To observe the MaxBarsBack, I add "Print(MaxBarsBack)" in my program, it firstly appear as "1". Every time the currentbar changes to 1, the MaxBarsBack changes.
when you say "Every time the currentbar changes to 1, the MaxBarsBack changes. ", it's actually the other way around. The change in MaxBarsBack causes the reload, which in turn makes the code start over and prints currentbar 1 again.
You need to find out where you look back further than the MaxBarsBack in your code.
It's likely caused by either or both of these variables
To check this, you could test if you get the same behavior when you limit the value that these variables can have to 10 (for example) or keep them static at 10 and use a MaxBarsBack setting of 50.