Facebook
From Funky Cat, 3 Years ago, written in Plain Text.
This paste is a reply to Re: Re: 5min Chart Strategy Script from Jackson - view diff
Embed
Download Paste or View Raw
Hits: 171
  1. # Indicators
  2. #50 EMA and 100 EMA
  3. ema50 = EMA(applyTo: close, period:50)
  4. ema100 = EMA(applyTo: close, period:100)
  5. #MACD and MACD signal.
  6. macd = MACD(
  7.   applyTo: close,
  8.   fastPeriod: 12,
  9.   slowPeriod: 26
  10. )
  11. macdSignal = MACDSignal(
  12.   applyTo: close,
  13.   signalPeriod: 9,
  14.   fastPeriod: 12,
  15.   slowPeriod: 26
  16. )
  17. #Rule/Triggers
  18. #Pip calculation
  19. pip10 = open * 0.010
  20. pip5 = open * 0.005
  21. longEntryRule = open > (ema50 + pip10)
  22. longEntryRule2 = open > (ema100 + pip10)
  23. series longEntryRule3:
  24.   once: 0
  25.   rest: CrossesUpwards(value: macd,crosses: macdSignal)
  26. #Final Long Entry Rule
  27. FinalLongEntryRule = longEntryRule and longEntryRule2 and ( longEntryRule3 or longEntryRule3[1] or longEntryRule3[2] or longEntryRule3[3] or longEntryRule3[4] )
  28. #Setting initial Stop
  29. period = 5
  30. series StopLoss:
  31.   once: open
  32. for distance from 1 to (period - 1)
  33.   if low[distance] < StopLoss update StopLoss: low[distance]
  34. # Signals
  35. #StopRepeat is to protect Take profit and StopLoss base on open postions.
  36. series StopRepeat:
  37.   once: 0
  38.   rest: 1 if (FinalLongEntryRule and (StopRepeat == 0)) else StopRepeat
  39. series InitialStop:
  40.   once: open
  41.   rest: StopLoss if  (StopRepeat == 1) else InitialStop
  42. series TakeProfit:
  43.   once: 0
  44.   rest : ((open - InitialStop) * 2 + open) if (StopRepeat == 1) else TakeProfit
  45.  
  46. if (open > TakeProfit or open < InitialStop) update StopRepeat: 0
  47. if (open <= TakeProfit or open >= InitialStop) update StopRepeat: 2
  48. #Final Long Exit Rule
  49. FinalLongExitRule = open > TakeProfit or open < InitialStop or open < (ema50-pip10)
  50. enter long when FinalLongEntryRule
  51. exit long when FinalLongExitRule

Replies to Re: Re: Re: 5min Chart Strategy Script rss

Title Name Language When
Re: Re: Re: Re: 5min Chart Strategy Script Flying Agouti text 3 Years ago.