introd u ction to signals
play

Introd u ction to signals FIN AN C IAL TR AD IN G IN R Il y a - PowerPoint PPT Presentation

Introd u ction to signals FIN AN C IAL TR AD IN G IN R Il y a Kipnis Professional Q u antitati v e Anal y st and R programmer What are signals ? Signals are the interactions of : Market data w ith indicators Indicators w ith other indicators E


  1. Introd u ction to signals FIN AN C IAL TR AD IN G IN R Il y a Kipnis Professional Q u antitati v e Anal y st and R programmer

  2. What are signals ? Signals are the interactions of : Market data w ith indicators Indicators w ith other indicators E x amples : 50- da y MA crossing o v er 200- da y MA Oscillator crosses u nder 20 Signal is necessar y ( b u t not s u� cient ) for b uy/ sell order FINANCIAL TRADING IN R

  3. Using add . signal () Ver y similar to the process for creating indicators Onl y a fe w signal f u nctions add.signal(strategy.st, name = “function", arguments = list(arguments), label = "label") Again , similar to appl y famil y FINANCIAL TRADING IN R

  4. Fo u r t y pes of signals sigComparison : Relationship bet w een t w o indicators , ret u rns 1 if relationship is tr u e sigCrosso v er : Similar to sigComparison , ret u rns 1 on the � rst occ u rrence sigThreshold : Compares range - bo u nd indicator to a static q u antit y sigForm u la : Fle x ible signal f u nction FINANCIAL TRADING IN R

  5. E x amples FINANCIAL TRADING IN R

  6. E x amples FINANCIAL TRADING IN R

  7. Let ' s practice ! FIN AN C IAL TR AD IN G IN R

  8. sigComparison and sigCrosso v er FIN AN C IAL TR AD IN G IN R Il y a Kipnis Professional Q u antitati v e Anal y st and R programmer

  9. Trend indicators sigCrossover and sigComparison Both compare t w o v ariable q u antities E x ample : shorter lookback MA crosses o v er longer lookback MA (50- da y v ers u s 200- da y SMA ) FINANCIAL TRADING IN R

  10. Str u ct u re add.signal(strategy.st, name = "sigComparison", arguments = list(columns = c("str1", "str2"), relationship = "lt" ), label = "siglabel") add.signal(strategy.st, name = "sigCrossover", arguments = list(columns = c( "str1", "str2"), relationship = "eq"), label = "siglabel") “ gt ”, “ lt ”, “ eq ”, “ lte ”, “ gte ” FINANCIAL TRADING IN R

  11. Str u ct u re add.signal(strategy.st, name = "sigCrossover", arguments = list(columns = c("SMA50", "SMA200"), relationship = "gt"), label = "longfilter") add.signal(strategy.st, name = "sigComparison", arguments = list(columns = c("SMA50", "SMA200", relationship = "lt" ), label = "filterexit") FINANCIAL TRADING IN R

  12. E x amples FINANCIAL TRADING IN R

  13. Let ' s practice ! FIN AN C IAL TR AD IN G IN R

  14. sigThreshold FIN AN C IAL TR AD IN G IN R Il y a Kipnis Professional Q u antitati v e Anal y st and R programmer

  15. Abo u t sigThreshold deals w ith bo u nded indicators interacting w ith critical ( and u s u all y �x ed ) v al u es E x amples : w hen the DVO crosses u nder 20 on indicator w ith r u nning probabilit y v al u e ( bet w een 0 and 1) on rolling ratio ’ s that center on 0 FINANCIAL TRADING IN R

  16. Str u ct u re add.signal(strategy.st, name = “sigThreshold", arguments = list(column = "str1", threshold = 20, cross = TRUE, relationship = "lt" ), label = "siglabel") cross = TRUE mimics sigCrossover cross = FALSE mimics sigComparison FINANCIAL TRADING IN R

  17. E x amples add.signal(strategy.st, name = “sigThreshold", arguments = list(column = "DVO_2_126", threshold = 20, cross = FALSE, relationship = “lt"), label = "thresholdfilter") add.signal(strategy.st, name = “sigThreshold", arguments = list(column = "DVO_2_126", threshold = 80, cross = TRUE, relationship = "gt"), label = "thresholdfilter") FINANCIAL TRADING IN R

  18. E x amples FINANCIAL TRADING IN R

  19. Let ' s practice ! FIN AN C IAL TR AD IN G IN R

  20. sigForm u la FIN AN C IAL TR AD IN G IN R Il y a Kipnis Professional Q u antitati v e Anal y st and R programmer

  21. Abo u t sigForm u la Catch - all signal allo w ing for combinations of signals Uses string e v al u ation E x ample : ONLY act u pon oscillator signaling if fa v orable market en v ironment (50- da y SMA abo v e 200- da y SMA ) make s u re to b uy a temporar y p u llback , not a large decline FINANCIAL TRADING IN R

  22. Str u ct u re add.signal(strategy.st, name = "sigFormula", arguments = list(formula = "statement1 & statement2”, cross = TRUE), label = "yourlabel") Base R : if ( statement 1 and statement 2) add.signal(strategy.st, name = "sigFormula", arguments = list(formula = "regular logical statement inside an if statement", cross = TRUE), label = "yourlabel") FINANCIAL TRADING IN R

  23. E x ample add.signal(strategy.st, name = “sigFormula", arguments = list(formula = "longthreshold & longfilter", cross = TRUE), label = "longentry") make s u re that the col u mns in the logical statement are in the strateg y prior to the sigFormula signal call FINANCIAL TRADING IN R

  24. Let ' s practice ! FIN AN C IAL TR AD IN G IN R

Recommend


More recommend