No Plot in the Chart

When I have this piece of code, it plots on the chart,

Buy = O>MA(C,20); ; 

Sell = O<MA(C,20);

but when I add more to it, like this, `Buy = O>MA(C,20) OR O>MA(C,8);

Sell = O<MA(C,20)-1;

The -1 in second line caused the problem with plotting. Can anyone tell me why?

@Veasnar, you will have to think about your logic here a bit more.

Your Sell Condition should evaluate to a True or False.

Your Sell is trying to do subtraction from a Logic value, so you will get an error.

Your Buy condition is TWO logical tests that are "OR"ed together. That is a Logical OR so it is allowed.

Not sure what you are after with the "-1" in the Sell, so you will have to define it better, and see if you can come up with a condition expression.

Thanks for your response, Snoopy.pa30,
"-1" is for yesterday or one day after it happened.

BTW, there is no error with compilation.

@Veasnar of course there is no error with compilation. You entered a mathematical equation. What you need is to familiar with the Ref function to refer to yesterday (or previous bar's)

If you are uncertain about what your calculations are creating then create an Exploration and see what all your variables are doing.

But also even though you have been a member of the forum for 10 months, you do not appear to have gone through some important steps in learning afl. I suggest you spend some significant time reading and coding what you find as you work your way through the resources listed in this forum post,

Good luck!

Thanks for your advice and suggestion, portfoliobuilder.