Marty Posted January 27, 2019 Report Share Posted January 27, 2019 Hi, How would I make a paintbar to indicate 3 green bars in the last 5 bars. Thank you, Marty Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2019 Report Share Posted January 27, 2019 any 3 of the last 5? assuming you are using Advanced Mode, just doif (this.Count(0, 4, Close > Open) > 3){ .....} If you don't want to include the current candle in the count, then just do 1, 5 instead of 0, 4 NOTE: make sure you are using the BETA version: https://medvedtrader.com/beta Quote Link to comment Share on other sites More sharing options...
Marty Posted January 27, 2019 Author Report Share Posted January 27, 2019 Getting an Error on the Chart (small x besides paintbar name) Compile Errors in Paintbar ID: GHTIJIJTLT, "3 G in 5" Compile Error at (15,208): Error# CS1041: Identifier expected; 'this' is a keyword Compile Error at (75,208): Error# CS1002: ; expected Compile Error at (75,208): Error# CS1525: Invalid expression term ')' Compile Error at (76,208): Error# CS1002: ; expected Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2019 Report Share Posted January 27, 2019 please show the full paintbar Quote Link to comment Share on other sites More sharing options...
Marty Posted January 27, 2019 Author Report Share Posted January 27, 2019 (edited) public void MainCalculation() { if (this.Count(0, 4, Close > Open) > 3) { SetColor(002525); } } Edited January 27, 2019 by Marty Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2019 Report Share Posted January 27, 2019 that post is empty Quote Link to comment Share on other sites More sharing options...
Marty Posted January 27, 2019 Author Report Share Posted January 27, 2019 public void MainCalculation() { if (this.Count(0, 4, Close > Open) > 3) { SetColor(002525); } } Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2019 Report Share Posted January 27, 2019 oops, change "this.Count" to be just "Count" Quote Link to comment Share on other sites More sharing options...
Marty Posted January 27, 2019 Author Report Share Posted January 27, 2019 (edited) Thanks, And to activate only during standard market hours(9:30 to 4:00 Eastern Time Zone) would need to add what? Thanks again. Edited January 27, 2019 by Marty Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2019 Report Share Posted January 27, 2019 if doing alerts, you can set that in the alert notification. With just setting the color, it would only show on the paintbar, so why bother? if you don't show ext. hours, it won't show the paintbar. You can do it in the code, but it is a bit of a pain. Quote Link to comment Share on other sites More sharing options...
Marty Posted January 27, 2019 Author Report Share Posted January 27, 2019 Yeah I'm not very experienced in code but it would be helpful to have since many people seem to want to add to their Paintbars. I use this for backtesting. Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2019 Report Share Posted January 27, 2019 BTW, I think your SetColor is probably supposed to be: SetColor(0x002525); or SetColor(0xFF002525); Quote Link to comment Share on other sites More sharing options...
Marty Posted January 27, 2019 Author Report Share Posted January 27, 2019 Was looking at the default Paintbars and noticed that "Def: Unusual Volume" had a small spelling error. public void MainCalculation() { DefinePaintbarParameter("VOLPERCENTUP", "Percent Up", false, 1, 10000, 1, 50); DefinePaintbarParameter("MINVOL", "Minimum Bar Vol", true, 0, 1000000000000, 1000, 1000); DefinePaintbarParameter("MINXPRICE", "Min Price", false, 0.0001, 10000, 0.1, 5); DefinePaintbarParameter("MAXPRICE", "Max Price", false, 0.0001, 10000, 0.1, 1000); if (Volume_Bar > Volume_EMA * (1 + GetPaintbarParameter("NUMTOCHECK")) && Volume_Bar >= GetPaintbarParameter("MINVOL") && SymbolData.Last >= GetPaintbarParameter("MINPRICE") && SymbolData.Last <= GetPaintbarParameter("MAXPRICE")) { SetColorAndShape("Vol Up", PBShape.ArrowUp_Hollow, SysColor.VolumeUp); TriggerAlert("Vol Up"); SetScanResult(100); } } I think "DefinePaintbarParameter("MINXPRICE", "Min Price", false, 0.0001, 10000, 0.1, 5);" should be "MINPRICE" Thanks again for your help Now working on Having a 1% change in the last 5 candles. Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2019 Report Share Posted January 27, 2019 thanks. Yes, was a typo Quote Link to comment Share on other sites More sharing options...
Marty Posted January 27, 2019 Author Report Share Posted January 27, 2019 Doing the following but seems that negative numbers are being seen as positive ones. Ex. -0.02 + 0.05 + -0.01 = 0.02 but in my formual it is being calculated as 0.08 public void MainCalculation() { DefinePaintbarParameter("AMOUNT", "Change in Cents", false, 0.01, 1000, 0.01, .01); if ((Close[2] - Open[2]) + (Close[1] - Open[1]) + (Close[1] - Open[1]) > GetPaintbarParameter("AMOUNT") && Close[2] < Open[2] ) { SetColor("Color",0xFF82FF4E); } } Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2019 Report Share Posted January 27, 2019 how exactly are you seeing it evaluated to 0.08? Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 28, 2019 Report Share Posted January 28, 2019 note that you are checking [1] candle twice. if ((Close[2] - Open[2]) + (Close[1] - Open[1]) + (Close[1] - Open[1]) > GetPaintbarParameter("AMOUNT") Quote Link to comment Share on other sites More sharing options...
Marty Posted January 28, 2019 Author Report Share Posted January 28, 2019 On my chart I see the paintbar appear and disappear when I go up and down in .01 increments and I see it is calculating negative numbers as positive. Oops that must be it, time to stop for the day, getting tired Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 28, 2019 Report Share Posted January 28, 2019 1) you can make it less error prone and easier to read by using the SUM function: Sum(3, Close - Open) > GetPaintbarParameter("AMOUNT") 2) you can set the Scan Result to show the result of that sum function unconditionally. That way you can see what MT is totaling for the last 3 candles for the symbols in the portfolio if you run the scan (turn OFF the filtering) public void MainCalculation() { DefinePaintbarParameter("AMOUNT", "Change in Cents", false, 0.01, 1000, 0.01, .01); if ( Sum(3, Close - Open) > GetPaintbarParameter("AMOUNT") && Close[2] < Open[2] ) { SetColor("Color",0xFF82FF4E); } SetScanResult(Sum(3, Close - Open).ToString("#,###.00##")); } Quote Link to comment Share on other sites More sharing options...
Marty Posted January 28, 2019 Author Report Share Posted January 28, 2019 Wow, yes this is great. Thank you so much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.