Simple Coding Help - No Promise.

Romeo1998

Well-Known Member
added semi colon at the end , now working :)

one last thing bro can you please add custom time frame also , so that all we could chose any time frame instead of fixed
custom timeframe option is already there, change the parameter PERIODS, u can adjust all the periods for all the timeframes :happy: just right click on chart n see in parameters :happy:

while copying n pasting, i might have missed the semicolon :D
 

toocool

Well-Known Member
custom timeframe option is already there, change the parameter PERIODS, u can adjust all the periods for all the timeframes :happy: just right click on chart n see in parameters :happy:

while copying n pasting, i might have missed the semicolon :D
what i mean is what if we need all emas with 15 minute time frame as base ?

instead of 5 and hourly and 2 hourly and 4 hourly ??
 

Romeo1998

Well-Known Member
what i mean is what if we need all emas with 15 minute time frame as base ?

instead of 5 and hourly and 2 hourly and 4 hourly ??
ok, here it is :)

Code:
SetChartOptions( 0, chartWrapTitle | chartShowArrows | chartShowDates, 0 );
_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_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

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

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

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

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

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

Romeo1998

Well-Known Member
Hi,
Can somebody write an AFL to plot only the opening candle and volume of past days on certain timeframe? I.e. AFL would give all opening 3 min or 5 min or 15 min candles with their volume.

Thank you.
Dear friend,
use this code :)
Code:
//plot candles only from 9:15 am to 9:30 am :)
tn=TimeNum();
tnn=tn>=91500 AND tn<=93000;
Price = IIf( tnn, Close, Null );
SetChartOptions(0,chartShowArrows|chartShowDates,0);
_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( Price, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
use these two codes in different panes :happy:
Code:
//plot volume only from 9:15 am to 9:30 am :)
tn=TimeNum();
tnn=tn>=91500 AND tn<=93000;
VV = IIf( tnn, V, Null );
VV = IIf( tnn, V, Null );
SetChartOptions(0,chartShowArrows|chartShowDates,0);
Plot( VV, _DEFAULT_NAME(), ParamColor("Color", colorBlueGrey ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram  ) );
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

toocool

Well-Known Member
ok, here it is :)

Code:
SetChartOptions( 0, chartWrapTitle | chartShowArrows | chartShowDates, 0 );
_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_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

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

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

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

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

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

it has period of ema but not higher time frame selection

 

Romeo1998

Well-Known Member
no bro

it has period of ema but not higher time frame selection

ok, use this code, its a combination of both the above codes

now u can use same timeframe ema with different values OR different timeframe ema with same values OR both ^_^

u can toggle these two options from parameter

Code:
Same_timeframe_but_diff_values = ParamToggle("Ema with same TF but diff values","Yes|No",1);
Diff_timeframe_but_same_values = ParamToggle("Diff_timeframe_but_same_values","Yes|No",0);

