How to know whether 2 lines are crossing?
How to find out when 2 lines are crossing?
Let's say I have a Strategy with indicator 2 lines, I want to execute an order once the to 2 indicator lines are crossing. I tried if (self.l.indicator1-self.l.indicator2) == 0 but this is not working of course, especially if the timeframe is not 1 Minute.
@crypto_trader Crossing mean one line was above the other on previous period, and is under on current period.
This logic could be written like that :
if (self.l.indicator1>self.l.indicator2) and (self.l.indicator1<self.l.indicator2):
You may want to read below links, for a more efficient implementation :
and have a look at crossover.py indicator.
unfortunately there is a error message:
return self.array[self.idx + ago]
IndexError: array index out of range
@crypto_trader With crossover indicator ? with the if <...> and <...> logic ? You may get a faster and more accurate help if you post the part of your code which cause this error.
@crypto_trader try crossover indicator, or :
if (self.l.indicator1[-1]>self.l.indicator2[-1]) and (self.l.indicator1<self.l.indicator2):
run-out last edited by