How do I find out if the stock is subject to trend or not?

Hello, I am evaluating the purchase of the license, before proceeding I would like to test a simple idea with the programming language and see if I can manage to learn.
I would like to check if the stock is subject to following the trend or not, to do so I buy at the break of the high of the previous day or I sell at the break of the low of the previous day, I close at the end of the day ............ .. I know it's trivial but not knowing anything about programming I'm going crazy, there is someone who could kindly put me on the right path :-). Thank you.

Create a "flag" by using the "Cross" function.

Hi "Possum" and thanks for your reply, I tried to follow your advice but I couldn't create anything presentable, at the moment I'm at this point: (forgive my english son google translate :smile:)

SetOption("activateStopsImmediately",1);

BuyLimitPrice = Ref(H,-1);
BuySignal = H>=BuyLimitPrice;
Buy = BuySignal;
BuyPrice = BuyLimitPrice;

Sell = 0;
SellPrice = Close;

ApplyStop(stopTypeNBar,stopModeBars,0,0,False,0,0,-1); 

This is the "long" part to which the "short" part must be added and here the problems related to my ignorance begin: -) .... how can I do? to tell the program that I want to go short.

BuyLimitPrice = Ref(L,-1);
BuySignal = L<=BuyLimitPrice;
Buy = BuySignal;
BuyPrice = BuyLimitPrice;

So I execute the operations in the correct way but distorts the result of the equity because it sees them as long operations, returning negative values.
thank you.

Update:

SetOption("activateStopsImmediately",1);

BuyLimitPrice = Ref(H,-1);
BuySignal = H>=BuyLimitPrice;
Buy = BuySignal;
BuyPrice = BuyLimitPrice;

Sell = 0;

ShortLimitPrice = Ref(L,-1);
ShortSignal = L<=ShortLimitPrice;
Short = ShortSignal;
ShortPrice = ShortLimitPrice;

Cover =0;

ApplyStop(stopTypeNBar,stopModeBars,0,0,False,0,0,-1);

I do not know if it is the best solution, but this is how it works, it can verify if the chosen title is subject to follow the trend or not ..... which was what I wanted :slightly_smiling_face:.
Example with Alcoa Corp (AA), data from 2010 to 2014, resulting equity:
Equity

Nice job.....keep studying. You might experiment with Ref(H,-2), Ref(L,-3), etc., etc...many combinations to study.