NexusFi: Find Your Edge


Home Menu

 





Need Help w/ PaintBar Code


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,038 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 
ChrisMoody's Avatar
 ChrisMoody 
Chapel Hill, NC
 
Experience: Advanced
Platform: Trade Navigator, MultiCharts, TOS
Broker: Stage 5, FXCM, IQ Feed
Trading: Futures, Forex, Options
Posts: 12 since Aug 2011
Thanks Given: 22
Thanks Received: 3

Hello...Need someones Expertise.

I've coded several PaintBar indicators in MultiCharts. However, I'm running in to a problem with this code. The issue is the PaintBar colors ONLY 2 Bars after the condition = True on the second bar. Currently the code is painting every bar that meets the condition. Obviously I'm not coding the condition correctly.

See Screenshot for Visual which has the Rules that my code obviously isn't defining the rules correctly. I've never had to write code that only #1 PaintsBars Two Bars when the condition is true for current bar and bar[1]. #2 Only Paints 2 Bars when condition is True and no Additional bars until the condition becomes False....Then it should start over and paint the next two consecutive bars when the condition is true again.

Rule: If Low and Low[1] > than SMA Then PlotPaintBar for only those 2 Bars. The condition can't be True again until the Low of a bar is <= the SMA....after that the condition/Rule bocomes Valid again to plot the PaintBars if Two bars meet the criteria.

Code is Below....I took out a few conditions to keep code simple and I couldn't remember if the TRH and TRL needed to stay in...

 
Code
Inputs:
       UpColor2B(Green);
      
variables:
       MacH(0),
       TRH(0),
       TRL(0);
   
//MacH = SMA( Close, 10) ;
MacH = AverageFC( Close, 10) ;

TRH = maxlist( close[1], high);
TRL = minlist( close[1], Low);
      
condition1 = Low > MacH ;

if condition1 then
       begin
       PlotPaintBar(High, Low, Open, Close, "2BarUp", UpColor2B);
       //PlotPaintBar(High[1], Low[1], Open[1], Close[1], "2BarUp", UpColor2B);
       //PlotPaintBar(High, Low, Open, Close, "2BarUp", UpColor2B);
       Alert ;
       End ;

Thanks SOO Much for Your Help!!!


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
$500M Riding on World Cup 2026: France/Spain Co-Favored …
Prediction Markets & Event Contracts
Warsh Rate Hike at 40%, Iran June 15 Expires Tonight at …
Prediction Markets & Event Contracts
I Have a Thing Called Iran -- Trump Stays in DC as Airsp …
Prediction Markets & Event Contracts
 
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643


ChrisMoody,

you need to check for the number of bars you allow to plot. In your code you could start a counter when Condition1 is true and as long as the counter <= 2 (or any other input) the paintbars are allowed to plot.
When Condition1 = false you set the counter back to 0.

 
Code
Inputs:
       UpColor2B(Green),
       BarsToPlot(2);
      
variables:
	Counter(0),
       MacH(0),
       TRH(0),
       TRL(0);
   
//MacH = SMA( Close, 10) ;
MacH = AverageFC( Close, 10) ;

TRH = maxlist( close[1], high);
TRL = minlist( close[1], Low);
      
condition1 = Low > MacH ;

if condition1 = false then
	Counter = 0;

if condition1 then 
	Counter += 1;
	
if Counter > 0 and Counter <= BarsToPlot then
       begin
       PlotPaintBar(High, Low, Open, Close, "2BarUp", UpColor2B);
       //PlotPaintBar(High[1], Low[1], Open[1], Close[1], "2BarUp", UpColor2B);
       //PlotPaintBar(High, Low, Open, Close, "2BarUp", UpColor2B);
       Alert ;
       End ;
Regards,
ABCTG


ChrisMoody View Post
Hello...Need someones Expertise.

I've coded several PaintBar indicators in MultiCharts. However, I'm running in to a problem with this code. The issue is the PaintBar colors ONLY 2 Bars after the condition = True on the second bar. Currently the code is painting every bar that meets the condition. Obviously I'm not coding the condition correctly.

See Screenshot for Visual which has the Rules that my code obviously isn't defining the rules correctly. I've never had to write code that only #1 PaintsBars Two Bars when the condition is true for current bar and bar[1]. #2 Only Paints 2 Bars when condition is True and no Additional bars until the condition becomes False....Then it should start over and paint the next two consecutive bars when the condition is true again.

Rule: If Low and Low[1] > than SMA Then PlotPaintBar for only those 2 Bars. The condition can't be True again until the Low of a bar is <= the SMA....after that the condition/Rule bocomes Valid again to plot the PaintBars if Two bars meet the criteria.

Code is Below....I took out a few conditions to keep code simple and I couldn't remember if the TRH and TRL needed to stay in...

 
Code
Inputs:
       UpColor2B(Green);
      
variables:
       MacH(0),
       TRH(0),
       TRL(0);
   
//MacH = SMA( Close, 10) ;
MacH = AverageFC( Close, 10) ;

TRH = maxlist( close[1], high);
TRL = minlist( close[1], Low);
      
condition1 = Low > MacH ;

if condition1 then
       begin
       PlotPaintBar(High, Low, Open, Close, "2BarUp", UpColor2B);
       //PlotPaintBar(High[1], Low[1], Open[1], Close[1], "2BarUp", UpColor2B);
       //PlotPaintBar(High, Low, Open, Close, "2BarUp", UpColor2B);
       Alert ;
       End ;

Thanks SOO Much for Your Help!!!



Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
 
ChrisMoody's Avatar
 ChrisMoody 
Chapel Hill, NC
 
Experience: Advanced
Platform: Trade Navigator, MultiCharts, TOS
Broker: Stage 5, FXCM, IQ Feed
Trading: Futures, Forex, Options
Posts: 12 since Aug 2011
Thanks Given: 22
Thanks Received: 3


Quoting 
you need to check for the number of bars you allow to plot. In your code you could start a counter when Condition1 is true and as long as the counter <= 2 (or any other input) the paintbars are allowed to plot.
When Condition1 = false you set the counter back to 0.

ABCTG,

Thank You....Greatly Appreciate it...


Started this thread Reply With Quote




Last Updated on May 7, 2014


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts