Tool for Practicing Trading

78 0 11
For newbies at trading or people who want to try practice on a new market prior to trading with real money.

Most trader newbies will first work on a practice account to develop their skills. They will also look at historical data to see how they would have fared at that time. If you are like me, both these methods have serious drawbacks.

Practice account
Trading on a practice account is slow as you have to wait for the market to unfold to realize whether your analysis was correct and whether your decisions were right. Many people say that new traders should trade on the daily chart , not the intraday. And this is really slow, of course, as you have to wait for a few days before you can be sure. This is maybe why some new traders start trading intraday, with all risks and bad habits it can generate.

Historical Data
Here, we can work faster since the market has already developped. But the problem is that analysis and decision are biaised because we can see the "future" market moves. If you are like me, analysing and defining trades from past data is much easier then real time ones.

The Script
This is why I have created this script that allows you to hide all market data after a "Now" time that you define. Beyond the "Now", you the screen will be just gray.
By increasing day by day, or hour by hour, you can see the historical market unfold and evolve. It allows to practice trading on the daily chart much faster, analyzing several days and possibly weeks writing a few hours.

  • To ensure that the "Future" bars are really invisible, you need to modify the security bar styles to hide the borders. One you hide them, all bars will be fully hidden after the data selected as "Now".
  • Depending on your internet access speed, the loading of new data when you modify the :"Now" parameters may be slow, but it is certainly faster that waiting for the market unfolding day by day !

If you see any way to make this script more efficient, I am welcoming ideas and comments.
Remove from Favorite Scripts Add to Favorite Scripts
// --------------------------------------------------------
// Tool for practicing trading | v1 (Published Version)
// --------------------------------------------------------
// Created by Etienne Charlier
// Tool to use historical data as real life data and practice new strategies or new markets conditions
// The script hides all price bars beyond a date defined as "Now". 
// This allows to use historical data to practice, without knowing how it will move. 
// The script works as follows:
//      All bars beyond "Now" are considered as "Future" and to be hidden.
//      The script colors both the "Future" bars and the "Future" background in the same color as the candle bar wicks.
//      In order to make bars fully invisible, you need to unselect "Border" in the setting for the security candle bar.
// The script settings allows you to define: 
//      "Now"s Year-Month-Day-Hour
//      Nbr of days for Slow EMA (default 21)
//      Nbr of days for Fast EMA (default 8)
//      All colors to match your chart template
// Handling of overlay indicators:
// Standard indicators also show a hint of "Future" trend and are not hidden. 
// For instance, build-in EMA indicator will also show in the "Future" area and does not allow you to trade in "real time" conditions.
// This script provide a PastSlowEMA and a PastFastEMA that stops at "Now"
// You can add any overlay indicator you want, by filtering it with the IsFuture boolean variable.
// If you need not overlayed indicators, create separate script to filter them, using the code below.

study(title = "Tool for Practicing Trading", shorttitle="Practice", overlay = true)

// Input Parameters
NowYear = input(defval=2015, title="Now: Year", type=integer, step=1, minval=1990)
NowMonth = input(defval=1, title="Now: Month", type=integer, step=1, minval=1, maxval=12)
NowDay = input(defval=1, title="Now: Day", type=integer, step=1, minval=1, maxval=31)
NowHour = input(defval=16, title="Now: Hour", type=integer, step=1, minval=1, maxval=24)
FastEMA = input(defval=8, title="EMA Days (Fast)", type=integer, step=1, minval=0)
SlowEMA = input(defval=21, title="EMA Days (Slow)", type=integer, step=1, minval=0)
LTEMA = input(defval=65, title="EMA Days (LT)", type=integer, step=1, minval=0)

// Test if current bar is in "future"
IsFuture =  year > NowYear or
            (year == NowYear and month > NowMonth) or
            (year == NowYear and month == NowMonth and dayofmonth > NowDay) or
            (year == NowYear and month == NowMonth and dayofmonth == NowDay and hour > NowHour) ?
            true : false

// Create "Past" indicators for Historical Past Data Series: PastFastEMA, PastSlowEMA, PastLTEMA
PastFastEMA = IsFuture ? na : ema(close,FastEMA)
PastSlowEMA = IsFuture ? na : ema(close,SlowEMA)
PastLTEMA = IsFuture ? na : ema(close,LTEMA)

// Color "Future" bars, "Future" background 
barcolor(IsFuture ? #737375 : na)
bgcolor(IsFuture ? #737375 : na, transp=0) 

// Plot "Past" indicators
plot(PastFastEMA, title="Fast EMA", color=#e69138)
plot(PastSlowEMA, title="Slow EMA", color=#3d85c6)
plot(PastLTEMA, title="LT EMA", color=#424242)

// You can add here code to "mute" other indicators that you normally display on your chart.
// This consist in creating a new series called "PastIndicatorName" that only includes data for bars prior to "Now"
// To do so, create one line for each of the indicators you use. Then you plot that new series.
// Code to add:
// PastIndicatorName = IsFuture ? na : indicatorfunction(xxx)
// plot(PastIndicatorName, title="IndicatorName", color= xxxx)
Ideas Scripts Chart
United States
United Kingdom
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out