Buy/Sell when MA reverses direction

Hi ,

Could you please provide some advice on creating a Buy or Sell signal when a Moving average reverses its direction.

Eg: MA reverses from Up to Down then Sell on next candle. Or the oposit for a Buying signal.

Thanks !

Hi Ray, yes seetu can help you evaluate a few moving average reversals. However, to really get a feel for such a strategy you will need to evaluate hundreds of lengths of moving average over thousands of active products. Then you will need to evaluate the fade strategy for the same hundreds of lengths of moving average over the same thousands of products. Then summarize the findings to try to come to a data-driven conclusion about the merits of such a strategy. IMHO, seetu is not up to this larger task. You will need a general purpose language such as java, python, c++, etc.

Hi Allen, thanks for your reply.

Let me narrow down the variables to 1 symbol and 1 moving average, so the strategy might be feasible on Seetu.

For example:

  • Buy SPY on the the opening of next candle after MA 9 Turns Up

  • stop loss on the minimum of previous candle

  • stop gain equals stop loss on opposite direction

  • Sell SPY with same logic with opposite signals

My main trouble right now is how to detect that a MA change its direction.

Thanks a lot.

likely you will never make any money long term. Guys if it was that simple everyone would be millionaires. Do you think your the first one that thought of that idea? I don’t mean to be critical but it amazes me how many people think trading is that easy. I trade full time for a living and i only wish it was that simple (and for the record, yes i have tried that and back tested it).

I code, but not Seetu. So I can’t give specifics, but generally:

If the MA increased from the previous MA, then it ‘turned up.’ And vice-versa.

How to tell if it increased/decreased?

Use a variable to store MA. Next day, compare new MA to MA that’s stored in a variable. Or,

If there is a way, just calculate current MA, and the MA from previous day, and compare.


Left some stuff out.

Actually, when the MA is increasing, it is up, of course. But you asked about reversals.

So, when the MA goes from down to up, then a reversal has taken place.

So, you may need an additional variable to store the direction of the MA (up/down).

And vice-versa on all of the above.

gametime, i think ray is picking a facile strategy as a self-challenge to learn seetu programming, not necessarily to proclaim it a profitable strategy.

1 Like

you need to compare current close with previous two closes.
if close[-2] greater than close[-1] and close[-1] is less than close[0] then you have a bounce.

He’s asking about the moving average of closes.

Gametime: Thanks for the advice. As Allen mentioned, I am familiarizing with coding in Seetu with a popular setup from trader Larry Williams.

MachineLearningTradr and AllenEverhart, thanks for the tips, they make a lot of sense, I am about to test the Seetu code below:

MA9 = CalcMA (close, 9);
MA9last1 = ref (MA9, -1);
MA9last2 = ref (MA9, -2);

BuySignal = MAlast2 > MA9last1 < MA9last;

Like I said, I don’t code Seetu, but it looks like you understand the logic of what I was trying to say. :smile:

But, based upon what you wrote, maybe try:

BuySignal = MA9 > MA9last1 < MA9last2;


Just a remark:

BuySignal = MA9 > MA9last1 < MA9last2;

is not valid syntax.

Valid syntax is something like: BuySignal = A > B AND B < C;

Re the original question: See this for inspiration:

1 Like

Yes! That’s the idea, my typo.

@BobSvan2 this post sums up most of my doubts. Thanks.