Please edit your post . . .
Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:
Please use this to post code . . . it makes it easier to read.danielo87:
The problem is that despite the trend, the memory DoubleToStr is reset after 15 candles and exposed to 0 What could be causing this?
DoubleToStr() is a function not a variable. trendinfo is your variable, so if it is 0 then it is 0.x Try adding a print for your Short and Long MAs to see if they are equal.
It seems to me that the value should be saved to a file and read it.
danielo87:
It seems to me that the value should be saved to a file and read it.
It seems to me that the value should be saved to a file and read it.
Pointless . . . . print these values ShortMa2, LongMa2, ShortMa1, LongMa1
Neither of these tests will be true so trendinfo will be 0.0
if(ShortMa2>LongMa2 && ShortMa1<LongMa1) trendinfo = -1;
if(ShortMa2<LongMa2 && ShortMa1>LongMa1) trendinfo = 1;
danielo87:
It seems to me that the value should be saved to a file and read it.
It seems to me that the value should be saved to a file and read it.
Why are you using doubletostr, when your function returns an integer value?....
I suspect that there are conditions that you haven't considered, which is why a zero value is being returned.
You could change your logic to something like this:
if(condition 1 && condition 2){ return(1); }else if( condition 3 && condition 4){ return(-1); }else{ print(ma1 value); print(ma2 value); print(ma3 value); print(ma4 value); } //This would allow you to determine which other conditions you need to consider...
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
function to check if there is a market trend - based on the intersection of the long and short moving average:
The problem is that despite the trend, the memory DoubleToStr is reset after 15 candles and exposed to 0 What could be causing this?