SetChartOptions(0,chartShowArrows|chartShowDates,0);
_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() );
if (Diff_timeframe_but_same_values==1)
{



_SECTION_BEGIN("EMA 5 MIN");
EM5=ParamToggle("EMA5","Off|On",1);
 
if(EM5)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in5Minute);
m5= EMA(Close,p) ;
Plot(TimeFrameExpand(m5, in5Minute), "", ParamColor( "5 Min Color", colorRed ), styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 15 MIN");
EM15=ParamToggle("EMA15","Off|On",1);

if(EM15)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in15Minute);
m15= EMA(Close,p) ;
Plot(TimeFrameExpand(m15, in15Minute), "", ParamColor( "15 Min Color", colorBlue ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA Hourly");
EMH=ParamToggle("EMAH","Off|On",1);

if(EMH)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly);
mH= EMA(Close,p) ;
Plot(TimeFrameExpand(mH, inHourly), "", ParamColor( "Hourly Color", colorGreen ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 2Hourly");
EM2H=ParamToggle("EMA2H","Off|On",1);

if(EM2H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*2);
m2H= EMA(Close,p) ;
Plot(TimeFrameExpand(m2H, inHourly*2), "", ParamColor( "2Hour Color", colorYellow ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 4Hourly");
EM4H=ParamToggle("EMA4H","Off|On",1);

if(EM4H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*4);
m4H= EMA(Close,p) ;
Plot(TimeFrameExpand(m4H, inHourly*4), "", ParamColor( "4Hour Color", colorOrange ),styleStaircase|styleThick);
TimeFrameRestore();
}
_SECTION_END();


}


if(Same_timeframe_but_diff_values==1)
{

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

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

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

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

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

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

Romeo1998

Well-Known Member
use this code :happy: modified lil bit :D
now working fine

Code:
Same_timeframe_but_diff_values = ParamToggle("Ema with same TF but diff values","Yes|No",1);
Diff_timeframe_but_same_values = ParamToggle("Diff_timeframe_but_same_values","Yes|No",1);

SetChartOptions(0,chartShowArrows|chartShowDates,0);
_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() );


if (Diff_timeframe_but_same_values==1)
{

_SECTION_BEGIN("EMA 5 MIN");
EM5=ParamToggle("EMA5","Off|On",1);
 
if(EM5)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in5Minute);
m5= EMA(Close,p) ;
Plot(TimeFrameExpand(m5, in5Minute), "", ParamColor( "5 Min Color", colorRed ), styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 15 MIN");
EM15=ParamToggle("EMA15","Off|On",1);

if(EM15)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in15Minute);
m15= EMA(Close,p) ;
Plot(TimeFrameExpand(m15, in15Minute), "", ParamColor( "15 Min Color", colorBlue ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA Hourly");
EMH=ParamToggle("EMAH","Off|On",1);

if(EMH)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly);
mH= EMA(Close,p) ;
Plot(TimeFrameExpand(mH, inHourly), "", ParamColor( "Hourly Color", colorGreen ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 2Hourly");
EM2H=ParamToggle("EMA2H","Off|On",1);

if(EM2H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*2);
m2H= EMA(Close,p) ;
Plot(TimeFrameExpand(m2H, inHourly*2), "", ParamColor( "2Hour Color", colorYellow ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 4Hourly");
EM4H=ParamToggle("EMA4H","Off|On",1);

if(EM4H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*4);
m4H= EMA(Close,p) ;
Plot(TimeFrameExpand(m4H, inHourly*4), "", ParamColor( "4Hour Color", colorOrange ),styleStaircase|styleThick);
TimeFrameRestore();
}
_SECTION_END();


}


if(Same_timeframe_but_diff_values==1)
{

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

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

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

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

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

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

toocool

Well-Known Member
use this code :happy: modified lil bit :D
now working fine

Code:
Same_timeframe_but_diff_values = ParamToggle("Ema with same TF but diff values","Yes|No",1);
Diff_timeframe_but_same_values = ParamToggle("Diff_timeframe_but_same_values","Yes|No",1);

SetChartOptions(0,chartShowArrows|chartShowDates,0);
_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() );


if (Diff_timeframe_but_same_values==1)
{

_SECTION_BEGIN("EMA 5 MIN");
EM5=ParamToggle("EMA5","Off|On",1);
 
if(EM5)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in5Minute);
m5= EMA(Close,p) ;
Plot(TimeFrameExpand(m5, in5Minute), "", ParamColor( "5 Min Color", colorRed ), styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 15 MIN");
EM15=ParamToggle("EMA15","Off|On",1);

if(EM15)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in15Minute);
m15= EMA(Close,p) ;
Plot(TimeFrameExpand(m15, in15Minute), "", ParamColor( "15 Min Color", colorBlue ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA Hourly");
EMH=ParamToggle("EMAH","Off|On",1);

if(EMH)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly);
mH= EMA(Close,p) ;
Plot(TimeFrameExpand(mH, inHourly), "", ParamColor( "Hourly Color", colorGreen ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 2Hourly");
EM2H=ParamToggle("EMA2H","Off|On",1);

if(EM2H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*2);
m2H= EMA(Close,p) ;
Plot(TimeFrameExpand(m2H, inHourly*2), "", ParamColor( "2Hour Color", colorYellow ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 4Hourly");
EM4H=ParamToggle("EMA4H","Off|On",1);

if(EM4H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*4);
m4H= EMA(Close,p) ;
Plot(TimeFrameExpand(m4H, inHourly*4), "", ParamColor( "4Hour Color", colorOrange ),styleStaircase|styleThick);
TimeFrameRestore();
}
_SECTION_END();


}


if(Same_timeframe_but_diff_values==1)
{

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

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

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

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

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

_SECTION_BEGIN("EMA6");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
}
appreciate your efforts bro but its not what i was talking about

if we need all 4 ema , with 15 minute base on 1 minute chart .....................say 15 minute 20 period..................15 minute 50 period .................15 minute ................100 period .......................and so on

and wish to change base interval of time period to 30 minute .................or 1 hour (or any other )as per your wish

and chart is put on 1 minute time frame ........thats what i am talking about
 

Romeo1998

Well-Known Member
appreciate your efforts bro but its not what i was talking about

if we need all 4 ema , with 15 minute base on 1 minute chart .....................say 15 minute 20 period..................15 minute 50 period .................15 minute ................100 period .......................and so on

and wish to change base interval of time period to 30 minute .................or 1 hour (or any other )as per your wish

and chart is put on 1 minute time frame ........thats what i am talking about
it can be done bro, :happy:
1st click on EMA_with_same_tf to show those emas,
n toggle off diff_timeframe_ema
c pic one

then scroll down n change the periods in ema1,ema2, n so on, the timeframe will remain the same :happy:
c pic two
 
Last edited:

Similar threads