Skip to content

Instantly share code, notes, and snippets.

@lvca
Last active June 12, 2020 22:03
Show Gist options
  • Save lvca/c1efb5c5fa5196d00285c6b908b4dc4b to your computer and use it in GitHub Desktop.
Save lvca/c1efb5c5fa5196d00285c6b908b4dc4b to your computer and use it in GitHub Desktop.
Arcade Trader strategy to invest when the sma50 line crosses over the sma200 line and sell when the sma50 crosses below sma200 line
function beginTrading(context){
if( History.days().length > 1 ) {
let yesterday = History.last();
let prev = History.relative(-1);
if( yesterday.wma150 >= yesterday.wma200 &&
prev.wma150 < prev.wma200 )
return { invest: true, reason: "wma-150 crossed over wma-200" };
}
}
function endTrading(context){
let yesterday = History.last();
let prev = History.relative(-1);
if( yesterday.wma150 < yesterday.wma200 &&
prev.wma150 >= prev.wma200 )
return { reason: "wma-150 crossed below wma-200" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment