I would like to build a code which will buy when the price made a pull back of 50% of the current wave.
I would like to set up manually the top and the bottom of the wave when i launch the strategy but if the price continue rising i would need the code to update the new highest and calculate the new level of 50%.
I tried this code which is not working properly:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
defparampreloadbars=10000
bottom=19844
originaltop=19966
hh=highest[barindex](high)
IFhh>originaltopTHEN
top=hh
ENDIF
IFhh<originaltopTHEN
top=originaltop
ENDIF
fib50=((top-bottom)/2)+bottom
c1=low[0]<=fib50
IFc1ANDnotonmarketTHEN
BUY1CONTRACTATMARKET
ENDIF
I tried to backtest it with the graphonprice function but the barindex doesn’t take in consideration the exact period of time i want to test and rather takes all the previous data which bring back a wrong value.
1
GRAPHONPRICEfib50
I would be very gratefull if someone could help me on this matter.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.