Great! To do this stuff well, we need to become a hybrid of an avant-garde trader and an IT engineer. The more you know about what drives price, the better script writer you’ll be. Two additional comments:
You refer to MarketDelta in your earlier post. They are a data provider for volume on the horizontal axis. I don’t believe Quantopian provides that data. Q staff, please chime in.
Since I’m a trader first, quant second, I first translate the basic concept onto a chart to see what kind of trade signals it produces. That initial step serves as a “proof of concept.” So, I did exactly that with your value area trading concept that you're embarking on. And I used an intra-day chart since that was the title of your post.
Here’s the proof-of-concept script:
def lr = 6 * ( WMA(OHLC4, 10) - Average(OHLC4, 10) ) / 9;
def upBar = close > open;
def dnBar = close < open;
def short = lr > 0 && upBar && close > VAHigh;
def long = lr < 0 && dnBar && close < VALow;
plot longSignal = if long && !long1 and !long[2] then low else double.nan;
plot shortSignal = if short && !short1 and !short[2] then high else double.nan;
That means we plot a long signal on an upbar, in an uptrend, when price exceeds the value area high. (vv. for a short) This ensures you are fading the herd, buying on weakness/selling on strength, and trading when prices are distorted from fair market value.
Your concept looks like this during the past five days, trading S&P futures, intra-day at 5000 ticks. The results show a highly positive predictive value: 28 signals profitable, 5 false positives.
So, Luca …if you can get volume data on the horizontal axis into Quantopian’s IDE and write a python script equivalent to my thinkscript …you’re going to kick some butt. Good luck! (By the way, I took trades on a number of those signals last week.)