Simple Coding Help - No Promise.

dear amit ji,
please help me with this code.It shows same values of resistance and support twice in the right side of the chart.please modify it to show values of resistance and support once for every r/s values. will it be possible to incorporate daily op,hi,lo,cl, vol and previous day hi and low in the second line

_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/8 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorHSB( 42, 42, 42 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxTextOut( IndustryID(1), Status("pxwidth")/2, Status("pxheight")/4 );

GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxSelectFont("Tahoma", Status("pxheight")/36 );
GfxTextOut( "PRASAD RAO", Status("pxwidth")/2, Status("pxheight")/3 );
_SECTION_END();

_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/8 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorHSB( 42, 42, 42 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxTextOut( IndustryID(1), Status("pxwidth")/2, Status("pxheight")/4 );

GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxSelectFont("Tahoma", Status("pxheight")/36 );
GfxTextOut( "PRASAD RAO", Status("pxwidth")/2, Status("pxheight")/3 );
_SECTION_END();

SetBarFillColor=( IIf(O>C,colorDarkRed, colorBrightGreen ) );
Plot( C, "Price", IIf( O>C,colorRed, colorGreen ), styleCandle );

HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );

_SECTION_BEGIN("Resistance");

supres=ParamToggle("Sup_Res","No|Yes",1);
if(supres)
{


Prd1=Param("Res_Period1",2,0,200,1);

test = TEMA ( High , Prd1 ) ;

PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,haHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,haHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,haHigh,2);//PeakValue2

MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak

MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
SD = IIf(DateNum() < LastValue(MPKD,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1", colorBrown,ParamStyle("ResStyle1",styleLine|styleNoTitle,maskAll));

MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
SD2 = IIf(DateNum() < LastValue(MPKD2,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2", colorBrown,ParamStyle("ResStyle2",styleLine|styleNoTitle,maskAll));


MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
SD3 = IIf(DateNum() < LastValue(MPKD3,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3", colorBrown,ParamStyle("ResStyle3",styleLine|styleNoTitle,maskAll));


MPKV4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,4); //MajorPeakValue
MPKD4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),4); //MajorPeakDate
SD4 = IIf(DateNum() < LastValue(MPKD4,lastmode = True ), Null, LastValue(MPKV4,Lastmode = True));//SelectedDate
Plot(SD4, "Resist4", colorBrown,ParamStyle("ResStyle4",styleLine|styleNoTitle,maskAll));



MPKV5 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,5); //MajorPeakValue
MPKD5 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),5); //MajorPeakDate
SD5 = IIf(DateNum() < LastValue(MPKD5,lastmode = True ), Null, LastValue(MPKV5,Lastmode = True));//SelectedDate
Plot(SD5, "Resist5", colorBrown,ParamStyle("ResStyle5",styleLine|styleNoTitle,maskAll));


MPKV6 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,6); //MajorPeakValue
MPKD6 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),6); //MajorPeakDate
SD6 = IIf(DateNum() < LastValue(MPKD6,lastmode = True ), Null, LastValue(MPKV6,Lastmode = True));//SelectedDate
Plot(SD6, "Resist6", colorBrown ,ParamStyle("ResStyle6",styleLine|styleNoTitle,maskAll));




_SECTION_END();


_SECTION_BEGIN("Support");
//SP=L > Ref(L,-1) AND Ref(L,1) < L;//Peak

Prd2=Param("Sup_Period1",2,0,200,1);

test2 = TEMA ( Low , Prd2 ) ;

SP = Ref(test2,1) > Low AND test2 < Ref(test2,-1);//Peak
SPV0 = ValueWhen(SP,haLow,0);//PeakValue0
SPV1 = ValueWhen(SP,haLow,1);//PeakValue1
SPV2 = ValueWhen(SP,haLow,2);//PeakValue2

//PKV5 = ValueWhen(PK,haHigh,5);//PeakValue5
//PKV6 = ValueWhen(PK,haHigh,6);//PeakValue6

MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak

MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
SD = IIf(DateNum() < LastValue(MSPD,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1", colorPlum,ParamStyle("SupportLine1",styleLine|styleNoTitle,maskAll));



MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
SD2 = IIf(DateNum() < LastValue(MSPD2,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2", colorPlum,ParamStyle("SupportLine2",styleLine|styleNoTitle,maskAll));



MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
SD3 = IIf(DateNum() < LastValue(MSPD3,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3", colorPlum,ParamStyle("SupportLine3",styleLine|styleNoTitle,maskAll));


MSPV4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,4);
MSPD4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),4);
SD4 = IIf(DateNum() < LastValue(MSPD4,lastmode = True ), Null, LastValue(MSPV4,Lastmode = True));
Plot(SD4,"Support4", colorPlum,ParamStyle("SupportLine4",styleLine|styleNoTitle,maskAll));


MSPV5 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,5);
MSPD5 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),5);
SD5 = IIf(DateNum() < LastValue(MSPD5,lastmode = True ), Null, LastValue(MSPV5,Lastmode = True));
Plot(SD5,"Support5", colorPlum,ParamStyle("SupportLine5",styleLine|styleNoTitle,maskAll));


MSPV6 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,6);
MSPD6 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),6);
SD6 = IIf(DateNum() < LastValue(MSPD6,lastmode = True ), Null, LastValue(MSPV6,Lastmode = True));
Plot(SD6,"Support6", colorPlum,ParamStyle("SupportLine6",styleLine|stylehidden|styleNoTitle,maskAll));

}

_SECTION_END();

Plot( C, "Price", IIf( O>C,colorRed, colorGreen ), styleCandle );

HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );

_SECTION_BEGIN("Resistance");

supres=ParamToggle("Sup_Res","No|Yes",1);
if(supres)
{


Prd1=Param("Res_Period1",2,0,200,1);

test = TEMA ( High , Prd1 ) ;

PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,haHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,haHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,haHigh,2);//PeakValue2

MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak

MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
SD = IIf(DateNum() < LastValue(MPKD,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1", colorBrown,ParamStyle("ResStyle1",styleLine|styleNoTitle,maskAll));

MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
SD2 = IIf(DateNum() < LastValue(MPKD2,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2", colorBrown,ParamStyle("ResStyle2",styleLine|styleNoTitle,maskAll));


MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
SD3 = IIf(DateNum() < LastValue(MPKD3,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3", colorBrown,ParamStyle("ResStyle3",styleLine|styleNoTitle,maskAll));


MPKV4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,4); //MajorPeakValue
MPKD4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),4); //MajorPeakDate
SD4 = IIf(DateNum() < LastValue(MPKD4,lastmode = True ), Null, LastValue(MPKV4,Lastmode = True));//SelectedDate
Plot(SD4, "Resist4", colorBrown,ParamStyle("ResStyle4",styleLine|styleNoTitle,maskAll));



MPKV5 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,5); //MajorPeakValue
MPKD5 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),5); //MajorPeakDate
SD5 = IIf(DateNum() < LastValue(MPKD5,lastmode = True ), Null, LastValue(MPKV5,Lastmode = True));//SelectedDate
Plot(SD5, "Resist5", colorBrown,ParamStyle("ResStyle5",styleLine|styleNoTitle,maskAll));


MPKV6 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,6); //MajorPeakValue
MPKD6 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),6); //MajorPeakDate
SD6 = IIf(DateNum() < LastValue(MPKD6,lastmode = True ), Null, LastValue(MPKV6,Lastmode = True));//SelectedDate
Plot(SD6, "Resist6", colorBrown ,ParamStyle("ResStyle6",styleLine|styleNoTitle,maskAll));




_SECTION_END();


_SECTION_BEGIN("Support");
//SP=L > Ref(L,-1) AND Ref(L,1) < L;//Peak

Prd2=Param("Sup_Period1",2,0,200,1);

test2 = TEMA ( Low , Prd2 ) ;

