Jump to content
Medved Trader Forums

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

 
Link to comment
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

Link to comment
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.

Link to comment
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);
 }
}

Link to comment
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##"));
}
Link to comment
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...