Simple Coding Help - No Promise.

Nehal_s143

Well-Known Member
Nehal
Please do not be mislead by such marketing gimmicks.
Obviously the code has a dll lock which locks the software after the trial period.

Secondly, if the indicator is surely making profits,why are they charging fees for it and distributing it to the world.They might as well use the software/indicator and become multimillionaires themselves.
Amitji I plan to use it as additional confirmation, will not be depend on alone this inductor
 

amitrandive

Well-Known Member
Nehal
Please do not be mislead by such marketing gimmicks.
Obviously the code has a dll lock which locks the software after the trial period.

Secondly, if the indicator is surely making profits,why are they charging fees for it and distributing it to the world.They might as well use the software/indicator and become multimillionaires themselves.
Amitji I plan to use it as additional confirmation, will not be depend on alone this inductor
Nehal

Very often the simplest of things work in a market.
Mostly all systems work in a trending market and fail in a sideways market.

Most indicators work on a larger time frame.We just have to understand that there is no indicator which will work at all times in a trending and sideways market.

Attaching a simple system image.

 
Hello seniors ,

Below is Market profile code..

Facing lots of errors in it... Kindly help me


_SECTION_BEGIN("MarketProfile");
//------------------------------------------------------------------------------
//
// Formula Name: Market Profile
//
// Use with 5/15min chart
// Originial - From AFL library

//Market Profile 10/12/2009


//------------------------------------------------------------------------------
// This is a modified version of afl date 09/19/2009 as listed above
// Contains a couple changes:
// 1) a more correct (but not complete) calculation of POC.
// 2) attempt to avoid the out of bound runtime error that
// sometimes occurs. See below:
//
// Here are changes to emulate the arrays x[] and total[] so
// that the array size are not limited by Barcount.
// Now one probably should not get the out of bound error even
// if the density or ticksize is smaller. Of course, there will
// be more overhead in calculation.
// johncw 20091010
// Wrapper start
_N(VarKey = NumToStr(GetChartID(), 1.0, False) + "_");
_N(VarTotal = "V_T" + VarKey);
_N(VarX = "V_x" + VarKey);

function L_StaticVarSet(L_name, L_value)
{
local L_name, L_value;
StaticVarSet(L_name + VarKey, L_value);
}

function L_StaticVarGet(L_name)
{
local L_name;
return(StaticVarGet(L_name + VarKey));
}

function x_g(L_idx)
{
local L_idx;
return VarGet(VarX + L_idx);
}

function x_s(L_idx, L_value)
{
local L_idx, L_value;
VarSet(VarX + L_idx, L_value);
}

function total_g(L_idx)
{
local L_idx;
return VarGet(VarTotal+L_idx);
}

function total_s(L_idx, L_value)
{
local L_idx, L_value, L_name;
VarSet(VarTotal+L_idx, L_value);
}
// Wrapper end
//------------------------------------------------------------------------------


PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);


EnMP2= ParamList("MarketProfile","Solid|Lines|Letters");
styleLines = ParamStyle("Style", styleLine, maskAll);

Type=ParamList("Type","Price Profile|Volume Profile");
Period= ParamList("Base","Hourly|Daily|Weekly|Monthly",1);

Den = Param("Density", 1, 0.25, 100, 0.25); // Resolution in terms of $
percent=Param("Value Area", 70, 1, 100, 1);
ViewTPOCount= ParamToggle("Show TPO Count", "No|Yes",1);
Viewvalues= ParamToggle("Show Values", "No|Yes",1);

ViewPREVIOUS = ParamToggle("Previous Values", "No|Yes",1);

ViewVALVAH = ParamToggle("Show VAL VAH Line", "No|Yes",1);
Viewfill = ParamToggle("Show VA Fill", "No|Yes",0);
Colorpoc=ParamColor("Color POC", colorYellow);
Colorfill=ParamColor("Color Fill", ColorRGB(20,40,60));


EnIB = ParamToggle("Show Initial Balance", "Yes|No");
IBBars = Param("Initial Balance Bars", 2, 0, 10, 1);

if(Period=="Daily"){
BarsInDay = BarsSince(Day() != Ref(Day(), -1));
Bot = TimeFrameGetPrice("L", inDaily, 0);
Top = TimeFrameGetPrice("H", inDaily, 0);
Vol = TimeFrameGetPrice("V", inDaily, 0);
}