SP = Ref(test2,1) > Low AND test2 < Ref(test2,-1);//Peak
SPV0 = ValueWhen(SP,haLow,0);//PeakValue0
SPV1 = ValueWhen(SP,haLow,1);//PeakValue1
SPV2 = ValueWhen(SP,haLow,2);//PeakValue2

//PKV5 = ValueWhen(PK,haHigh,5);//PeakValue5
//PKV6 = ValueWhen(PK,haHigh,6);//PeakValue6

MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak

MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
SD = IIf(DateNum() < LastValue(MSPD,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1", colorPlum,ParamStyle("SupportLine1",styleLine|styleNoTitle,maskAll));



MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
SD2 = IIf(DateNum() < LastValue(MSPD2,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2", colorPlum,ParamStyle("SupportLine2",styleLine|styleNoTitle,maskAll));



MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
SD3 = IIf(DateNum() < LastValue(MSPD3,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3", colorPlum,ParamStyle("SupportLine3",styleLine|styleNoTitle,maskAll));


MSPV4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,4);
MSPD4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),4);
SD4 = IIf(DateNum() < LastValue(MSPD4,lastmode = True ), Null, LastValue(MSPV4,Lastmode = True));
Plot(SD4,"Support4", colorPlum,ParamStyle("SupportLine4",styleLine|styleNoTitle,maskAll));


MSPV5 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,5);
MSPD5 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),5);
SD5 = IIf(DateNum() < LastValue(MSPD5,lastmode = True ), Null, LastValue(MSPV5,Lastmode = True));
Plot(SD5,"Support5", colorPlum,ParamStyle("SupportLine5",styleLine|styleNoTitle,maskAll));


MSPV6 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,6);
MSPD6 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),6);
SD6 = IIf(DateNum() < LastValue(MSPD6,lastmode = True ), Null, LastValue(MSPV6,Lastmode = True));
Plot(SD6,"Support6", colorPlum,ParamStyle("SupportLine6",styleLine|stylehidden|styleNoTitle,maskAll));

}

_SECTION_END();

_SECTION_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorBlueGrey ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram ), 2 );
_SECTION_END();

_SECTION_BEGIN("EMA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
 

amitrandive

Well-Known Member
dear amit ji,
please help me with this code.It shows same values of resistance and support twice in the right side of the chart.please modify it to show values of resistance and support once for every r/s values. will it be possible to incorporate daily op,hi,lo,cl, vol and previous day hi and low in the second line

_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/8 );
GfxSetTextAlign( 6 );// center alignment

Do not use codes which use something you do not understand,it is dangerous and not worth it.

Also use code tags for pasting codes
 
Hi,
I've tried it many times. but it's not showing me anything.
Code:
// http://www.amibroker.com/docs/MTFIndicators.html
// First 'Scan' on 1-minute time frame
// Then click 'Backtest'
// Then right-click result list and choose "Show arrows for actual trades"
// mod. by trash
// http://www.traderji.com/amibroker/90119-simple-coding-help-no-promise-349.html#post1087794

SetOption( "FuturesMode", False );
// etc.
SetPositionSize( 1, spsShares );

// calling stored custom MACD line
// It is dependent on the Symbol is was created with!
nm = Name(); // insert the name of the symbol the composite was created with
x = StaticVarGet( "~MACD" + nm ); //Foreign( "~MACD" + Name(), "C" );
// create buy sell signal
Buy = Cross( x, -0.5 ); // buy when x crosses ABOVE -0.5
Sell = Cross( 0.5, x ); // sell when x crosses BELOW 0.5
Short = Cover = 0;

// create custom MACD composite via Scan
if( Status( "action" ) == actionScan ) {
    Count = 0;
    result = 0;
    for( i = 10; i <= 300; i++ ) {
        TimeFrameSet( i * in1Minute );
        m = MACD( 12, 26 );
        TimeFrameRestore();
        m = IIf( TimeFrameExpand( m, i * in1Minute ) > 0, 1, -1 );
        result += m;
        Count++;
    }

    // storing result to static variable. 
    // It is dependent on the Symbol is was created with!
    StaticVarSet( "~MACD" + Name(), result / Count, persistent = true );
    //AddToComposite( result / Count, "~MACD" + Name(), "X" );
    Buy = 0;
}

