TradingView
codypd
2 apr 2016 20:43

Simple Strategy Code Stub 

United States Oil FundArca

Descrizione

This is a very basic strategy implementation

Use as a code stub for your strategy code. I wrote it because I could not find one.

This particular strategy goes long on Tuesdays at 10 am and goes short at 3 pm on Thursdays.
Because US markets open at 9:30 you have to have your chart in 30 minute or less resolution for trades to fire.

You can gut that code and replace it with your own to start testing your own indicators and strategies.
If you build a strategy that doesn't use "hour" like I have this resolution requirement won't apply.

For giggles, compare its performance to other strategies. Weird, huh? About 53% effective on most equities and indexes.

This strategy does the minimum needed to get a strategy working
and uses default position sizes and buys at market with no stops.
Again, it is the minimal code stub needed to test an indicator/rule based strategy.
A great code reference for building more sophisticated strategies can be
found here =>

The code is written by @greatwolf and is very well structured for anyone looking to fully utilize
strategy features for position sizing, limit orders, stops and cancellations.
Altro