Click here to Login





                                                   TO SHARE: Candlestick chart with a few interesting features

  1

0
Josh McCormick
2020-09-05 16:12:27


Hi! I wanted to share a few QuantShare Script ideas that you might find useful in your candlestick chart.

Screenshot 1: https://i.imgur.com/1OoIvxI.png
Screenshot 2: https://i.imgur.com/Gprp252.png

Items include:

1. Large candles which are easy to view (be sure to follow the instructions at the top of the code)
2. Reserved area at the bottom of the graph for custom functions (such as the next item)
3. Infobar with: the current symbol, its full name, and chart information (see #4 and #5)
4. Bold text and a custom font size based on the amount of text you're trying to fit on-screen.
5. Chart information which includes Historical/IntraDay label, exact timeframe info (daily, weekly, 15 min, etc).
6. Large zones color-coded with user-defined trend information
7. Contiguously painted areas which ignore any small one period breaks

Nothing too earth-shattering here, but you might find a trick or two that might be worth stealing. This just sprang out of an effort this morning to put a correct label on the graph so I know if it's on an Historical or an IntraDay chart and ... what I've been missing up until now: what the current TIMEFRAME is.

I thought I was going to have to create a custom function to retrieve the current timeframe, but as it turns out, there is a timeframe() command that is not listed in the manual that returns that information (in days if you're on an historical charts, otherwise, in seconds). A list of iffstr commands allow you to name each of these charts to taste (or native language).

Admittedly, screenshot #2 suggests that I need a better way of showing the divisions between days than the alternate white/lightblue background that is QuantShare's default. I'll give it some more thought.

=========================
QUANTSHARE SCRIPT FOLLOWS:
=========================

// -------------------------------------------------------
// HOW TO: DISPLAY CANDLES WITH NICELY WIDENED PROPORTIONS
// -------------------------------------------------------
//
// Right click on the CHART and select Chart Settings.
// Near the very bottom of the list, under Bar Settings, is Minimum Cluster.
// Set the number to 25 and then close the Chart Settings window.


// -----------------------------------------
// ADD TO CHART: COLOR-ENHANCED CANDLESTICKS
// -----------------------------------------
//
// Color coding and shading explained:
//
// RED = This period's candle closed BELOW the price it opened at.
// GREEN = This period's candle closed ABOVE the price it opened at.
//
// DARKER = This candle saw MORE volume than the previous candle (the candle to the left).
// LIGHTER = This candle saw LESS volume than the previous candle (the candle to the left).

PlotCandleStick("Quotes", colorBlue|255|colorViolet|255|0, StyleBringToFront|StyleWidth2);
UpdateColor(volume >= Ref(volume, 1) and close > open, colorGreen);
UpdateColor(volume < Ref(volume, 1) and close > open, colorLightGreen);
UpdateColor(volume >= Ref(volume, 1) and close <= open, colorRed);
UpdateColor(volume < Ref(volume, 1) and close <= open, colorLightCoral);


// ----------------------------------------------------------------
// ADD TO CHART: DASHED LINE CONNECTING EACH CANDLE'S CLOSING PRICE
// ----------------------------------------------------------------

plot(close, "Closing Price", colorBlack, ChartSmoothLine, StyleDashed|StyleWidth2|StyleHideYAxisValue|StyleHideValues);


// ------------------------------------------
// ADD TO CHART: SYMBOL AND CHART INFORMATION
// ------------------------------------------
// The FULL NAME of the current symbol
// The CHART TYPE (eod or intraday))
// The TIMEFRAME (weekly, 15 minutes, etc)

// Initialize variables

chartname=fullname()." (".Name().") ";
tf="";
frame=timeframe();

// Descriptive labels for the major timeframes. Example: "WEEKLY"
// Please rename these to taste. If you have a custom timeframe, add it here.

tf=tf.iffstr(IsEod() and Frame==1,"EOD DAILY","");
tf=tf.iffstr(IsEod() and Frame==7,"EOD WEEKLY","");
tf=tf.iffstr(IsEod() and Frame==31,"EOD MONTHLY","");
tf=tf.iffstr(IsEod() and Frame==365,"EOD YEARLY","");
tf=tf.iffstr(!IsEod() and Frame==0,"INTRA TICK","");
tf=tf.iffstr(!IsEod() and Frame==1,"INTRA SECOND","");
tf=tf.iffstr(!IsEod() and Frame==60,"INTRA 1 MIN","");
tf=tf.iffstr(!IsEod() and Frame==300,"INTRA 5 MIN","");
tf=tf.iffstr(!IsEod() and Frame==600,"INTRA 10 MIN","");
tf=tf.iffstr(!IsEod() and Frame==900,"INTRA 15 MIN","");
tf=tf.iffstr(!IsEod() and Frame==1800,"INTRA 30 MIN","");
tf=tf.iffstr(!IsEod() and Frame==3600,"INTRA HOUR","");
tf=tf.iffstr(!IsEod() and Frame==7200,"INTRA 2 HOUR","");

// If none of the above labels matched, we'll apply
// a generic label which indicates if you're on an
// EOD or an Intraday chart, and its period length.

tf=tf.iffstr(IsEod() and stringcontains("",tf),"EOD (".frame.")","");
tf=tf.iffstr(!IsEod() and stringcontains("",tf),"INTRA (".frame.")","");
chartname=chartname.tf;

// If the entire string exceeds 50 characters, we'll make
// the font smaller and adjust the offset.

// TODO: YOU MAY NEED TO ADJUST THE SIZE AND OFFSET VALUES
// TO MATCH YOUR SCREEN RESOLUTION AND CHART SIZE.

FontSize=iff (StringLength (chartname)>50,1.5,1.9); // Last two numbers contain sizes.
FontYoffset=iff (StringLength (chartname)>50,4,7); // Last two numbers contain Y offsets.

// Label the chart

PrintChart(chartname,"", BottomCenter, colorBlack, colorTransparent, colorTransparent,255,FontSize);
UpdatePrintSettings("PositionY",1,FontYoffset);

// Label the chart, same settings, but one pixel to the right to create BOLD text.

PrintChart(chartname,"", BottomCenter, colorBlack, colorTransparent, colorTransparent,255,FontSize);
UpdatePrintSettings("PositionY",1,FontYoffset);
UpdatePrintSettings("PositionX",1,1); // One pixel to the right.


// -----------------------------------------------------------------------------------
// ADD TO CHART: 20-PERIOD SHORT-TERM MOVING AVERAGE OF THE CLOSING PRICE, COLOR-CODED
// -----------------------------------------------------------------------------------
//
// This will plot the 20-period SMA (Short-term Moving Average) of the closing price.
// The line will be color coded red (when above the closing price) and green (when
// below the closing price).

plot (sma(20),"sma20",ColorGreen,chartline,StyleWidth3);
Updatecolor (sma(20)>close,ColorRed);


// -----------------------------------------------------------------------
// ADD TO CHART: COLOR-CODED TREND ZONES AND SMALL RESERVED AREA AT BOTTOM
// -----------------------------------------------------------------------
//
// This will shade the graph GREEN or RED depending on the current trend.
// The very bottom of the screen will be colored YELLOW and will not contain candles.
// At extreme zoom levels, the color-coding may revert to default shading due to how the areas are plotted.

// You may define the current trend with whatever formula you see fit:

trend=sma(20)>=close;

// If there are large green or red areas with just a one-line break, the lines
// below will repair the breaks and create large contiguous areas with the same color.

trend=trend or (ref(trend,1) and ref(trend,-1)); // Intentional repaint to make contiguous trend/green areas.
trend=trend and !(!ref(trend,1) and !ref(trend,-1)); // Intentional repaint to make contiguous trend/green areas.
plot(!trend , "GREEN TREND AREA", colorgreen|30, Chartstep, StyleOwnScale|StyleHideYAxisValue|StyleHideValues);
plot(trend, "RED TREND AREA", colorRed|30, Chartstep, StyleOwnScale|StyleHideYAxisValue|StyleHideValues);



Josh McCormick
2020-09-05 16:31:42

  0

Last night I made a little effort towards a QuantShare script that would identify what kind of candle is currently selected (or the mouse is hovered over). Right now, this is a bit of a novelty, and a candle can have more than one match. But certain candles at certain times can provide strong hints at what the market may do... or what you should or should not be doing at that moment in time. The time/date stamp needs a bit more work, too.

Here's what I have so far...

// ONE LINE CHART WHICH DISPLAYS THE NAME
// OF ANY CANDLE OR PATTERN IT DETECTS IN THE CURRENT PERIOD.

period=14;
UpdateSettings("Full Pane", 1);
detect="".date()." ".hour().":".minute()." ";
detect=detect.iffstr(GapUp(),"Gap up. ","");
detect=detect.iffstr(GapDown(),"Gap down. ","");
detect=detect.iffstr(Cdl2crows(),"Cdl2crows ","");
detect=detect.iffstr(Cdl3blackcrows(),"Cdl3blackcrows ","");
detect=detect.iffstr(Cdl3inside(),"Cdl3inside ","");
detect=detect.iffstr(Cdl3linestrike(),"Cdl3linestrike ","");
detect=detect.iffstr(Cdl3outside(),"Cdl3outside ","");
detect=detect.iffstr(Cdl3staRsinsouth(),"Cdl3staRsinsouth ","");
detect=detect.iffstr(Cdl3whitesoldiers(),"Cdl3whitesoldiers ","");
detect=detect.iffstr(CdlAbandonedbaby(period),"CdlAbandonedbaby ","");
detect=detect.iffstr(CdlAdvanceblock(),"CdlAdvanceblock ","");
detect=detect.iffstr(CdlBelthold(),"CdlBelthold ","");
detect=detect.iffstr(CdlBreakaway(),"CdlBreakaway ","");
detect=detect.iffstr(CdlClosingmarubozu(),"CdlClosingmarubozu ","");
detect=detect.iffstr(CdlConcealbabyswall(),"CdlConcealbabyswall ","");
detect=detect.iffstr(CdlCounterattack(),"CdlCounterattack ","");
detect=detect.iffstr(CdlDarkcloudcover(period),"CdlDarkcloudcover ","");
detect=detect.iffstr(CdlDoji(),"CdlDoji ","");
detect=detect.iffstr(CdlDojistar(),"CdlDojistar ","");
detect=detect.iffstr(CdlDragonflydoji(),"CdlDragonflydoji ","");
detect=detect.iffstr(CdlEngulfing(),"CdlEngulfing ","");
detect=detect.iffstr(CdlEveningdojistar(period),"CdlEveningdojistar ","");
detect=detect.iffstr(CdlEveningstar(period),"CdlEveningstar ","");
detect=detect.iffstr(CdlGapsidesidewhite(),"CdlGapsidesidewhite ","");
detect=detect.iffstr(CdlGravestonedoji(),"CdlGravestonedoji ","");
detect=detect.iffstr(CdlHammer(),"CdlHammer ","");
detect=detect.iffstr(CdlHangingman(),"CdlHangingman ","");
detect=detect.iffstr(CdlHarami(),"CdlHarami ","");
detect=detect.iffstr(CdlHaramicross(),"CdlHaramicross ","");
detect=detect.iffstr(CdlHighwave(),"CdlHighwave ","");
detect=detect.iffstr(CdlHikkake(),"CdlHikkake ","");
detect=detect.iffstr(CdlHikkakemod(),"CdlHikkakemod ","");
detect=detect.iffstr(CdlHomingpigeon(),"CdlHomingpigeon ","");
detect=detect.iffstr(CdlIdentical3crows(),"CdlIdentical3crows ","");
detect=detect.iffstr(CdlInneck(),"CdlInneck ","");
detect=detect.iffstr(CdlInvertedhammer(),"CdlInvertedhammer ","");
detect=detect.iffstr(CdlKicking(),"CdlKicking ","");
detect=detect.iffstr(CdlKickingbylength(),"CdlKickingbylength ","");
detect=detect.iffstr(CdlLadderbottom(),"CdlLadderbottom ","");
detect=detect.iffstr(CdlLongleggeddoji(),"CdlLongleggeddoji ","");
detect=detect.iffstr(CdlLongline(),"CdlLongline ","");
detect=detect.iffstr(CdlMarubozu(),"CdlMarubozu ","");
detect=detect.iffstr(CdlMatchinglow(),"CdlMatchinglow ","");
detect=detect.iffstr(CdlMathold(period),"CdlMathold ","");
detect=detect.iffstr(CdlMorningdojistar(period),"CdlMorningdojistar ","");
detect=detect.iffstr(CdlMorningstar(period),"CdlMorningstar ","");
detect=detect.iffstr(CdlOnneck(),"CdlOnneck ","");
detect=detect.iffstr(CdlPiercing(),"CdlPiercing ","");
detect=detect.iffstr(CdlRickshawman(),"CdlRickshawman ","");
detect=detect.iffstr(CdlRisefall3methods(),"CdlRisefall3methods ","");
detect=detect.iffstr(CdlSeparatinglines(),"CdlSeparatinglines ","");
detect=detect.iffstr(CdlShootingstar(),"CdlShootingstar ","");
detect=detect.iffstr(CdlShortline(),"CdlShortline ","");
detect=detect.iffstr(CdlSpinningtop(),"CdlSpinningtop ","");
detect=detect.iffstr(CdlStalledpattern(),"CdlStalledpattern ","");
detect=detect.iffstr(CdlSticksandwich(),"CdlSticksandwich ","");
detect=detect.iffstr(CdlTakuri(),"CdlTakuri ","");
detect=detect.iffstr(CdlTasukigap(),"CdlTasukigap ","");
detect=detect.iffstr(CdlThrusting(),"CdlThrusting ","");
detect=detect.iffstr(CdlTristar(),"CdlTristar ","");
detect=detect.iffstr(CdlUnique3river(),"CdlUnique3river ","");
detect=detect.iffstr(CdlUpsidegap2crows(),"CdlUpsidegap2crows ","");
detect=detect.iffstr(CdlXsidegap3methods(),"CdlXsidegap3methods ","");
PrintChart (detect,"",BottomLeft,ColorBlack,ColorTransparent,ColorTransparent,255);
UpdatePrintSettings("Size",1,14);
UpdatePrintSettings("PositionY",1,0);




Josh McCormick
2020-09-05 22:15:31

  0

Earlier, I said...

> Admittedly, screenshot #2 suggests that I need a better way of showing the divisions between days
> than the alternate white/lightblue background that is QuantShare's default. I'll give it some more thought.

By default, QuantShare switches between a WHITE background and a BLUISH WHITE background to indicate the start of a new trading day. You may find this aesthetically displeasing. Or perhaps (as above) you're already coloring your own background to provide other information (such as trend). You can disable alternate background color by right clicking on the graph, selecting Chart Settings, and then changing (towards the top) the Alternate back color to WHITE and the Alternate alpha to 255. But what to replace it with?

The code below is designed to work with the rest of the changes above. (It creates that same reserved area at the bottom of the chart.) It marks the start of a new day with a thick semi-transparent dark-gray area. Depending on what you're analyzing, a 'new day' could be when the market re-opens, or it could be midnight.

SCRIPT:

NewDay=(!IsEod() and (Day() != Ref(Day(),-1)));
Plot (NewDay,"DAY1",colorDarkGray|175,Chartstep, StyleDashed|StyleOwnScale|StyleHideYAxisValue|StyleHideValues|StyleWidth0);
Plot (!NewDay,"DAY1",colorDarkGray,Chartstep, StyleDashed|StyleOwnScale|StyleHideYAxisValue|StyleHideValues|StyleWidth0);

SAMPLE SCREENSHOT:

https://i.imgur.com/Eh4J2Oa.png

UPDATE (9/9/2020):

I thought the vertical bar lacked visibility so I changed the color to colorDarkBlue. That also changes the color of the 'status bar' at the bottom of the window to match it, so on the Intraday chart, I change the font color from black to white and it works well.

SCREENSHOT WITH DAILY CHART AND 5 MIN INTRADAY CHART WITH COLOR CHANGES:

https://i.imgur.com/CuxOEXI.png

UPDATE (9/10/2020):
Altered the formula for the the "new day" vertical bar so it triggers in the space between the last bar of the day and the first bar of the next day. Much better alignment.

WAS: NewDay=(!IsEod() and (Day() != Ref(Day(),1)));
NOW: NewDay=(!IsEod() and (Day() != Ref(Day(),-1)));



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Enhanced Candlestick Chart with Volume Variation
Chart Pattern Indicator
Relative Performance Chart - Dynamic assets and index
Relative Performance/Return Chart - Compare Several Assets/Stocks...
Plot Economic Indicators on a Chart

How-to Lessons
How to create a chart with a black background
How to plot a stock using different periods in the same chart
How to plot arrows below/above candlesticks on a chart
How to add a trading indicator to a chart
How to print a chart

Related Forum Threads
Limiting the scale of a candlestick chart with volume?
Basic features and some issues with the background
Is it possible to make a spread chart with futures contracts?
Locks up when market is open while using the *daily* chart with I...
Horizontal line on the intraday chart with the day's opening pric...

Blog Posts
Chart Layouts Explained - With Custom Scripts
QuantShare Trading Software: New Features in the 3.4.3 Version
Update Chart Layout based on Active Time Frame
QuantShare Trading Software: New Features in the 3.7.0 Version
QuantShare Trading Software: New Features in the 3.4.2 Version









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.