I was wondering if there was a way that I could create a function that bought based on a previous buy order. For example I am purchasing shares when they are above a certain average but then I want to sell the shares if the next price is higher than the price I bought it for.
I was trying to define a variable like this:
FirstPrice = price > average
SecondPrice = price > FirstPrice
but I am not sure if this is how I should be doing this. This is how I have it set up for now but it is not really working for me.
if FirstPrice==True and notional > context.min_notional:
order(context.jblu, 10)
if SecondPrice==True and notional > context.min_notional:
order(context.jblu, -10)
if price < (average) and notional > context.min_notional:
order(context.jblu, 0)