if(Period=="Hourly"){
BarsInDay = BarsSince(Minute() != Ref(Minute(), -1));
Bot = TimeFrameGetPrice("L", in5Minute, 0);
Top = TimeFrameGetPrice("H", in5Minute, 0);
Vol = TimeFrameGetPrice("V", in5Minute, 0);
}

if(Period=="Weekly"){
BarsInDay = BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ));
Bot = TimeFrameGetPrice("L", inWeekly, 0);
Top = TimeFrameGetPrice("H", inWeekly, 0);
Vol = TimeFrameGetPrice("V", inWeekly, 0);
}

if(Period=="Monthly" ){
BarsInDay = BarsSince(Month() != Ref(Month(), -1));
Bot = TimeFrameGetPrice("L", inMonthly, 0);
Top = TimeFrameGetPrice("H", inMonthly, 0);
Vol = TimeFrameGetPrice("V", inMonthly, 0);
}

CurTop = HHV(H,BarsInDay+1);
Curbot = LLV(L,BarsInDay+1);
Range = Highest(Top-Bot);
TodayRange = Top - Bot;

AveRange = Sum(Top-Bot,30)/30;
LAveRange = AveRange[BarCount-1];

// Initialization
baseX = 0;
baseY = floor(Bot[0]/Den)*Den;
relTodayRange = 0;
firstVisBar = Status("firstvisiblebar");
lastVisBar = Status("lastvisiblebar");

D=.0005;
//total=0;
totaldn=0;
totalup=0;
shiftup=0;
shiftdn=0;
startr=0;

i0 = 0;
i1 = 0;
for (i=0; i<BarCount; i++) {
x_s(i, 0); // should not need this
if (BarsInDay == 0 AND i < firstVisBar) {
i0 = i;
}
if (BarsInDay == 0 AND i >= lastVisBar) {
i1 = i;
}
}

