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
(In the beginning, I thought it would be easy)
cori
cori
i've been sitting on my hands on this one... i thought it may be tougher than u expected! éet me know if i can help u debug!
regards,
hugues
I have done it mostly, although I cannot say if the results are the same as the original will give. This is because I don't understand what this indicator should give and I don't have a tradestation.
One main Problem was the ability of Easy Language to call a function on a specified bar using a syntax like x = myFunction( param1, param2)[5] which will call the function five bars back. The function then will get this bar as its actual one.
My problem is, that my indicator gets always more then 10 upFracs and therefore the calculated value is -1.
I have looked at this problem the whole evening yesterday and cannot find it.
I post you here what I have done so far. Maybe you can see it. I think, either I have taken one calculation wrong or I have a wrong condition in an if statement.
It's too bad, that there are no Debugger for the programs, this would make it easy to find such errors.
My codestyle is a bit different from yours, but I hope, you can understand it.
If you find something, give me a hint.
with regards, cori
I don't understand, why I get in the downFrac -1 and therefore, the line isn't painted. I have looked at the code again and again and can not find it.
Alexantry, please can you put some prints in your code, which are printing all the calculatet values on each run, so like value0 thru value4, the bl-lines etc. Post the protocol here, so that I maybe can see, what is happening.
greetings, cori
// function Average as provided from Alexantry
//
double calculateAverage( double price[], int length ) {
/*******************************************************************
Description: Simple Moving Average
Provided By: Omega Research, Inc. (c) Copyright 1999
********************************************************************/
if ( debug ) {
logOutput( StringConcatenate( " - calculateAverage() inputs - price[0]: ", price[0],
", length: ", length ) );
}
double sum = 0;
int counter = 0;
double result = 0;
//HDB this loop misses one value: if length is 3, length-1 is 2 and the for loop does 0, 1 whereas it should do 0,1,2
for ( counter = 0; counter < length - 1; counter++ ) {
sum += price[counter];
}
if ( length > 0 ) {
result = sum / length;
}
if ( debug ) {
logOutput( StringConcatenate( " - calculateAverage() return: ", result ) );
}
return( result );
}
anyway, its late so good night and have a nice weekend !
I have corrected the loop and the second line also shows up.
I don't know what it calculates, really not, but it was a good example to learn Easy Language, I now have a reference book - downloaded from tradestation.com. Some things in there are for the programmers, which write code to forget, because it gets difficult to understand like the example I gave above with the [x] behind the function.
BTW: my favorite indicator is the Ichimoku Kinko Hyo.
Ok, lets go. Alexantry, check if it might do what you expect. Compare it to your tradestation or whatever you have.
Picture ( USDJPY )
The code. Make a new custom indicator, name it as you want, and paste it there. - Ah, and don't forget to read the header of the code ;-)
Good luck, and again, thank you, hugues.
cori
EDIT: I have set the debug Switch to false. If not it would fill up your log with garbage.