Advertisement
JustUncleL

[Autoview][BackTest] Blank R0.13B

Jun 9th, 2018
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.00 KB | None | 0 0
  1. //@version=3
  2.  
  3. // // BEGIN UNCOMMENT FOR BACKTESTING
  4. // strategy(title="[Autoview][BackTest] Blank R0.13B", shorttitle="[BT]Blank R0.13B", overlay=true,
  5. // pyramiding=0, default_qty_value=100, default_qty_type=strategy.cash,currency="USD",
  6. // commission_value=0.2,commission_type=strategy.commission.percent, initial_capital=1000)
  7. // // END UNCOMMENT FOR BACKTESTING
  8.  
  9. // COMMENT OUT FOR BACKTESTING
  10. study(title="[Autoview][Alerts]Blank R0.13B", shorttitle="[AL]Blank R0.13B", overlay=true)
  11. // END COMMENT OUT FOR BACKTESTING
  12.  
  13. //This does not capture all the pieces of code that need to be commented out/in
  14. //strategyEntry(RUNNING, AS, STUDY) => RUNNING=='This is only used when we are generating alerts' ? -9999.0001 : -9999.0001
  15. //strategyClose(ALERTS, NOT_STRATEGY) => ALERTS=='I know it is weird, just uncmment it' ? -9999.0001 : -9999.0001
  16. // END UNCOMMENT FOR ALERTS
  17.  
  18. //
  19. // Author: yatrader2 / Mrbit
  20. // Adapted from: JustUncleL R0.13
  21. // Revision: R0.13B Branch by MrBit
  22. // Date: 9-June-2018
  23. //
  24. // Description:
  25. // ============
  26. //
  27. // Trade Management options:
  28. // -------------------------
  29. // - Option to specify Backtest start and end time.
  30. // - Trailing Stop, with Activate Level (as % of price) and Trailing Stop (as % of price)
  31. // - Target Profit Level, (as % of price)
  32. // - Stop Loss Level, (as % of price)
  33. // - BUY green triandles and SELL dark red triangles
  34. // - Trade Order closed colour coded Label:
  35. // > Dark Red = Stop Loss Hit
  36. // > Green = Target Profit Hit
  37. // > Purple = Trailing Stop Hit
  38. // > Orange = Opposite (Sell) Order Close
  39. //
  40. // Trade Management Indication:
  41. // ----------------------------
  42. // - Trailing Stop Activate Price = Blue dotted line
  43. // - Trailing Stop Price = Fuschia solid stepping line
  44. // - Target Profit Price = Lime '+' line
  45. // - Stop Loss Price = Red '+' line
  46. //
  47. // Dealing With Renko Charts:
  48. // --------------------------
  49. // - If you choose to use Renko charts, make sure you have enabled the "IS This a RENKO Chart"
  50. // option, (I have not so far found a way to Detect the type of chart is running).
  51. // - If you want non-repainting Renko charts you MUST use TRADITIONAL Renko Bricks. This
  52. // type of brick is fixed and will not change size.
  53. // - Also use Renko bricks with WICKS DISABLED. Wicks are not part of Renko, the whole
  54. // idea of using Renko bricks is not to see the wick noise.
  55. // - Set you chart Time Frame to the lowest possible one that will build enough bricks
  56. // to give a reasonable history, start at 1min TimeFrame. Renko bricks are not dependent
  57. // on time, they represent a movement in price. But the chart candlestick data is used
  58. // to create the bricks, so lower TF gives more accurate Brick creation.
  59. // - You want to size your bricks to 2/1000 of the pair price, so for ETHBTC the price is say 0.0805
  60. // then your Renko Brick size should be about 2*0.0805/1000 = 0.0002 (round up).
  61. // - You may find there is some slippage in value, but this can be accounted for in the Backtes
  62. // by setting your commission a bit higher, for Binance for example I use 0.2
  63. //
  64. // Dealing HA Candles:
  65. // -------------------
  66. // They are supported, but be aware backtest will provide impossible trades...
  67. // https://getsatisfaction.com/tradingview/topics/strategy-tester-places-incorrect-orders-in-backtesting-when-using-heikin-ashi-candles
  68. // By default even if you are using HA candles, the normal candle values are used
  69. //
  70. // References:
  71. // ===========
  72. // - MA Ribbon R0.13 by JustUncleL
  73. // - "How to automate this strategy for free using a chrome extension" by CryptoRox
  74. //
  75. // Revisions:
  76. // ==========
  77. // R0.12 - Beta 2 Version
  78. // R0.13 - Beta 3 version
  79. // > Resolve issue with Orange Close alerts not showing up in the TV
  80. // alarm notifications when using Candlestick Charts.
  81. // > Resolve issue with multiple Long/Short signals before Close by
  82. // better use of the tradeState engine to keep control. This also
  83. // made some of the Risk Management Code simplier.
  84. // R0.13B - [MrBit] Branch from JustUncleL R0.13
  85. // > Remove actual algo
  86. // > Establish functions for long Signal, long Close Signal
  87. // and short Signal, short Close Signal to minimize the places code
  88. // must be editted to update / replace algos
  89. // > Make allow Long and allow short and invert trade directions
  90. // independent options
  91. // > Added support for alternate candle types
  92. // > Added autoset backtest period feature, and optional coloring
  93. // > Moved strategy calls in to functions so they can all be comment
  94. // out or activated / disabled in a single block at the top of the script
  95. //
  96. //
  97. // -----------------------------------------------------------------------------
  98. // Copyright 2018 @JustUncleL, @yatrader2
  99. //
  100. // This program is free software: you can redistribute it and/or modify
  101. // it under the terms of the GNU General Public License as published by
  102. // the Free Software Foundation, either version 3 of the License, or
  103. // any later version.
  104. //
  105. // This program is distributed in the hope that it will be useful,
  106. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  107. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  108. // GNU General Public License for more details.
  109. //
  110. // The GNU General Public License can be found here
  111. // <http://www.gnu.org/licenses/>.
  112. //
  113. // -----------------------------------------------------------------------------
  114. //
  115.  
  116.  
  117. useRenko = input(false, title="This a RENKO Chart?")
  118. useHeikin = input(false, title="Use Heikin-Ashi Candles? (BT WILL BE UNRELIABLE)")
  119. // WARNING: Using Heikin-Ashi may result in inaccurate backtest results
  120. open_ = useHeikin ? security(heikinashi(tickerid), period, open) : security(tickerid, period, open)
  121. close_ = useHeikin ? security(heikinashi(tickerid), period, close) : security(tickerid, period, close)
  122. high_ = useRenko? max(close_,open_) : useHeikin ? security(heikinashi(tickerid), period, high) : security(tickerid, period, high)
  123. low_ = useRenko? min(close_,open_) : useHeikin ? security(heikinashi(tickerid), period, low) : security(tickerid, period, low)
  124. uPrice = input(title="Price", defval="close", options=["close", "high", "low"])
  125. src= uPrice=="close" ? close_ : uPrice=="high" ? high_ : uPrice=="low" ? low_ : na
  126.  
  127. // Use Alternate Anchor TF for MAs
  128. anchor = input(0,minval=0,maxval=1440,title="Alternate TimeFrame Multiplier (0=none)")
  129.  
  130. // If have anchor specified, calculate the base multiplier.
  131. //mult = isintraday ? anchor==0 or interval<=0 or interval>=anchor or anchor>1440? 1 : round(anchor/interval) : 1
  132. //mult := isdwm? 1 : mult // Only available Daily or less
  133. mult = anchor>0 ? anchor : 1
  134.  
  135. // - FUNCTIONS
  136.  
  137.  
  138. longSignal()=>
  139. false
  140.  
  141. shortSignal()=>
  142. false
  143.  
  144. closeLongSignal()=>
  145. false
  146.  
  147. closeShortSignal()=>
  148. false
  149.  
  150.  
  151. // Generate Buy Sell signals,
  152. buy = 0
  153. sell= 0
  154. //
  155. buy := longSignal() ? 1 : 0
  156. sell := shortSignal() ? 1 : 0
  157. //
  158.  
  159. //////////////////////////////////////////////////////////////////////////////////////////
  160. //*** This Trade Management Section of code is a modified version of that found in ***//
  161. //*** "How to automate this strategy for free using a chrome extension" by CryptoRox ***//
  162. //*** Modifications and tradeState engine by JustUncleL. ***//
  163. //////////////////////////////////////////////////////////////////////////////////////////
  164. //
  165.  
  166.  
  167. ///////////////////////////////////////////////
  168. //* Backtesting Period Selector | Component *//
  169. ///////////////////////////////////////////////
  170.  
  171. //* https://www.tradingview.com/script/eCC1cvxQ-Backtesting-Period-Selector-Component *//
  172. //* https://www.tradingview.com/u/pbergden/ *//
  173. //* Modifications made by JustUncleL*//
  174. //* Modifications made by MrBit*//
  175.  
  176. // // BEGIN UNCOMMENT FOR BACKTESTING
  177.  
  178. //// A switch to control background coloring of the test period
  179. //testPeriodBackground = input(title="Color Test Period?", type=bool, defval=false)
  180. //
  181. // Autoset Backtest Period
  182. // Based on code from WellSpentTime
  183. //autolen = input(title="Auto set backtest Start", defval=true)
  184. //custom_candle_start = 0
  185. //timecondition_hourly = n > round(76.5633 * pow((interval / 60), 2) - 1745.19 * (interval / 60) + 10649)
  186. //timecondition_daily = n > round(1000 / interval) // Only for bitcoin, need a separate quadratic fit for other securities
  187. //time_condition = (interval >= 60 and interval <= 720 and timecondition_hourly) or (interval < 60 and timecondition_daily)
  188. //
  189. //// Or set a specifc period
  190. //// From https://www.tradingview.com/script/eCC1cvxQ-Backtesting-Period-Selector-Component/
  191. //testStartMonth = input(title="Backtest Start Month", type=integer, defval=1, step=1, minval=1, maxval=12)
  192. //testStartYear = input(title="Backtest Start Year", type=integer, defval=2018, step=1, minval=2013, maxval=2019)
  193. ////testStartDay = input(title="Backtest Start Day", defval=28, step=1, minval=1, maxval=31)
  194. //testStartDay = 1
  195. //testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
  196. //
  197. //testStopMonth = input(title="Backtest Stop Month", type=integer, defval=12, step=1, minval=1, maxval=12)
  198. //testStopYear = input(title="Backtest Stop Year", type=integer, defval=2018, step=1, minval=2013, maxval=2020)
  199. ////testStopDay = input(title="Backtest Stop Day", type=integer, defval=31, step=1, minval=1, maxval=31)
  200. //testStopDay=31
  201. //testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)
  202. //
  203. //// Set the time period
  204. //testPeriod() => autolen ? time_condition : time >= testPeriodStart and time <= testPeriodStop ? true : false
  205. //
  206. //// Color the period (or don't)
  207. //testPeriodBackgroundColor = testPeriodBackground and testPeriod() ? #000055 : na
  208. //bgcolor(testPeriodBackgroundColor, transp=90)
  209.  
  210. // // END UNCOMMENT FOR BACKTESTING
  211.  
  212.  
  213. //////////////////////////
  214. //* Strategy Component *//
  215. //////////////////////////
  216.  
  217. AQUA = #00FFFFFF
  218. BLUE = #0000FFFF
  219. RED = #FF0000FF
  220. LIME = #00FF00FF
  221. GRAY = #808080FF
  222. DARKRED = #8B0000FF
  223. DARKGREEN = #006400FF
  224. //
  225. fastExit = input(false,title="Use Opposite Trade as a Close Signal")
  226. clrBars = input(true,title="Colour Candles to Trade Order state")
  227. orderType = input("Longs+Shorts",title="What type of Orders", options=["Longs+Shorts","LongsOnly","ShortsOnly","Flips"])
  228. isLong = orderType!="ShortsOnly" //input(true,title="Allow Longs")
  229. isShort = orderType!="LongsOnly" //input(true,title="Allow Shorts")
  230. //Flips only work when both Longs+Shorts is used
  231. //invertTrade = input(false,title="Invert Trade Direction")
  232. //
  233.  
  234. //////////////////////////
  235. //* Trade State Engine *//
  236. //////////////////////////
  237.  
  238. // Keep track of current trade state
  239. longClose = false, longClose := nz(longClose[1],false)
  240. shortClose = false, shortClose := nz(shortClose[1],false)
  241. tradeState = 0, tradeState := nz(tradeState[1])
  242. tradeState := tradeState==0 ? buy==1 and (barstate.isconfirmed or barstate.ishistory) and isLong and not longClose and not shortClose? 1 :
  243. sell==1 and (barstate.isconfirmed or barstate.ishistory) and isShort and not longClose and not shortClose? -1 :
  244. tradeState : tradeState
  245.  
  246. //////////////////////////////////////////////////
  247. //* Put Entry and special Exit conditions here *//
  248. //////////////////////////////////////////////////
  249.  
  250. //Entry Conditions, when state changes direction.
  251. //
  252. longCondition = false
  253. shortCondition = false
  254. longCondition := change(tradeState) and tradeState==1
  255. shortCondition := change(tradeState) and tradeState==-1
  256. if orderType=="Flips"
  257. temp = longCondition
  258. longCondition := shortCondition
  259. shortCondition := temp
  260. //end if
  261.  
  262. // Exit on Sell signal
  263. longExitC = closeLongSignal() ? 1 : 0
  264. shortExitC = closeShortSignal() ? 1 : 0
  265.  
  266. // Exit condition for no SL.
  267. longExit = change(longExitC) and longExitC==1 and tradeState==1
  268. shortExit = change(shortExitC) and shortExitC==1 and tradeState==-1
  269.  
  270. // -- debugs
  271. //plotchar(tradeState,"tradeState at Event",location=location.bottom, color=na)
  272. //plotchar(longCondition, title="longCondition",color=na)
  273. //plotchar(shortCondition, title="shortCondition",color=na)
  274. //plotchar(tradeState, title="tradeState",color=na)
  275. // -- /debugs
  276.  
  277. /////////////////////////////////////
  278. //======[ Deal Entry Prices ]======//
  279. /////////////////////////////////////
  280.  
  281. last_open_longCondition = na
  282. last_open_shortCondition = na
  283. last_open_longCondition := longCondition ? close : nz(last_open_longCondition[1])
  284. last_open_shortCondition := shortCondition ? close : nz(last_open_shortCondition[1])
  285.  
  286. //////////////////////////////////
  287. //======[ Position State ]======//
  288. //////////////////////////////////
  289.  
  290. in_longCondition = tradeState == 1
  291. in_shortCondition = tradeState == -1
  292.  
  293. /////////////////////////////////
  294. //======[ Trailing Stop ]======//
  295. /////////////////////////////////
  296.  
  297. isTS = input(true, "Trailing Stop")
  298. ts = input(3.0, "Trailing Stop (%)", minval=0,step=0.1, type=float) /100
  299.  
  300. last_high = na
  301. last_low = na
  302. last_high_short = na
  303. last_low_long = na
  304. last_high := not in_longCondition ? na : in_longCondition and (na(last_high[1]) or high_ > nz(last_high[1])) ? high_ : nz(last_high[1])
  305. last_high_short := not in_shortCondition ? na : in_shortCondition and (na(last_high[1]) or high_ > nz(last_high[1])) ? high_ : nz(last_high[1])
  306. last_low := not in_shortCondition ? na : in_shortCondition and (na(last_low[1]) or low_ < nz(last_low[1])) ? low_ : nz(last_low[1])
  307. last_low_long := not in_longCondition ? na : in_longCondition and (na(last_low[1]) or low_ < nz(last_low[1])) ? low_ : nz(last_low[1])
  308.  
  309. long_ts = isTS and in_longCondition and not na(last_high) and (low_ <= last_high - last_high * ts) //and (last_high >= last_open_longCondition + last_open_longCondition * tsi)
  310. short_ts = isTS and in_shortCondition and not na(last_low) and (high_ >= last_low + last_low * ts) //and (last_low <= last_open_shortCondition - last_open_shortCondition * tsi)
  311.  
  312.  
  313. ///////////////////////////////
  314. //======[ Take Profit ]======//
  315. ///////////////////////////////
  316.  
  317. isTP = input(true, "Take Profit")
  318. tp = input(3.0, "Take Profit (%)",minval=0,step=0.1,type=float) / 100
  319. ttp = input(1.0, "Trailing Profit (%)",minval=0,step=0.1,type=float) / 100
  320. ttp := ttp>tp ? tp : ttp
  321.  
  322. long_tp = isTP and in_longCondition and (last_high >= last_open_longCondition + last_open_longCondition * tp) and (low_ <= last_high - last_high * ttp)
  323. short_tp = isTP and in_shortCondition and (last_low <= last_open_shortCondition - last_open_shortCondition * tp) and (high_ >= last_low + last_low * ttp)
  324.  
  325. /////////////////////////////
  326. //======[ Stop Loss ]======//
  327. /////////////////////////////
  328.  
  329. isSL = input(false, "Stop Loss")
  330. sl = input(3.0, "Stop Loss (%)", minval=0,step=0.1, type=float) / 100
  331. long_sl = isSL and in_longCondition and (low_ <= last_open_longCondition - last_open_longCondition * sl)
  332. short_sl = isSL and in_shortCondition and (high_ >= last_open_shortCondition + last_open_shortCondition * sl)
  333.  
  334. ////////////////////////////////////
  335. //======[ Stop on Opposite ]======//
  336. ////////////////////////////////////
  337.  
  338. //NOTE Short exit signal is non-repainting, no need to force it, if Pyramiding keep going
  339. long_sos = (fastExit or (not isTS and not isSL)) and longExit and in_longCondition
  340. short_sos = (fastExit or (not isTS and not isSL)) and shortExit and in_shortCondition
  341.  
  342. /////////////////////////////////
  343. //======[ Close Signals ]======//
  344. /////////////////////////////////
  345.  
  346. // Create a single close for all the different closing conditions, all conditions here are non-repainting
  347. longClose := isLong and (long_tp or long_sl or long_ts or long_sos) and not longCondition
  348. shortClose := isShort and (short_tp or short_sl or short_ts or short_sos) and not shortCondition
  349.  
  350. ///////////////////////////////
  351. //======[ Plot Colors ]======//
  352. ///////////////////////////////
  353.  
  354. longCloseCol = na
  355. shortCloseCol = na
  356. longCloseCol := long_tp ? green : long_sl ? maroon : long_ts ? purple : long_sos ? orange :longCloseCol[1]
  357. shortCloseCol := short_tp ? green : short_sl ? maroon : short_ts ? purple : short_sos ? orange : shortCloseCol[1]
  358. //
  359. tpColor = isTP and in_longCondition ? lime : isTP and in_shortCondition ? lime : na
  360. slColor = isSL and in_longCondition ? red : isSL and in_shortCondition ? red : na
  361.  
  362.  
  363. //////////////////////////////////
  364. //======[ Strategy Plots ]======//
  365. //////////////////////////////////
  366.  
  367. plot(isTS and in_longCondition?
  368. last_high - last_high * ts : na, "Long Trailing", fuchsia, style=2, linewidth=2,offset=1)
  369. plot(isTP and in_longCondition and last_high < last_open_longCondition + last_open_longCondition * tp ?
  370. last_open_longCondition + last_open_longCondition * tp : na, "Long TP Active", tpColor, style=3,join=false, linewidth=2,offset=1)
  371. plot(isTP and in_longCondition and last_high >= last_open_longCondition + last_open_longCondition * tp ?
  372. last_high - last_high * ttp : na, "Long Trailing", black, style=2, linewidth=2,offset=1)
  373. plot(isSL and in_longCondition and last_low_long > last_open_longCondition - last_open_longCondition * sl ?
  374. last_open_longCondition - last_open_longCondition * sl : na, "Long SL", slColor, style=3,join=false, linewidth=2,offset=1)
  375. //
  376. plot(isTS and in_shortCondition?
  377. last_low + last_low * ts : na, "Short Trailing", fuchsia, style=2, linewidth=2,offset=1)
  378. plot(isTP and in_shortCondition and last_low > last_open_shortCondition - last_open_shortCondition * tp ?
  379. last_open_shortCondition - last_open_shortCondition * tp : na, "Short TP Active", tpColor, style=3,join=false, linewidth=2,offset=1)
  380. plot(isTP and in_shortCondition and last_low <= last_open_shortCondition - last_open_shortCondition * tp ?
  381. last_low + last_low * ttp : na, "Short Trailing", black, style=2, linewidth=2,offset=1)
  382. plot(isSL and in_shortCondition and last_high_short < last_open_shortCondition + last_open_shortCondition * sl ?
  383. last_open_shortCondition + last_open_shortCondition * sl : na, "Short SL", slColor, style=3,join=false, linewidth=2,offset=1)
  384. //
  385. bclr = not clrBars ? na : tradeState==0 ? GRAY :
  386. in_longCondition ? close<last_open_longCondition? DARKGREEN : LIME :
  387. in_shortCondition ? close>last_open_shortCondition? DARKRED : RED : GRAY
  388. barcolor(bclr,title="Trade State Bar Colouring")
  389.  
  390.  
  391. ///////////////////////////////
  392. //======[ Alert Plots ]======//
  393. ///////////////////////////////
  394.  
  395. // // START OF COMMENT OUT FOR BACKTESTING
  396.  
  397. plotshape(longCondition?close:na, title="Long", color=green, textcolor=green, transp=0,
  398. style=shape.triangleup, location=location.belowbar, size=size.small,text="LONG",offset=0)
  399. plotshape(longClose?close:na, title="Long Close", color=longCloseCol, textcolor=white, transp=0,
  400. style=shape.labeldown, location=location.abovebar, size=size.small,text="Long\nClose",offset=0)
  401.  
  402. plotshape(shortCondition?close:na, title="Short", color=red, textcolor=red, transp=0,
  403. style=shape.triangledown, location=location.abovebar, size=size.small,text="SHORT",offset=0)
  404. plotshape(shortClose?close:na, title="Short Close", color=shortCloseCol, textcolor=white, transp=0,
  405. style=shape.labelup, location=location.belowbar, size=size.small,text="Short\nClose",offset=0)
  406.  
  407.  
  408. // Autoview alert syntax - This assumes you are trading coins BUY and SELL on Binance Exchange
  409. // WARNING*** Only use Autoview to automate a strategy after you've sufficiently backtested and forward tested the strategy.
  410. // You can learn more about the syntax here:
  411. // http://autoview.with.pink/#syntax and you can watch this video here: https://www.youtube.com/watch?v=epN5Tjinuxw
  412.  
  413. // For the opens you will want to trigger BUY orders on LONGS (eg ETHBTC) with alert option "Once Per Bar Close"
  414. // and SELL orders on SHORTS (eg BTCUSDT)
  415. // b=buy q=0.001 e=binance s=ethbtc t=market ( LONG )
  416. // or b=sell q=0.001 e=binance s=btcusdt t=market ( SHORT )
  417. alertcondition(longCondition, "Open Long", "LONG")
  418. alertcondition(shortCondition, "Open Short", "SHORT")
  419.  
  420. // For the closes you will want to trigger these alerts on condition with alert option "Once Per Bar"
  421. // (NOTE: with Renko you can only use "Once Per Bar Close" option)
  422. // b=sell q=99% e=binance s=ethbtc t=market ( CLOSE LONGS )
  423. // or b=buy q=99% e=binance s=btcusdt t=market ( CLOSE SHORTS )
  424. // This gets it as it happens and typically results in a better exit live than in the backtest.
  425. // It works really well for counteracting some market slippage
  426. alertcondition(longClose, "Close Longs", "CLOSE LONGS")
  427. alertcondition(shortClose, "Close Shorts", "CLOSE SHORTS")
  428.  
  429. // // END COMMENT OUT FOR BACKTESTING
  430.  
  431. ////////////////////////////////////////////
  432. //======[ Strategy Entry and Exits ]======//
  433. ////////////////////////////////////////////
  434.  
  435. // // BEGIN UNCOMMENT FOR BACKTESTING
  436.  
  437. //if testPeriod() and isLong
  438. // strategyEntry("Long", 1, longCondition)
  439. // strategyClose("Long", longClose)
  440. //
  441. //if testPeriod() and isShort
  442. // strategyEntry("Short", 0, shortCondition)
  443. // strategyClose("Short", shortClose)
  444.  
  445. // // END UNCOMMENT FOR BACKTESTING
  446.  
  447. // --- Debugs
  448. //plotchar(longExit,title="longExit",location=location.bottom,color=na)
  449. //plotchar(longCondition,title="longCondition",location=location.bottom,color=na)
  450. //plotchar(in_longCondition,title="in_longCondition",location=location.bottom,color=na)
  451. //plotchar(longClose,title="longClose",location=location.bottom,color=na,color=na)
  452. //plotchar(buy,title="buy",location=location.bottom,color=na)
  453. // --- /Debugs
  454.  
  455. ///////////////////////////////////
  456. //======[ Reset Variables ]======//
  457. ///////////////////////////////////
  458.  
  459. if longClose or not in_longCondition
  460. last_high := na
  461. last_high_short := na
  462.  
  463. if shortClose or not in_shortCondition
  464. last_low := na
  465. last_low_long := na
  466.  
  467. if longClose or shortClose
  468. tradeState := 0
  469. in_longCondition := false
  470. in_shortCondition := false
  471.  
  472.  
  473. //plotchar(tradeState,"tradeState at EOF",location=location.bottom, color=na)
  474. // EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement