Jump to content
Medved Trader Forums
Marty

5 Green Bars in the last 5

Recommended Posts

any 3 of the last 5?  assuming you are using Advanced Mode, just do
if (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

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
public void MainCalculation()
{
    if (this.Count(0, 4, Close > Open) > 3)
       
        {
        
         SetColor(002525);
    }

}

 
Edited by Marty

Share this post


Link to post
Share on other sites

public void MainCalculation()
{
    if (this.Count(0, 4, Close > Open) > 3)
     
     {
        
         SetColor(002525);
    }

}

Share this post


Link to post
Share on other sites

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 by Marty

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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);
 }
}

Share this post


Link to post
Share on other sites

note that you are checking [1] candle twice.

if ((Close[2] - Open[2]) + (Close[1] - Open[1]) + (Close[1] - Open[1]) > GetPaintbarParameter("AMOUNT")

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites
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##"));
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...