DislikedI have the code, no need to decompile. Can anyone help to make it into an MQ4?Ignored
Similar Threads
How can I convert .ex4 file into .mq4? 142 replies
Need Help converting AFL Amibroker to MQ4 Metatrader 4 replies
Please help convert this to MQ4 file. Thank you! 8 replies
Subject: Amibroker Plot Vertical Lines at Calendar Days
Hi
On Amibroker From a “Mouse select|Date input"
I would like to Plot a series of Vertical Lines at intervals of 29,41,51,66,83,106,135,172,219,279,354,451 Calendar Days
The attached formula only plots lines at trading days intervals (Bars)
Could you please modify the formula to plot lines at Calendar day intervals?
Amibroker function DaysSince1900() get number of days since January 1st, 1900
Could you tell me how to use this function for calculations of calendar days
as opposed to trading days in the attached formula
Hoping you can oblige
Thank you in advance
Derek
Hi
On Amibroker From a “Mouse select|Date input"
I would like to Plot a series of Vertical Lines at intervals of 29,41,51,66,83,106,135,172,219,279,354,451 Calendar Days
The attached formula only plots lines at trading days intervals (Bars)
Could you please modify the formula to plot lines at Calendar day intervals?
Amibroker function DaysSince1900() get number of days since January 1st, 1900
Could you tell me how to use this function for calculations of calendar days
as opposed to trading days in the attached formula
Hoping you can oblige
Thank you in advance
Derek
Inserted Code
//Calendar Spiral _SECTION_BEGIN("CarolanForwardSpiral"); Fb = Param( "Spiral Calendar Forward or Backwards", 1, -1, 1 ); F2=Fb*29; F3=Fb*42; F4=Fb*51; F5=Fb*66; F6=Fb*84; F7=Fb*106; F8=Fb*135; F9=Fb*172; F10=Fb*219; F11=Fb*279; F12=Fb*354; F13=Fb*451; F14=Fb*573; F15=Fb*729; F16=Fb*928; F17=Fb*1180; F18=Fb*1501; Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F2; Plot(Line1_X, "F2( "+WriteVal(F2,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F3; Plot(Line1_X, "F3( "+WriteVal(F3,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F4; Plot(Line1_X, "F4( "+WriteVal(F4,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F5; Plot(Line1_X, "F5( "+WriteVal(F5,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F6; Plot(Line1_X, "F6( "+WriteVal(F6,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F7; Plot(Line1_X, "F7( "+WriteVal(F7,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F8; Plot(Line1_X, "F8( "+WriteVal(F8,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F9; Plot(Line1_X, "F9( "+WriteVal(F9,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F10; Plot(Line1_X, "F10( "+WriteVal(F10,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F11; Plot(Line1_X, "F11( "+WriteVal(F11,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F12; Plot(Line1_X, "F12( "+WriteVal(F12,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F13; Plot(Line1_X, "F13( "+WriteVal(F13,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F14; Plot(Line1_X, "F14( "+WriteVal(F14,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F15; Plot(Line1_X, "F15( "+WriteVal(F15,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F16; Plot(Line1_X, "F16( "+WriteVal(F16,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 + F17; Plot(Line1_X, "F17( "+WriteVal(F17,1)+" )",colorYellow,styleHistogram|styleOwnScale); Line1_X = Cum(1) == SelectedValue(BarIndex())+1 +F18; Plot(Line1_X, "F18( "+WriteVal(F18,1)+" )",colorYellow,styleHistogram|styleOwnScale); Plot(C,"close",colorGreen,styleCandle); _SECTION_END();
Hi friends,
I am very new to trading. Someone kindly help me converting the following indicator from Amibroker AFL to either MQ4 or MQL5. I found it on internet. Could not find Simon who coded it originally but big thanks to him.
Thanks in advance to all those Good Samaritans.
//--------- CPR ---------//
//Coded By: SIMSON//
_SECTION_BEGIN( "CPR" );
dtDayStartComp = TimeFrameCompress( DateTime(), inDaily, compressOpen );
dtDayStartExp = TimeFrameExpand( dtDayStartComp, inDaily, expandFirst );
dtDayEndComp = TimeFrameCompress( DateTime(), inDaily, compressLast );
dtDayEndExp = TimeFrameExpand( dtDayEndComp, inDaily, expandFirst );
DayCond = DateTime() >= dtDayStartExp AND DateTime() < dtDayEndExp;
//Levels Settings (Shown / Hidden)//
/*
DCPR = ParamToggle( "Daily CPR", "Shown|Hidden", 0 );
WCPR = ParamToggle( "Weekly CPR", "Shown|Hidden", 0 );
MCPR = ParamToggle( "Monthly CPR", "Shown|Hidden", 0 );
*/
TCPR = ParamToggle( "Tomorrow CPR", "Shown|Hidden", 1 );
DRE4 = ParamToggle( "Daily R4", "Shown|Hidden", 1 );
DRE3 = ParamToggle( "Daily R3", "Shown|Hidden", 1 );
DRE2 = ParamToggle( "Daily R2", "Shown|Hidden", 1 );
DRE1 = ParamToggle( "Daily R1", "Shown|Hidden", 0 );
DCUB = ParamToggle( "Daily UB", "Shown|Hidden", 0 );
DCPV = ParamToggle( "Daily PV", "Shown|Hidden", 0 );
DCLB = ParamToggle( "Daily LB", "Shown|Hidden", 0 );
DSU1 = ParamToggle( "Daily S1", "Shown|Hidden", 0 );
DSU2 = ParamToggle( "Daily S2", "Shown|Hidden", 1 );
DSU3 = ParamToggle( "Daily S3", "Shown|Hidden", 1 );
DSU4 = ParamToggle( "Daily S4", "Shown|Hidden", 1 );
DH = ParamToggle( "Previous Day High", "Shown|Hidden", 0 );
DL = ParamToggle( "Previous Day Low", "Shown|Hidden", 0 );
WRE3 = ParamToggle( "Weekly R3", "Shown|Hidden", 1 );
WRE2 = ParamToggle( "Weekly R2", "Shown|Hidden", 1 );
WRE1 = ParamToggle( "Weekly R1", "Shown|Hidden", 1 );
WCUB = ParamToggle( "Weekly UB", "Shown|Hidden", 1 );
WCPV = ParamToggle( "Weekly PV", "Shown|Hidden", 1 );
WCLB = ParamToggle( "Weekly LB", "Shown|Hidden", 1 );
WSU1 = ParamToggle( "Weekly S1", "Shown|Hidden", 1 );
WSU2 = ParamToggle( "Weekly S2", "Shown|Hidden", 1 );
WSU3 = ParamToggle( "Weekly S3", "Shown|Hidden", 1 );
WH = ParamToggle( "Previous Week High", "Shown|Hidden", 1 );
WL = ParamToggle( "Previous Week Low", "Shown|Hidden", 1 );
MRE3 = ParamToggle( "Monttly R3", "Shown|Hidden", 1 );
MRE2 = ParamToggle( "Monttly R2", "Shown|Hidden", 1 );
MRE1 = ParamToggle( "Monttly R1", "Shown|Hidden", 1 );
MCUB = ParamToggle( "Monttly UB", "Shown|Hidden", 1 );
MCPV = ParamToggle( "Monttly PV", "Shown|Hidden", 1 );
MCLB = ParamToggle( "Monttly LB", "Shown|Hidden", 1 );
MSU1 = ParamToggle( "Monttly S1", "Shown|Hidden", 1 );
MSU2 = ParamToggle( "Monttly S2", "Shown|Hidden", 1 );
MSU3 = ParamToggle( "Monttly S3", "Shown|Hidden", 1 );
MH = ParamToggle( "Previous Month High", "Shown|Hidden", 1 );
ML = ParamToggle( "Previous Month Low", "Shown|Hidden", 1 );
// Current Day High Low Close
CDH = TimeFrameGetPrice( "H", inDaily, 0 );
CDL = TimeFrameGetPrice( "L", inDaily, 0 );
CDC = TimeFrameGetPrice( "C", inDaily, 0 );
// Previous Days High Low Close
PDH = TimeFrameGetPrice( "H", inDaily, -1 );
PDL = TimeFrameGetPrice( "L", inDaily, -1 );
PDC = TimeFrameGetPrice( "C", inDaily, -1 );
// Previous Weeks High Low Close
PWH = TimeFrameGetPrice( "H", inWeekly, -1 );
PWL = TimeFrameGetPrice( "L", inWeekly, -1 );
PWC = TimeFrameGetPrice( "C", inWeekly, -1 );
// Previous Months High Low Close
PMH = TimeFrameGetPrice( "H", inMonthly, -1 );
PML = TimeFrameGetPrice( "L", inMonthly, -1 );
PMC = TimeFrameGetPrice( "C", inMonthly, -1 );
// Daily CPR
PV = ( PDH + PDL + PDC ) / 3;
LB = ( PDH + PDL ) / 2;
UB = ( PV - LB ) + PV ;
// Weekly CPR
WPV = ( PWH + PWL + PWC ) / 3;
WLB = ( PWH + PWL ) / 2;
WUB = ( WPV - WLB ) + WPV;
// Monthly CPR
MPV = ( PMH + PML + PMC ) / 3;
MLB = ( PMH + PML ) / 2;
MUB = ( MPV - MLB ) + MPV;
// Daily Resistence & Supports
R1 = 2 * PV - PDL;
R2 = PV + ( PDH - PDL );
R3 = R1 + ( PDH - PDL );
R4 = R3 + ( R2 - R1);
S1 = 2 * PV - PDH;
S2 = PV - ( PDH - PDL );
S3 = S1 - ( PDH - PDL );
S4 = S3 - ( S1 - S2 );
// Weekly Resistence & Supports
WR1 = 2 * WPV - PWL;
WR2 = WPV + ( PWH - PWL );
WR3 = WR1 + ( PWH - PWL );
WR4 = WR3 + ( WR2 - WR1);
WS1 = 2 * WPV - PWH;
WS2 = WPV - ( PWH - PWL );
WS3 = WS1 - ( PWH - PWL );
WS4 = WS3 - ( WS1 - WS2 );
// Monthly Resistence & Supports
MR1 = 2 * MPV - PML;
MR2 = MPV + ( PMH - PML );
MR3 = MR1 + ( PDH - PML );
MR4 = MR3 + ( MR2 - MR1);
MS1 = 2 * MPV - PMH;
MS2 = MPV - ( PMH - PML );
MS3 = MS1 - ( PMH - PML );
MS4 = MS3 - ( MS1 - MS2 );
numbars = LastValue( Cum( Status( "barvisible" ) ) );
hts = -50;
_SECTION_BEGIN( "DAILY CPR" );
if ( DH == 0 )
{
Plot( IIf( DayCond, PDH, Null ), "PDH", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PDH = "+PDH , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PDH), colorYellow );
}
if ( DL == 0 )
{
Plot( IIf( DayCond, PDL, Null ), "PDL", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PDL = "+PDL , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PDL), colorYellow );
}
if ( DCUB == 0 )
{
Plot( IIf( DayCond, UB, Null ), "UB", colorAqua, styleLine, Null, Null, 2 );
PlotText( "UB = "+UB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(UB), colorAqua );
}
if ( DCPV == 0 )
{
Plot( IIf( DayCond, PV, Null ), "Pivot", colorAqua, styleLine, Null, Null, 2 );
PlotText( "PV = "+PV , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PV), colorAqua );
}
if ( DCLB == 0 )
{
Plot( IIf( DayCond, LB, Null ), "LB", colorAqua, styleLine, Null, Null, 2 );
PlotText( "LB = "+LB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(LB), colorAqua );
}
if ( DRE1 == 0 )
{
Plot( IIf( DayCond, R1, Null ), "R1", colorLime, styleLine, Null, Null, 2 );
PlotText( "R1 = "+R1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(R1), colorLime );
}
if ( DRE2 == 0 )
{
Plot( IIf( DayCond, R2, Null ), "R2", colorLime, styleLine, Null, Null, 2 );
PlotText( "R2 = "+R2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(R2), colorLime );
}
if ( DRE3 == 0 )
{
Plot( IIf( DayCond, R3, Null ), "R3", colorLime, styleLine, Null, Null, 2 );
PlotText( "R3 = "+R3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(R3), colorLime );
}
if ( DRE4 == 0 )
{
Plot( IIf( DayCond, R4, Null ), "R4", colorLime, styleLine, Null, Null, 2 );
PlotText( "R4 = "+R4 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(R4), colorLime );
}
if ( DSU1 == 0 )
{
Plot( IIf( DayCond, S1, Null ), "S1", colorOrange, styleLine, Null, Null, 2 );
PlotText( "S1 = "+S1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(S1), colorOrange );
}
if ( DSU2 == 0 )
{
Plot( IIf( DayCond, S2, Null ), "S2", colorOrange, styleLine, Null, Null, 2 );
PlotText( "S2 = "+S2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(S2), colorOrange );
}
if ( DSU3 == 0 )
{
Plot( IIf( DayCond, S3, Null ), "S3", colorOrange, styleLine, Null, Null, 2 );
PlotText( "S3 = "+S3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(S3), colorOrange );
}
if ( DSU4 == 0 )
{
Plot( IIf( DayCond, S4, Null ), "S4", colorOrange, styleLine, Null, Null, 2 );
PlotText( "S4 = "+S4 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(S4), colorOrange );
}
_SECTION_END();
_SECTION_BEGIN( "WEEKLY CPR" );
if ( WH == 0 )
{
Plot( IIf( DayCond, PWH, Null ), "PWH", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PWH = "+PWH , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PWH), colorYellow );
}
if ( WL == 0 )
{
Plot( IIf( DayCond, PWL, Null ), "PWL", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PWL = "+PWL , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PWL), colorYellow );
}
if ( WCUB == 0 )
{
Plot( IIf( DayCond, WUB, Null ), "WCUB", colorAqua, styleDots, Null, Null, 2 );
PlotText( "WCUB = "+WUB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WUB), colorAqua );
}
if ( WCPV == 0 )
{
Plot( IIf( DayCond, WPV, Null ), "WCPV", colorAqua, styleDots, Null, Null, 2 );
PlotText( "WCPV = "+WPV , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WPV), colorAqua );
}
if ( WCLB == 0 )
{
Plot( IIf( DayCond, WLB, Null ), "WCLB", colorAqua, styleDots, Null, Null, 2 );
PlotText( "WCLB = "+WLB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WLB), colorAqua );
}
if ( WRE1 == 0 )
{
Plot( IIf( DayCond, WR1, Null ), "WR1", colorLime, styleDots, Null, Null, 2 );
PlotText( "WR1 = "+WR1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WR1), colorLime );
}
if ( WRE2 == 0 )
{
Plot( IIf( DayCond, WR2, Null ), "WR2", colorLime, styleDots, Null, Null, 2 );
PlotText( "WR2 = "+WR2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WR2), colorLime );
}
if ( WRE3 == 0 )
{
Plot( IIf( DayCond, WR3, Null ), "WR3", colorLime, styleDots, Null, Null, 2 );
PlotText( "WR3 = "+WR3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WR3), colorLime );
}
if ( WSU1 == 0 )
{
Plot( IIf( DayCond, WS1, Null ), "WS1", colorOrange, styleDots, Null, Null, 2 );
PlotText( "WS1 = "+WS1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WS1), colorOrange );
}
if ( WSU2 == 0 )
{
Plot( IIf( DayCond, WS2, Null ), "WS2", colorOrange, styleDots, Null, Null, 2 );
PlotText( "WS2 = "+WS2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WS2), colorOrange );
}
if ( WSU3 == 0 )
{
Plot( IIf( DayCond, WS3, Null ), "WS3", colorOrange, styleDots, Null, Null, 2 );
PlotText( "WS3 = "+WS3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WS3), colorOrange );
}
_SECTION_END();
_SECTION_BEGIN( "MONTHLY CPR" );
if ( MH == 0 )
{
Plot( IIf( DayCond, PMH, Null ), "PMH", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PMH = "+PMH , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PMH), colorYellow );
}
if ( ML == 0 )
{
Plot( IIf( DayCond, PML, Null ), "PML", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PML = "+PML , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PML), colorYellow );
}
if ( MCUB == 0 )
{
Plot( IIf( DayCond, MUB, Null ), "MCUB", colorAqua, styleDashed, Null, Null, 2 );
PlotText( "MCUB = "+MUB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MUB), colorAqua );
}
if ( MCPV == 0 )
{
Plot( IIf( DayCond, MPV, Null ), "MCPV", colorAqua, styleDashed, Null, Null, 2 );
PlotText( "MCPV = "+MPV , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MPV), colorAqua );
}
if ( MCLB == 0 )
{
Plot( IIf( DayCond, MLB, Null ), "MCLB", colorAqua, styleDashed, Null, Null, 2 );
PlotText( "MCLB = "+MLB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MLB), colorAqua );
}
if ( MRE1 == 0 )
{
Plot( IIf( DayCond, MR1, Null ), "MR1", colorLime, styleDashed, Null, Null, 2 );
PlotText( "MR1 = "+MR1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MR1), colorLime );
}
if ( MRE2 == 0 )
{
Plot( IIf( DayCond, MR2, Null ), "MR2", colorLime, styleDashed, Null, Null, 2 );
PlotText( "MR2 = "+MR2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MR2), colorLime );
}
if ( MRE3 == 0 )
{
Plot( IIf( DayCond, MR3, Null ), "MR3", colorLime, styleDashed, Null, Null, 2 );
PlotText( "MR3 = "+MR3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MR3), colorLime );
}
if ( MSU1 == 0 )
{
Plot( IIf( DayCond, MS1, Null ), "MS1", colorOrange, styleDashed, Null, Null, 2 );
PlotText( "MS1 = "+MS1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MS1), colorOrange );
}
if ( MSU2 == 0 )
{
Plot( IIf( DayCond, MS2, Null ), "MS2", colorOrange, styleDashed, Null, Null, 2 );
PlotText( "MS2 = "+MS2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MS2), colorOrange );
}
if ( MSU3 == 0 )
{
Plot( IIf( DayCond, MS3, Null ), "MS3", colorOrange, styleDashed, Null, Null, 2 );
PlotText( "MS3 = "+MS3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MS3), colorOrange );
}
_SECTION_END();
_SECTION_END();
_SECTION_BEGIN( "NEXT DAY" );
if ( TCPR == 0 )
{
shift = 10; //Number of Bars to be shifted, could use a Param if needed
bi = BarIndex();
lvbi = LastValue( bi );
LAx0 = lvbi - shift + 1;
LAx1 = lvbi;
// Present Days High Low Close
// These levels will be dynamic as day progresses and would ahow up in the no bar region after the last visible Bar for shifted number of bars (i.e. 10 in this case)
// Do use "Bar Replay" to figure out what I mean
dH = TimeFrameGetPrice( "H", inDaily, 0 );
dL = TimeFrameGetPrice( "L", inDaily, 0 );
dC = TimeFrameGetPrice( "C", inDaily, 0 );
//Central Pivots shifted for Next Day
dPV = ( dH + dL + dC ) / 3;
LB = ( dH + dL ) / 2;
UB = 2 * dPV - LB;
y = LastValue( dPV );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "PV", colorAqua, styleThick, Null, Null, shift );
y = LastValue( LB );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "LB", colorAqua, styleThick, Null, Null, shift );
y = LastValue( UB );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "UB", colorAqua, styleThick, Null, Null, shift );
//Pivot Levels shifted for Next Day
R1 = 2 * dPV - dL;
R2 = dPV + dH - dL;
S1 = 2 * dPV - dH;
S2 = dPV - dH + dL;
y = LastValue( R1 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "R1", colorOrange, styleThick, Null, Null, shift );
y = LastValue( R2 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "R2", colorOrange, styleThick, Null, Null, shift );
y = LastValue( S1 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "S1", colorLime, styleThick, Null, Null, shift );
y = LastValue( S2 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "S2", colorLime, styleThick, Null, Null, shift );
}
_SECTION_END();
I am very new to trading. Someone kindly help me converting the following indicator from Amibroker AFL to either MQ4 or MQL5. I found it on internet. Could not find Simon who coded it originally but big thanks to him.
Thanks in advance to all those Good Samaritans.
//--------- CPR ---------//
//Coded By: SIMSON//
_SECTION_BEGIN( "CPR" );
dtDayStartComp = TimeFrameCompress( DateTime(), inDaily, compressOpen );
dtDayStartExp = TimeFrameExpand( dtDayStartComp, inDaily, expandFirst );
dtDayEndComp = TimeFrameCompress( DateTime(), inDaily, compressLast );
dtDayEndExp = TimeFrameExpand( dtDayEndComp, inDaily, expandFirst );
DayCond = DateTime() >= dtDayStartExp AND DateTime() < dtDayEndExp;
//Levels Settings (Shown / Hidden)//
/*
DCPR = ParamToggle( "Daily CPR", "Shown|Hidden", 0 );
WCPR = ParamToggle( "Weekly CPR", "Shown|Hidden", 0 );
MCPR = ParamToggle( "Monthly CPR", "Shown|Hidden", 0 );
*/
TCPR = ParamToggle( "Tomorrow CPR", "Shown|Hidden", 1 );
DRE4 = ParamToggle( "Daily R4", "Shown|Hidden", 1 );
DRE3 = ParamToggle( "Daily R3", "Shown|Hidden", 1 );
DRE2 = ParamToggle( "Daily R2", "Shown|Hidden", 1 );
DRE1 = ParamToggle( "Daily R1", "Shown|Hidden", 0 );
DCUB = ParamToggle( "Daily UB", "Shown|Hidden", 0 );
DCPV = ParamToggle( "Daily PV", "Shown|Hidden", 0 );
DCLB = ParamToggle( "Daily LB", "Shown|Hidden", 0 );
DSU1 = ParamToggle( "Daily S1", "Shown|Hidden", 0 );
DSU2 = ParamToggle( "Daily S2", "Shown|Hidden", 1 );
DSU3 = ParamToggle( "Daily S3", "Shown|Hidden", 1 );
DSU4 = ParamToggle( "Daily S4", "Shown|Hidden", 1 );
DH = ParamToggle( "Previous Day High", "Shown|Hidden", 0 );
DL = ParamToggle( "Previous Day Low", "Shown|Hidden", 0 );
WRE3 = ParamToggle( "Weekly R3", "Shown|Hidden", 1 );
WRE2 = ParamToggle( "Weekly R2", "Shown|Hidden", 1 );
WRE1 = ParamToggle( "Weekly R1", "Shown|Hidden", 1 );
WCUB = ParamToggle( "Weekly UB", "Shown|Hidden", 1 );
WCPV = ParamToggle( "Weekly PV", "Shown|Hidden", 1 );
WCLB = ParamToggle( "Weekly LB", "Shown|Hidden", 1 );
WSU1 = ParamToggle( "Weekly S1", "Shown|Hidden", 1 );
WSU2 = ParamToggle( "Weekly S2", "Shown|Hidden", 1 );
WSU3 = ParamToggle( "Weekly S3", "Shown|Hidden", 1 );
WH = ParamToggle( "Previous Week High", "Shown|Hidden", 1 );
WL = ParamToggle( "Previous Week Low", "Shown|Hidden", 1 );
MRE3 = ParamToggle( "Monttly R3", "Shown|Hidden", 1 );
MRE2 = ParamToggle( "Monttly R2", "Shown|Hidden", 1 );
MRE1 = ParamToggle( "Monttly R1", "Shown|Hidden", 1 );
MCUB = ParamToggle( "Monttly UB", "Shown|Hidden", 1 );
MCPV = ParamToggle( "Monttly PV", "Shown|Hidden", 1 );
MCLB = ParamToggle( "Monttly LB", "Shown|Hidden", 1 );
MSU1 = ParamToggle( "Monttly S1", "Shown|Hidden", 1 );
MSU2 = ParamToggle( "Monttly S2", "Shown|Hidden", 1 );
MSU3 = ParamToggle( "Monttly S3", "Shown|Hidden", 1 );
MH = ParamToggle( "Previous Month High", "Shown|Hidden", 1 );
ML = ParamToggle( "Previous Month Low", "Shown|Hidden", 1 );
// Current Day High Low Close
CDH = TimeFrameGetPrice( "H", inDaily, 0 );
CDL = TimeFrameGetPrice( "L", inDaily, 0 );
CDC = TimeFrameGetPrice( "C", inDaily, 0 );
// Previous Days High Low Close
PDH = TimeFrameGetPrice( "H", inDaily, -1 );
PDL = TimeFrameGetPrice( "L", inDaily, -1 );
PDC = TimeFrameGetPrice( "C", inDaily, -1 );
// Previous Weeks High Low Close
PWH = TimeFrameGetPrice( "H", inWeekly, -1 );
PWL = TimeFrameGetPrice( "L", inWeekly, -1 );
PWC = TimeFrameGetPrice( "C", inWeekly, -1 );
// Previous Months High Low Close
PMH = TimeFrameGetPrice( "H", inMonthly, -1 );
PML = TimeFrameGetPrice( "L", inMonthly, -1 );
PMC = TimeFrameGetPrice( "C", inMonthly, -1 );
// Daily CPR
PV = ( PDH + PDL + PDC ) / 3;
LB = ( PDH + PDL ) / 2;
UB = ( PV - LB ) + PV ;
// Weekly CPR
WPV = ( PWH + PWL + PWC ) / 3;
WLB = ( PWH + PWL ) / 2;
WUB = ( WPV - WLB ) + WPV;
// Monthly CPR
MPV = ( PMH + PML + PMC ) / 3;
MLB = ( PMH + PML ) / 2;
MUB = ( MPV - MLB ) + MPV;
// Daily Resistence & Supports
R1 = 2 * PV - PDL;
R2 = PV + ( PDH - PDL );
R3 = R1 + ( PDH - PDL );
R4 = R3 + ( R2 - R1);
S1 = 2 * PV - PDH;
S2 = PV - ( PDH - PDL );
S3 = S1 - ( PDH - PDL );
S4 = S3 - ( S1 - S2 );
// Weekly Resistence & Supports
WR1 = 2 * WPV - PWL;
WR2 = WPV + ( PWH - PWL );
WR3 = WR1 + ( PWH - PWL );
WR4 = WR3 + ( WR2 - WR1);
WS1 = 2 * WPV - PWH;
WS2 = WPV - ( PWH - PWL );
WS3 = WS1 - ( PWH - PWL );
WS4 = WS3 - ( WS1 - WS2 );
// Monthly Resistence & Supports
MR1 = 2 * MPV - PML;
MR2 = MPV + ( PMH - PML );
MR3 = MR1 + ( PDH - PML );
MR4 = MR3 + ( MR2 - MR1);
MS1 = 2 * MPV - PMH;
MS2 = MPV - ( PMH - PML );
MS3 = MS1 - ( PMH - PML );
MS4 = MS3 - ( MS1 - MS2 );
numbars = LastValue( Cum( Status( "barvisible" ) ) );
hts = -50;
_SECTION_BEGIN( "DAILY CPR" );
if ( DH == 0 )
{
Plot( IIf( DayCond, PDH, Null ), "PDH", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PDH = "+PDH , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PDH), colorYellow );
}
if ( DL == 0 )
{
Plot( IIf( DayCond, PDL, Null ), "PDL", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PDL = "+PDL , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PDL), colorYellow );
}
if ( DCUB == 0 )
{
Plot( IIf( DayCond, UB, Null ), "UB", colorAqua, styleLine, Null, Null, 2 );
PlotText( "UB = "+UB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(UB), colorAqua );
}
if ( DCPV == 0 )
{
Plot( IIf( DayCond, PV, Null ), "Pivot", colorAqua, styleLine, Null, Null, 2 );
PlotText( "PV = "+PV , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PV), colorAqua );
}
if ( DCLB == 0 )
{
Plot( IIf( DayCond, LB, Null ), "LB", colorAqua, styleLine, Null, Null, 2 );
PlotText( "LB = "+LB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(LB), colorAqua );
}
if ( DRE1 == 0 )
{
Plot( IIf( DayCond, R1, Null ), "R1", colorLime, styleLine, Null, Null, 2 );
PlotText( "R1 = "+R1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(R1), colorLime );
}
if ( DRE2 == 0 )
{
Plot( IIf( DayCond, R2, Null ), "R2", colorLime, styleLine, Null, Null, 2 );
PlotText( "R2 = "+R2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(R2), colorLime );
}
if ( DRE3 == 0 )
{
Plot( IIf( DayCond, R3, Null ), "R3", colorLime, styleLine, Null, Null, 2 );
PlotText( "R3 = "+R3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(R3), colorLime );
}
if ( DRE4 == 0 )
{
Plot( IIf( DayCond, R4, Null ), "R4", colorLime, styleLine, Null, Null, 2 );
PlotText( "R4 = "+R4 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(R4), colorLime );
}
if ( DSU1 == 0 )
{
Plot( IIf( DayCond, S1, Null ), "S1", colorOrange, styleLine, Null, Null, 2 );
PlotText( "S1 = "+S1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(S1), colorOrange );
}
if ( DSU2 == 0 )
{
Plot( IIf( DayCond, S2, Null ), "S2", colorOrange, styleLine, Null, Null, 2 );
PlotText( "S2 = "+S2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(S2), colorOrange );
}
if ( DSU3 == 0 )
{
Plot( IIf( DayCond, S3, Null ), "S3", colorOrange, styleLine, Null, Null, 2 );
PlotText( "S3 = "+S3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(S3), colorOrange );
}
if ( DSU4 == 0 )
{
Plot( IIf( DayCond, S4, Null ), "S4", colorOrange, styleLine, Null, Null, 2 );
PlotText( "S4 = "+S4 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(S4), colorOrange );
}
_SECTION_END();
_SECTION_BEGIN( "WEEKLY CPR" );
if ( WH == 0 )
{
Plot( IIf( DayCond, PWH, Null ), "PWH", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PWH = "+PWH , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PWH), colorYellow );
}
if ( WL == 0 )
{
Plot( IIf( DayCond, PWL, Null ), "PWL", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PWL = "+PWL , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PWL), colorYellow );
}
if ( WCUB == 0 )
{
Plot( IIf( DayCond, WUB, Null ), "WCUB", colorAqua, styleDots, Null, Null, 2 );
PlotText( "WCUB = "+WUB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WUB), colorAqua );
}
if ( WCPV == 0 )
{
Plot( IIf( DayCond, WPV, Null ), "WCPV", colorAqua, styleDots, Null, Null, 2 );
PlotText( "WCPV = "+WPV , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WPV), colorAqua );
}
if ( WCLB == 0 )
{
Plot( IIf( DayCond, WLB, Null ), "WCLB", colorAqua, styleDots, Null, Null, 2 );
PlotText( "WCLB = "+WLB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WLB), colorAqua );
}
if ( WRE1 == 0 )
{
Plot( IIf( DayCond, WR1, Null ), "WR1", colorLime, styleDots, Null, Null, 2 );
PlotText( "WR1 = "+WR1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WR1), colorLime );
}
if ( WRE2 == 0 )
{
Plot( IIf( DayCond, WR2, Null ), "WR2", colorLime, styleDots, Null, Null, 2 );
PlotText( "WR2 = "+WR2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WR2), colorLime );
}
if ( WRE3 == 0 )
{
Plot( IIf( DayCond, WR3, Null ), "WR3", colorLime, styleDots, Null, Null, 2 );
PlotText( "WR3 = "+WR3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WR3), colorLime );
}
if ( WSU1 == 0 )
{
Plot( IIf( DayCond, WS1, Null ), "WS1", colorOrange, styleDots, Null, Null, 2 );
PlotText( "WS1 = "+WS1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WS1), colorOrange );
}
if ( WSU2 == 0 )
{
Plot( IIf( DayCond, WS2, Null ), "WS2", colorOrange, styleDots, Null, Null, 2 );
PlotText( "WS2 = "+WS2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WS2), colorOrange );
}
if ( WSU3 == 0 )
{
Plot( IIf( DayCond, WS3, Null ), "WS3", colorOrange, styleDots, Null, Null, 2 );
PlotText( "WS3 = "+WS3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(WS3), colorOrange );
}
_SECTION_END();
_SECTION_BEGIN( "MONTHLY CPR" );
if ( MH == 0 )
{
Plot( IIf( DayCond, PMH, Null ), "PMH", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PMH = "+PMH , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PMH), colorYellow );
}
if ( ML == 0 )
{
Plot( IIf( DayCond, PML, Null ), "PML", colorYellow, styleLine, Null, Null, 2 );
PlotText( "PML = "+PML , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(PML), colorYellow );
}
if ( MCUB == 0 )
{
Plot( IIf( DayCond, MUB, Null ), "MCUB", colorAqua, styleDashed, Null, Null, 2 );
PlotText( "MCUB = "+MUB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MUB), colorAqua );
}
if ( MCPV == 0 )
{
Plot( IIf( DayCond, MPV, Null ), "MCPV", colorAqua, styleDashed, Null, Null, 2 );
PlotText( "MCPV = "+MPV , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MPV), colorAqua );
}
if ( MCLB == 0 )
{
Plot( IIf( DayCond, MLB, Null ), "MCLB", colorAqua, styleDashed, Null, Null, 2 );
PlotText( "MCLB = "+MLB , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MLB), colorAqua );
}
if ( MRE1 == 0 )
{
Plot( IIf( DayCond, MR1, Null ), "MR1", colorLime, styleDashed, Null, Null, 2 );
PlotText( "MR1 = "+MR1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MR1), colorLime );
}
if ( MRE2 == 0 )
{
Plot( IIf( DayCond, MR2, Null ), "MR2", colorLime, styleDashed, Null, Null, 2 );
PlotText( "MR2 = "+MR2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MR2), colorLime );
}
if ( MRE3 == 0 )
{
Plot( IIf( DayCond, MR3, Null ), "MR3", colorLime, styleDashed, Null, Null, 2 );
PlotText( "MR3 = "+MR3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MR3), colorLime );
}
if ( MSU1 == 0 )
{
Plot( IIf( DayCond, MS1, Null ), "MS1", colorOrange, styleDashed, Null, Null, 2 );
PlotText( "MS1 = "+MS1 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MS1), colorOrange );
}
if ( MSU2 == 0 )
{
Plot( IIf( DayCond, MS2, Null ), "MS2", colorOrange, styleDashed, Null, Null, 2 );
PlotText( "MS2 = "+MS2 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MS2), colorOrange );
}
if ( MSU3 == 0 )
{
Plot( IIf( DayCond, MS3, Null ), "MS3", colorOrange, styleDashed, Null, Null, 2 );
PlotText( "MS3 = "+MS3 , LastValue( BarIndex() ) - ( numbars / Hts ), LastValue(MS3), colorOrange );
}
_SECTION_END();
_SECTION_END();
_SECTION_BEGIN( "NEXT DAY" );
if ( TCPR == 0 )
{
shift = 10; //Number of Bars to be shifted, could use a Param if needed
bi = BarIndex();
lvbi = LastValue( bi );
LAx0 = lvbi - shift + 1;
LAx1 = lvbi;
// Present Days High Low Close
// These levels will be dynamic as day progresses and would ahow up in the no bar region after the last visible Bar for shifted number of bars (i.e. 10 in this case)
// Do use "Bar Replay" to figure out what I mean
dH = TimeFrameGetPrice( "H", inDaily, 0 );
dL = TimeFrameGetPrice( "L", inDaily, 0 );
dC = TimeFrameGetPrice( "C", inDaily, 0 );
//Central Pivots shifted for Next Day
dPV = ( dH + dL + dC ) / 3;
LB = ( dH + dL ) / 2;
UB = 2 * dPV - LB;
y = LastValue( dPV );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "PV", colorAqua, styleThick, Null, Null, shift );
y = LastValue( LB );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "LB", colorAqua, styleThick, Null, Null, shift );
y = LastValue( UB );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "UB", colorAqua, styleThick, Null, Null, shift );
//Pivot Levels shifted for Next Day
R1 = 2 * dPV - dL;
R2 = dPV + dH - dL;
S1 = 2 * dPV - dH;
S2 = dPV - dH + dL;
y = LastValue( R1 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "R1", colorOrange, styleThick, Null, Null, shift );
y = LastValue( R2 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "R2", colorOrange, styleThick, Null, Null, shift );
y = LastValue( S1 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "S1", colorLime, styleThick, Null, Null, shift );
y = LastValue( S2 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "S2", colorLime, styleThick, Null, Null, shift );
}
_SECTION_END();