Click here to Login





                                                   Help with a Red/Green positive/negative hatched graph?

  1

0
Josh McCormick
2020-07-03 15:38:13


I'm wanting to create a filled hatch graph (with a black outline and zero line) where everything above zero is filled in green and everything below zero is filled in red. I figured out some code that worked perfectly.... except for where they meet in the middle. There is some sloppy overspray. Is there a better way to do what I want? And please, forgive my code. This is my third day with the product:

EXAMPLE IMAGE -------------------------
https://i.imgur.com/KzrkxXX.png

MY CODE -----------------------------------
// Pull Enhanced SRM Data (in beta - to be published) based upon a 50 period lookback
a = Srme(50);

// Plot the top half of the graph in a nice green hatched pattern (positive numbers)
Plot((a>0)*a, "Bulls Only", colorGreen|108, ChartLine, StyleWidth2);
SetHatchBrush("Percent20", colorWhite|255|colorMintCream|255|161);

// Plot the bottom half of the graph in a nice red hatched pattern (positive numbers)
Plot((a<0)*a, "Bears Only" , colorRed|108, ChartLine, StyleWidth2);
SetHatchBrush("Percent20", colorWhite|255|colorMintCream|255|161);

// Plot a solid black outline around the edge of the graph.
Plot(a, "SRME", colorBlack, ChartLine, StyleWidth3);

// Plot a black zero line to clearly divide the positive/negative boundary.
Plot (0, "", colorBlack, ChartLine, StyleWidth2);

Where it fails is when a number crosses the zero line, and I know that it's because I'm calling two different graph functions. But I haven't been able to find a way to create a bi-colored (and hatched) positive/negative graph. Hopefully there's some cool command I'm missing?
PS: Try this out on your own positive/negative indicator. It's an attractive plot, IMHO. It just needs a few touch-ups.

HELP? :)



QuantShare
2020-07-05 13:23:47

  1

Best Answer
Unfortunately, I do not see another way to do this as we do not have a built-in function for that.
Note this is happening because when the line drops below 0, instead of drawing say 2, -2 line, you are drawing 2, 0 line.



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
Long Term Up Trend with Short term re-entery Signals
Update the Stock Exchange Associated With U.S. Stocks - Market Fi...
Stock Correlation with its Industry - Change over time
Design and backtest a trading system with two strategies
Double / Triple Smoothened EMA with Flexible Alpha

How-to Lessons
How to use QuantShare with Metastock data
How to create a hatched area in a chart
How to associate an index with a list of stocks
How to create a chart with a black background
How to screen for stocks having a high correlation with the Dow J...

Related Forum Threads
Help With Daily Data Import Script
Need help with a MM Script
Help with Quantshare Language
Help with Survivorship Bias Free DB
Help with the following trading system

Blog Posts
Working with the formula editor
How to deal with StockTwits data
Create Realtime Quote Sheets with the Watchlist Tool
How to Backtest an Intraday Stock Trading System with EOD Ranking
How to Optimize a Trading System with Thousands of Billions of Co...









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 2020 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.