The following is all Javascript EFS which is javascript but adapted to stocks and trading software.
So in following example: high() is simply the High of price in a 1 minute bar. All bars process a High and Low (price for that minute) every minute.
Okay i have figured out how to use loops. However, i am having difficulty in accessing values within the loop i created e.g.
var Source2 = high();
var vValue2 = Source2.getValue(15);
for (h = -15; h < 0; h++) {
vValue2 = Math.max(vValue2, Source2.getValue(-h));
if (vValue2 == Source2.getValue(-h)) {
barIndex2 = getCurrentBarIndex()-h;
}
}
Now lets assume this is all fine and it returns me the values (in this case the Highest high looking forward 15 bars from entry point). However, i now wish to make conditions for the loop to process (all for backtesting purposes) such as:
- I want to return (vValue2 +1) e.g. 'vValue2' has been returned as the highest high (15 bars) and now i want to know the value of 'vValue2 +1 bar' even if this is not the highest bar.
- Is there a way for the loop only to return values if multiple conditions are met such as: i. Return the first Highest high of the 15 bars (lets say 'h') IF the bar ('h' +1) of this return value has a LOW which is less than the LOW of ('h') && ('h'+2), ('h'+3), ('h'+4), all have High less than ('h').
Basically i want to add multiple IF conditions to start a loop?? Or am i supposed to add the IF conditions after a loop has returned its values???
- I am not sure if the things i require are possible or must i use loop after loop to get the desired results.