Exploration atr supertrend Need help

Need help for exploration atr
price cross up atr10 multiplier 3
price cross up atr 20 multiplier 5
price cross up atr 100 multiplier 1

Thank you so much.

1 Like

Supertrend Indicator
You can code the exploration yourself.

SetBarsRequired( sbrAll, 0 );
RequestTimedRefresh( 1, False );
Setchartoptions( 0, Chartshowarrows | chartShowDates );
Plot( C, "Close", colorDefault, styleNoTitle | GetPriceStyle() );

function SuperTrend( ATR_Value, ATR_Multi )
{
    High_Price = High;
    Low_Price = Low;
    Close_Price = Close;

    Up = ( High_Price + Low_Price ) / 2 + ( ATR_Multi * ATR_Value );
    Dn = ( High_Price + Low_Price ) / 2 - ( ATR_Multi * ATR_Value );

    TrendUp = TrendDown = Null;
    Trend[0] = 1;
    changeOfTrend = flag = flagh = sig = bars = 0;

    Super_Trend = Null;

    for( i = 1; i < BarCount; i++ )
    {
        TrendUp[i] = TrendDown[i] = Null;
        Trend[i] = 1;

        if( Close_Price[i] > Up[i - 1] )
        {
            Trend[i] = 1;

            if( Trend[i - 1] == -1 )
            {
                changeOfTrend = 1;
            }
        }
        else
            if( Close_Price[i] < Dn[i - 1] )
            {
                Trend[i] = -1;

                if( Trend[i - 1] == 1 )
                {
                    changeOfTrend = 1;
                }
            }
            else
                if( Trend[i - 1] == 1 )
                {
                    Trend[i] = 1;
                    changeOfTrend = 0;
                }
                else
                    if( Trend[i - 1] == -1 )
                    {
                        Trend[i] = -1;
                        changeOfTrend = 0;
                    }

        if( Trend[i] < 0 && Trend[i - 1] > 0 )
        {
            flag = 1;
        }
        else
        {
            flag = 0;
        }

        if( Trend[i] > 0 && Trend[i - 1] < 0 )
        {
            flagh = 1;
        }
        else
        {
            flagh = 0;
        }

        if( Trend[i] > 0 && Dn[i] < Dn[i - 1] )
        {
            Dn[i] = Dn[i - 1];
        }

        if( Trend[i] < 0 && Up[i] > Up[i - 1] )
        {
            Up[i] = Up[i - 1];
        }

        if( flag == 1 )
        {
            Up[i] = ( High_Price[i] + Low_Price[i] ) / 2 + ( ATR_Multi * ATR_Value[i] );;
        }

        if( flagh == 1 )
        {
            Dn[i] = ( High_Price[i] + Low_Price[i] ) / 2 - ( ATR_Multi * ATR_Value[i] );;
        }

        if( Trend[i] == 1 )
        {
            TrendUp[i] = Dn[i];

            if( changeOfTrend == 1 )
            {
                TrendUp[i - 1] = TrendDown[i - 1];
                changeOfTrend = 0;
            }
        }
        else
            if( Trend[i] == -1 )
            {
                TrendDown[i] = Up[i];

                if( changeOfTrend == 1 )
                {
                    TrendDown[i - 1] = TrendUp[i - 1];
                    changeOfTrend = 0;
                }
            }

        Super_Trend[i] = Max( TrendUp[i], TrendDown[i] );
    }

    return Super_Trend;
}


ATR_Para = Param( "SuperTrend Periods", 7, 1, 100, 1 );
ATR_Multi = Param( "SuperTrend Factor", 3, 1, 50, 1 );


ATR_Value = ATR( ATR_Para );
SuperTrend_Value = SuperTrend( ATR_Value, ATR_Multi );

Buy_SuperTrend = Cross( Close, SuperTrend_Value );
Short_SuperTrend  = Cross( SuperTrend_Value, Close );

Plot( SuperTrend_Value, StrFormat( "\nSuperTrend(%g,%g)", ATR_Multi , ATR_Para ), IIf( SuperTrend_Value > Close, colorRed, colorBrightGreen ), styleLine, Null, Null, 0, 0, 2 );

3 Likes

Yogyatrader
Thank you so much for your, but seem to complicate for me, I have code knowledge very little
Can I do this.
Price cross up art10 multiplier3 = Cross(C, (ATR(10)*3) ,

I try from this code but cannot any stock symbol meet per criteria.
SuperTrend1 = ATR(10) * 3;
Supertrend2 = ATR(20)*5;
SuperTrend3 = ATR(100) * 1;

Buy = Cross(C,SuperTrend3);
Sell = Cross(SuperTrend3,C);

SuperTrend is the name of an indicator, so using that word in your subject line and as a variable name is likely confusing people.

More importantly, you are using ATR (a measure of the amount by which price moves) and the actual Close price. For practical purposes, those two values will never cross.

1 Like

Well, I guess we should get this in here, too.
@Addy, Please follow this advice: How to ask a good question

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.