// for insertion to separate indicator pane, NOT for price pane! 
if( Status( "action" ) == actionIndicator ) {
    // plot stored MTMACD
    Plot( x, "MTMACD", colorBlue, styleThick );

    // two grid lines
    PlotGrid( 0.5, colorRed );
    PlotGrid( -0.5, colorGreen );

    // removing excessive signals in indicator pane
    Buy = ExRem( Buy, Sell );
    Sell = ExRem( Sell, Buy );
    Short = ExRem( Short, Cover );
    Cover = ExRem( Cover, Short );

    // plotting buy and sell shapes
    PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow,
                IIf( Buy, colorGreen, colorRed ), layer = 0,
                y = x, dist = -12 );
    PlotShapes( Buy * shapeHollowUpArrow + Sell * shapeHollowDownArrow,
                colorLightGrey, layer, y, dist );
}
screenshots:
http://i.imgur.com/5yY9SDC.png

http://i.imgur.com/6v52GQr.png

If it's working for you.. Please show me with screenshot. so, i'll come to know, what am i doing wrong?

Thanks
 

trash

Well-Known Member
Hi,
I've tried it many times. but it's not showing me anything.
Code:
// http://www.amibroker.com/docs/MTFIndicators.html
// First 'Scan' on 1-minute time frame
// Then click 'Backtest'
// Then right-click result list and choose "Show arrows for actual trades"
// mod. by trash
// http://www.traderji.com/amibroker/90119-simple-coding-help-no-promise-349.html#post1087794

SetOption( "FuturesMode", False );
// etc.
SetPositionSize( 1, spsShares );

// calling stored custom MACD line
// It is dependent on the Symbol is was created with!
nm = Name(); // insert the name of the symbol the composite was created with
x = StaticVarGet( "~MACD" + nm ); //Foreign( "~MACD" + Name(), "C" );
// create buy sell signal
Buy = Cross( x, -0.5 ); // buy when x crosses ABOVE -0.5
Sell = Cross( 0.5, x ); // sell when x crosses BELOW 0.5
Short = Cover = 0;

// create custom MACD composite via Scan
if( Status( "action" ) == actionScan ) {
    Count = 0;
    result = 0;
    for( i = 10; i <= 300; i++ ) {
        TimeFrameSet( i * in1Minute );
        m = MACD( 12, 26 );
        TimeFrameRestore();
        m = IIf( TimeFrameExpand( m, i * in1Minute ) > 0, 1, -1 );
        result += m;
        Count++;
    }

    // storing result to static variable. 
    // It is dependent on the Symbol is was created with!
    StaticVarSet( "~MACD" + Name(), result / Count, persistent = true );
    //AddToComposite( result / Count, "~MACD" + Name(), "X" );
    Buy = 0;
}

// for insertion to separate indicator pane, NOT for price pane! 
if( Status( "action" ) == actionIndicator ) {
    // plot stored MTMACD
    Plot( x, "MTMACD", colorBlue, styleThick );

    // two grid lines
    PlotGrid( 0.5, colorRed );
    PlotGrid( -0.5, colorGreen );

    // removing excessive signals in indicator pane
    Buy = ExRem( Buy, Sell );
    Sell = ExRem( Sell, Buy );
    Short = ExRem( Short, Cover );
    Cover = ExRem( Cover, Short );

    // plotting buy and sell shapes
    PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow,
                IIf( Buy, colorGreen, colorRed ), layer = 0,
                y = x, dist = -12 );
    PlotShapes( Buy * shapeHollowUpArrow + Sell * shapeHollowDownArrow,
                colorLightGrey, layer, y, dist );
}
screenshots:
http://i.imgur.com/5yY9SDC.png

http://i.imgur.com/6v52GQr.png

If it's working for you.. Please show me with screenshot. so, i'll come to know, what am i doing wrong?

