Hi All,
I've recently been experimenting with a trading strategy and discovered Quantopian and decided it'd be a good opportunity to try out the platform but I'm having a really tough time trying to code out the strategy. My only coding experience is with VBA and despite searching around the internet, I can't really find the answers to my questions below and would appreciate any help at all! I have a decent amount of experience with trading but none with Algo Trading.
Main points of the strategy:
-Plot 3 SMAs of 4 , 9 , 18
-Buy/sell when all SMAs point in the same direction (e.g. when they all point up, buy. Sell when they all point in the same direction)
-Close out the trade after 1 period (if Taking profit)
-Set a stop loss just below the previous day low (if buying. reverse for selling)
Difficulties in coding:
-Firstly, I've spent 2 days thinking about it but I can't figure out how I would code something to execute when all 3 SMAs point in the same direction. I suppose I could attempt to code it by attempting to calculate the gradient and buying if all of it > 0 and selling if all < 0 but I couldn't get it to work. [I'm fully aware that the method I tried to execute in the attached code is not what I described. I couldn't get it to work so I was just experimenting with other methods]
-Secondly, the strategy works best on a 30-minutes time frame based off my manual testing, but I can't figure out how to code it to execute on a 30-minute time frame on Quantopian.
-Thirdly, I'm having trouble determining if my strategy is actually doing what I think it is doing. It doesn't seem to me like the stop loss I coded is actually working.
I would GREATLY appreciate it if anyone could help me with any of the 3 points I've raised above.
Thanks!