i1 = BarCount-1;
for (i=i0; i<=i1; i++) {
if (BarsInDay == 0) {
baseX = i;
baseY = floor(Bot/Den)*Den;
maxY = floor(Top/Den)*Den;
relTodayRange = (maxY-baseY)/Den;

for (j=0; j <= relTodayRange; j++) {
x_s(j, 0);

}
}

range_x=lastVisBar-firstVisBar;
spread = Param("X Space", 80, 1, 200, 1);
tpl = Param("Time Per Letter (mins)", 30, 1, 360, 1);
Intervalmin=Interval()/60;
flt =Param("First Letter (Bars)", 1, 1, 60, 1);
teb=ParamToggle("To Each Bar","No|Yes");
Color=Param("Color Threshold",20,1,50,1);
stopg=0;
stopr=0;
new=0;

Voloumeunit=Vol/LastValue(BarsInDay);


if (EnMP2 == "Letters") {
for (j=0; j<= relTodayRange; j++) {
if (L <= baseY+j*Den AND H >= baseY+j*Den) {
PlotText(StrExtract(" A , B , C , D , E , F , G , H , I , J , K , L , M , N , O , P , Q , R , S , T , U , V , W , X , Y , Z, a , b , c , d , e , f , g , h , i , j , k , L , m , n ,o , p , q , r , s , t , u , v , w , x , y , z ",
IIf(BarsInDay<flt,0,ceil(BarsInDay/(tpl/Intervalmin))-0)), baseX+IIf(teb==1,BarsInDay,x_g(j)*(range_x/spread)), baseY+j*Den,
colorWhite,ColorHSB(10+((ceil(BarsInDay/(tpl/Intervalmin)))*Color),160,140));
x_s(j, x_g(j)+1);

}
}
}

else if (EnMP2 == "Lines" OR EnMP2 == "Solid") {
for (j=0; j<= relTodayRange; j++) {
if (L <= baseY+j*Den AND H >= baseY+j*Den) {
if(Type=="Price Profile"){x_s(j, x_g(j)+1);}
else if(Type=="Volume Profile"){x_s(j, x_g(j)+round(V/Voloumeunit));}

}
}
}

// Draw Initial Balance after 11am bar is complete
if (BarsInDay == IBBars+1 AND EnIB == 0) {
Line1 = LineArray(i-2, curtop[i-1],i+7, curtop[i-1],0,True);
Plot(Line1,"",colorLightGrey,styleLine+styleDashed|styleNoRescale);
Line1 = LineArray(i-2, curbot[i-1],i+7, curbot[i-1],0,True);
Plot(Line1,"",colorLightGrey,styleLine+styleDashed|styleNoRescale);
}

// Examine x[j]
if ((i < BarCount - 1 AND BarsInDay[i+1] == 0) OR i == BarCount-1) {
maxXj = 0;
maxj = 0;
midrange = int(relTodayRange/2)+1;
for (j=0; j<= relTodayRange; j++) {
if (maxXj < x_g(j)) {
maxXj = x_g(j); maxj = j; L_StaticVarSet("Maxj",j); new=j;
} else if ( MaxXj == x_g(j)) {
if (abs(midrange-j) < abs(midrange-L_StaticVarGet("Maxj"))) {
maxXj = x_g(j); maxj = j; L_StaticVarSet("Maxj",j); new=j;
}
}
}
total_s(0, 0);
for ( n = 1; n <= relTodayRange; n++ ) {
total_s(n, x_g(n) + total_g(n-1));
}

Value_area=(total_g(relTodayRange)*percent)/100;

for ( a = 1; a <= relTodayRange; a++ )
{
if(Maxj-a>0 AND Maxj+a<relTodayRange)
{
if(MaxXj+total_g(Maxj+a)-total_g(Maxj)+(total_g(maxj)-MaxXj)-total_g(Maxj-(a+1))>=Value_area) {shiftup=a; shiftdn=a; break;}
}
else if(Maxj-a<1 )
{
if(MaxXj+total_g(Maxj+a)-total_g(Maxj)+(total_g(maxj)-MaxXj)>=Value_area){shiftup=a; shiftdn=maxj-1; break;}
}
else if(Maxj+a>relTodayRange )
{
if(MaxXj+total_g(relTodayRange)-total_g(Maxj)+(total_g(maxj)-MaxXj)-total_g(Maxj-(a+1)) >=Value_area){shiftup=relTodayRange-maxj; shiftdn=a; break;}
}
}

Vah = LineArray(baseX, baseY+(maxj+shiftup)*Den, i, baseY+(maxj+shiftup)*Den,0,True);
Val = LineArray(baseX, baseY+(maxj-shiftdn)*Den, i, baseY+(maxj-shiftdn)*Den,0,True);
Vah1 = LineArray(i, baseY+(maxj+shiftup)*Den, i+BarsInDay, baseY+(maxj+shiftup)*Den,0,True);
Val1 = LineArray(i, baseY+(maxj-shiftdn)*Den, i+BarsInDay, baseY+(maxj-shiftdn)*Den,0,True);
poc = LineArray(baseX, baseY+maxj*Den, i, baseY+maxj*Den,0,True);
poc1 = LineArray(i, baseY+maxj*Den, i+BarsInDay, baseY+maxj*Den,0,True);

if(ViewVALVAH==1)
{
Plot(Vah,"",ParamColor("Color_VA", colorBlueGrey),styleLine|styleNoRescale);
Plot(Val,"",ParamColor("Color_VA", colorLightBlue),styleLine|styleNoRescale);
Plot(poc,"",Colorpoc,styleLine|styleNoRescale);
}
if(ViewPREVIOUS==1)
{
Plot(Vah1,"",ParamColor("Color_VA", colorBlueGrey),styleDashed|styleNoRescale);
Plot(Val1,"",ParamColor("Color_VA", colorLightBlue),styleDashed|styleNoRescale);
Plot(poc1,"",Colorpoc,styleDashed|styleNoRescale);
}


if(Viewvalues==1)
{
PlotText(""+(baseY+maxj*Den),i-5,baseY+maxj*Den,Colorpoc);
PlotText(""+(baseY+(maxj+shiftup)*Den),i-5,baseY+(maxj+shiftup)*Den,colorWhite);
PlotText(""+(baseY+(maxj-shiftdn)*Den),i-5,baseY+(maxj-shiftdn)*Den,colorWhite);
if(ViewTPOCount==1){PlotText(""+(total_g(maxj)-MaxXj)+" / "+(total_g(maxj-shiftdn-1)),basex,bot-(Top-bot)*0.05,ParamColor("Color_Below_VA", colorGrey40));
PlotText(""+(total_g(relTodayRange)-total_g(maxj))+" / "+(total_g(relTodayRange)-total_g(maxj+shiftup)),basex,Top,ParamColor("Color_Above_VA", colorGrey40));
}



}

}

if (i < BarCount - 1 AND BarsInDay[i+1] == 0 OR i == BarCount-1) {

for (p = 1; p < relTodayRange+1; p++){
line = LineArray(baseX, baseY+p*Den, baseX+x_g(p), baseY+p*Den);
line2 = LineArray(baseX, baseY+(p-1)*Den, baseX+x_g(p-1), baseY+(p-1)*Den);

if (EnMP2 == "Solid")
{
PlotOHLC( Line, Line, Line2, Line2, "",IIf(p>(maxj+shiftup),ParamColor("Color_Above_VA", colorGrey40),IIf(p<=(maxj+shiftup)AND p>(maxj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA", colorGrey40))) ,styleCloud|styleNoRescale|styleNoLabel);
}
if (EnMP2 == "Lines")
{
Plot(line,"",IIf(p>(maxj+shiftup),ParamColor("Color_Above_VA", colorGrey40),IIf(p<=(maxj+shiftup)AND p>(maxj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA", colorGrey40))) , styleLines|styleNoLabel);
}

}
if(Viewfill==1){PlotOHLC(Vah,Vah,Val,Val,"",Colorfill,styleCloud|styleNoRescale|styleNoLabel);}

}
}


_SECTION_END();




Kindly help pls
 
Hi

I came across a web site http: // www . profsoftware . com /trend/

they are offering trend reversal indicator on price chart for any time frame any market

seems interesting they had also provided formula for the same but I think its for trade station. We need afl to test the same in Live market, they had shown examples on U.S. Market.

formula is as under


Manul on how to use in pdf given at
http : // www . profsoftware . com /trend/UNITRDES.pdf
Three code snippets attached by you are outer shells. Actual code is embedded within a DLL and converting outer shell to AFL is meaningless.
 
To Lvgandhi,

Hi,

From below pivot points...i want to plot levels lines for the current day only...


prv.day line makes it difficult to read the chart as scale changes...


Pivot point code :

_SECTION_BEGIN("Pivot Points");

//---------------------------------------------------------------------------
// This section gets whether they want pivot level for intraday or thier eod
//---------------------------------------------------------------------------

_N(ioreod =ParamList("Pivot Levels for ", "EOD|Intraday"));

if (ioreod=="Intraday")
{
yh = TimeFrameGetPrice( "H", inDaily, -1 );
yl = TimeFrameGetPrice( "L", inDaily, -1 );
yc = TimeFrameGetPrice( "C", inDaily, -1 );
}
else
{
yh = TimeFrameGetPrice( "H", inDaily, 0 );
yl = TimeFrameGetPrice( "L", inDaily, 0 );
yc = TimeFrameGetPrice( "C", inDaily, 0 );
}

//---------------------------------------------------------------------------
// To calculate the Pivot Levels
//---------------------------------------------------------------------------

to = TimeFrameGetPrice( "O", inDaily, 0 );
pivot = (yh + yl + yc) / 3;
range = yh - yl;
_N(pist =ParamList("Select Pivot Type ", "Classical Pivot|Woodie Pivot|Caramilla Pivot|Fibonacci Pivot"));

if (pist =="Classical Pivot" )
{
r1 = (2 * pivot) - yl ;
s1 = (2 * pivot) - yh ;
r2 = pivot - s1 + r1;
s2 = pivot - (r1 - s1) ;
r3 = 2 * (pivot - yl) + yh ;
s3 = yl - (2 * (yh - pivot));
}

else if(pist =="Woodie Pivot" )
{
pivot = (yh + yl + yc + to) / 4;
r1 = (2 * pivot) - yl;
r2 = pivot + range;
r3 = yh + 2 * (pivot - yl);
r4 = r3 + range;
s1 = (2 * pivot) - yh;
s2 = pivot - range;
s3 = yl - 2 * (yh - pivot);
s4 = S3 - range;
}

else if(pist =="Caramilla Pivot" )
{
r4 = yc + range * 1.1/2;
r3 = yc + range * 1.1/4;
r2 = yc + range * 1.1/6;
r1 = yc + range * 1.1/12;
s1 = yc - range * 1.1/12;
s2 = yc - range * 1.1/6;
s3 = yc - range * 1.1/4;
s4 = yc - range * 1.1/2;
}

else
{
r3 = pivot + 1.000 * (yh - yl);
r2 = pivot + 0.618 * (yh - yl);
r1 = pivot + 0.382 * (yh - yl);
s1 = pivot - 0.382 * (yh - yl);
s2 = pivot - 0.618 * (yh - yl);
s3 = pivot - 1.000 * (yh - yl);
}

//---------------------------------------------------------------------------
// To Plot Pivot Levels in the screen
//---------------------------------------------------------------------------

_N(dsr =ParamList("Draw Intraday Pivot Levels ", "None|Both|Support|Resistance"));

if (dsr =="Support" OR dsr == "Both")
{
Plot(pivot, "\n Pivot - ",colorGreen,1);
Plot(r1, "Resistance 1 - ",colorDarkRed,1);
Plot(r2, "Resistance 2 - ",colorDarkRed,1);
Plot(r3, "Resistance 3 - ",colorDarkRed,1);
Plot((pivot+r1)/2, "Mid Value of R1 & Pivot ",colorLightBlue,1);
Plot((r3+r2)/2, "Mid Value of R2 & R3 - ",colorLightBlue,1);
Plot((r1+r2)/2, "Mid Value of R1 & R2 - ",colorLightBlue,1);
}

if( dsr == "Resistance" OR dsr == "Both")
{
Plot(pivot, "\n Pivot - ",colorGreen,1);
Plot(s3, "Support 2 - ",colorDarkGreen,1);
Plot(s2, "Support 2 - ",colorDarkGreen,1);
Plot(s1, "Support 1 - ",colorDarkGreen,1);
Plot((s3+s2)/2, "Mid Value of S2 & S3 ",colorWhite,1);
Plot((s1+s2)/2, "Mid Value of S1 & S2 - ",colorWhite,1);
Plot((pivot+s1)/2, "Mid Value of S1 & Pivot ",colorWhite,1);
}

//---------------------------------------------------------------------------
// Printing the pivot level in interpretation window
//---------------------------------------------------------------------------


printf(Name()+ "\n\nResistance - 3 | %g\nResistance - 2 | %g\nResistance - 1 | %g\n" +
"Pivot | %g\nSupport - 1 | %g\nSupport - 2 | %g\nSupport - 3 | %g",
r3,r2,r1,pivot,s1,s2,s3);


//---------------------------------------------------------------------------
// This section is for Exploration
//---------------------------------------------------------------------------

Filter = 1;
AddColumn(r3,"Resistance 3");
AddColumn(r2,"Resistance 2");
AddColumn(r1,"Resistance 1");
AddColumn(Pivot,"Pivot");
AddColumn(s1,"Support 1");
AddColumn(s2,"Support 2");
AddColumn(s3,"Support 3");

//---------------------------------------------------------------------------
// Add Pivot levels along with the title
//---------------------------------------------------------------------------

_N(Title = EncodeColor(colorBrown)+ StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g(%.1f%%)\n"+
EncodeColor(4)+"Resistance 3 -=- %g ::::: Resistance 2 -=- %g ::::: Resistance 1 -=- %g :::::"+
EncodeColor(colorGreen)+" Pivot -=- %g"+
EncodeColor(29)+"\nSupport 1 -=- %g ::::: Support 2 -=- %g ::::: Support 3 -=- %g\n ",
O, H, L, C,SelectedValue( ROC( C, 1 ) ),r3,r2,r1,pivot,s1,s2,s3));

//---------------------------------------------------------------------------
// End of Pivot Point
//---------------------------------------------------------------------------



Regards,
Kedarnath
 
Guys, need some help with alertif.

I tried using the below Alertif code. It triggers multiple emails instead of one email. I checked the help page as well, http://www.amibroker.com/guide/h_alerts.html

but couldn't solve it.

What modification do I need to make in order to avoid multiple emails that is getting triggered.

Code:
AlertIf( Buy, "EMAIL", "Buy alert "+FullName()+"@"+BuyPrice, 1);

AlertIf( Sell, "EMAIL", "Sell alert "+FullName()+"@"+SellPrice, 2);

AlertIf( Short, "EMAIL", "Short alert "+FullName()+"@"+ShortPrice, 3);

AlertIf( Cover, "EMAIL", "Cover alert "+FullName()+"@"+CoverPrice, 4);
 

ethan hunt

Well-Known Member
Hi afl gurus,

AFL required which meets following conditions for back testing purpose:

~~~~~~~~~~~~~~~~~~~~

EOD

Condition A = EMA 1 crosses EMA 2 from below in EOD
Condition B = EMA 2 crosses EMA 1 from below in EOD

Intraday (5min)

Buy= if Condition A from EOD is met , buy price = open of 4th candle (9.30am in 5 min intrarday charts)

Sell = if Condition B from EOD is met , sell price = open of 4th candle (9.30am in 5 min intrarday charts)

Short = Sell

Cover = Buy

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Utmost Important: Back testing enabled.

Optional: Possibility to change the buy/sell execution candle to 1st, 2nd,3rd etc candle.

Optional: Possibility to change intraday time frames 10min,15min etc if possible.

Optional: Possibility to change buy/sell price from open to high, low, close, average etc.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks in advance
 
Last edited:

Similar threads