This doesn't seem to work - i'm passing atr(50) to a Function that expects a number and it flat-lines. So, i tried to plot this logic on a chart and it doesn't plot b for the first 50 bars because atr(50) doesn't exist.
b = iff((atr(50) != atr(50)),5,3*atr(50));
Plot(b, "ATR50: ", colorBlue,ChartBar);
How do i say either
- for first 50 bars, use a hard number (say 3), else use atr(50) OR
- for bars where atr(50) doesn't exist, use a hard number else use atr(50)
I tried this below so i have a valid non-NaN value for b in the first 50 bars - however, the plot still shows NaN for first 50 bars and shows ATR(50) after. Why isn't the iff condition working?
b = iff(sum(1)<51,1, atr(50));
Plot(b, "ATR50: ", colorPurple,ChartBar);
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.