Thanks
So what do I get from you in exchange if you want me to spoon feed you like a nanny showing you that it actually works in a video?

If you hire a nanny then she won't come to you just like that too.
She expects something in exchange too if she has to spend (extra-)time with little kids not being prepared for hard life yet. The same it is here.

Alternative way is figuring out how it works and what the working code is doing yourself.
 
Hi Friends,

I need realtime exploration for different timeframe. I think it only explores for daily TF.

Thanks a lot

Code:
_SECTION_BEGIN("Trend");

SetChartBkGradientFill( ParamColor( "TopColor", ColorRGB( 217, 197, 137 ) ), ParamColor( "BottomColor", ColorRGB( 254, 244, 224 ) ) );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));


SetChartOptions(0, chartShowDates | chartWrapTitle);
Plot(C,"",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
kk = Optimize( "mult", Param( "mult", 6.75, 1, 6, 0.25 ), 1, 2, 0.25 );
Per = Optimize( "period", Param( "period", 10, 5, 50, 1 ), 5, 50, 1 );
sdfact = Param( "Standard Deviation Factor", 2, 0.5, 5, 0.1 );
offset = Param( "Offset", 2, 1, 50, 1 );
tc = ParamList( "Channel Display", List = "No Channel|Channel|ChannelRT|Both
Channels", 1 );
ms = ParamToggle( "Trend", "Regular|Smoothed", 1 );

x = Cum( 1 );
HaClose = ( O + H + L + C ) / 4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );

if ( ms == 0 )
{
nm = ( H - L );
j = ( O + H + L + C ) / 4;
}
else
{
nm = ( HaHigh - HaLow );
j = ( HaOpen + HaHigh + HaLow + HaClose ) / 4;
}

rfsctor = WMA( nm, Per );

revers = kk * rfsctor;
Trend = 1;
NW[0] = 0;

for ( i = 1;i < BarCount;i++ )
{
if ( Trend[i-1] == 1 )
{
if ( j[i] < NW[i-1] )
{
Trend[i] = -1;
NW[i] = j[i] + Revers[i];
}
else
{
Trend[i] = 1;

if ( ( j[i] - Revers[i] ) > NW[i-1] )
{
NW[i] = j[i] - Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}

if ( Trend[i-1] == -1 )
{
if ( j[i] > NW[i-1] )
{
Trend[i] = 1;
NW[i] = j[i] - Revers[i];
}
else
{
Trend[i] = -1;

if ( ( j[i] + Revers[i] ) < NW[i-1] )
{
NW[i] = j[i] + Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
}

cp = ( H + L ) / 2;

Plot( IIf( NW < j, NW, Null ), "\ntrailLong", ParamColor( "ColorTrailLong",
colorBlue ), styleStaircase | styleDots );
Plot( IIf( NW > j, NW, Null ), "\ntrailShort", ParamColor( "ColorTrailShort",
colorRed ), styleStaircase | styleDots );

Buy = NW < j;
Short = NW > j;

Buy = ExRem(Buy, Short);
Short = ExRem(Short, Buy);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBlue, 0,NW);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0,NW);

_SECTION_END();
 

amitrandive

Well-Known Member
Hi Friends,

I need realtime exploration for different timeframe. I think it only explores for daily TF.

Thanks a lot

Code:
_SECTION_BEGIN("Trend");

SetChartBkGradientFill( ParamColor( "TopColor", ColorRGB( 217, 197, 137 ) ), ParamColor( "BottomColor", ColorRGB( 254, 244, 224 ) ) );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));


SetChartOptions(0, chartShowDates | chartWrapTitle);
Plot(C,"",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
kk = Optimize( "mult", Param( "mult", 6.75, 1, 6, 0.25 ), 1, 2, 0.25 );
Per = Optimize( "period", Param( "period", 10, 5, 50, 1 ), 5, 50, 1 );
sdfact = Param( "Standard Deviation Factor", 2, 0.5, 5, 0.1 );
offset = Param( "Offset", 2, 1, 50, 1 );
tc = ParamList( "Channel Display", List = "No Channel|Channel|ChannelRT|Both
Channels", 1 );
ms = ParamToggle( "Trend", "Regular|Smoothed", 1 );

x = Cum( 1 );
HaClose = ( O + H + L + C ) / 4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );

if ( ms == 0 )
{
nm = ( H - L );
j = ( O + H + L + C ) / 4;
}
else
{
nm = ( HaHigh - HaLow );
j = ( HaOpen + HaHigh + HaLow + HaClose ) / 4;
}

rfsctor = WMA( nm, Per );

revers = kk * rfsctor;
Trend = 1;
NW[0] = 0;

for ( i = 1;i < BarCount;i++ )
{
if ( Trend[i-1] == 1 )
{
if ( j[i] < NW[i-1] )
{
Trend[i] = -1;
NW[i] = j[i] + Revers[i];
}
else
{
Trend[i] = 1;

if ( ( j[i] - Revers[i] ) > NW[i-1] )
{
NW[i] = j[i] - Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}

if ( Trend[i-1] == -1 )
{
if ( j[i] > NW[i-1] )
{
Trend[i] = 1;
NW[i] = j[i] - Revers[i];
}
else
{
Trend[i] = -1;

if ( ( j[i] + Revers[i] ) < NW[i-1] )
{
NW[i] = j[i] + Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
}

cp = ( H + L ) / 2;

Plot( IIf( NW < j, NW, Null ), "\ntrailLong", ParamColor( "ColorTrailLong",
colorBlue ), styleStaircase | styleDots );
Plot( IIf( NW > j, NW, Null ), "\ntrailShort", ParamColor( "ColorTrailShort",
colorRed ), styleStaircase | styleDots );

Buy = NW < j;
Short = NW > j;

Buy = ExRem(Buy, Short);
Short = ExRem(Short, Buy);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBlue, 0,NW);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0,NW);

_SECTION_END();
Exploration is not coded in AFL
Use scan , and it works on any time frame.

Image shows scans for 5 minute time frame.

 

Nehal_s143

Well-Known Member
below afl is Plotting 2 Lines as band, I want to Plot Only 1 Line,
please Help me to write if Condition, i dont know How to use if OR else Coding

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

//Price Band
Typ=(H+L+C)/3;
GMCKS=EMA(Typ,5);
MA2=LinearReg(GMCKS,14);


Prd1=5;
Prd2=10;
TB= HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
BB= LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
CL=BB+(TB-BB)/2;
CLD=((TB-BB)/3)/1.5;
TLINE=CL+CLD;
BLINE=CL-CLD;
Plot(TLINE, "",colorCustom1,styleStaircase,styleDashed);
Plot(BLINE, "",colorCustom1,styleStaircase,styleDashed);

// if C>TLINE Plot BLINE
// if C<BLINE Plot TLINE

//afl is Plotting 2 Lines, I  want to Plot Only 1 Line,
//please Help me to write if Condition, i dont know How to use if OR else Coding

_SECTION_END();
 
No need to learn if for such simple stuff as of now; :rofl:

This requirement can be fulfilled by if's country cousin IIf. Since it is possible that C may not be greater than TLINE and also not less than BLINE, I've instructed Amibroker to Plot Null for such scenarios.

Code:
Plot(
IIF(C>TLINE, BLINE, IIf(C<BLINE, TLINE, NULL))
, "",colorCustom1,styleStaircase,styleDashed);
 
No need to learn if for such simple stuff as of now; :rofl:

This requirement can be fulfilled by if's country cousin IIf. Since it is possible that C may not be greater than TLINE and also not less than BLINE, I've instructed Amibroker to Plot Null for such scenarios.

Code:
Plot(
IIF(C>TLINE, BLINE, IIf(C<BLINE, TLINE, NULL))
, "",colorCustom1,styleStaircase,styleDashed);

Nehal

My PM box at traderji was showing full so in order to see your new message, I tried to empty it but that also deleted unread message of yours. Kindly repeat it here. If it is regarding the earlier if vs IIF, repeat it here only.
 

Similar threads