Simple Coding Help - No Promise.

can somebody please explain me in english, In This Code(mentioned below) what conditions writer is using to make entry and exit, please help on what conditions writer has designed to make entry and exit.

_SECTION_BEGIN("Price");

SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));
GfxSetBkMode(0);
GfxSetOverlayMode(1);
//SetTradeDelays(1,1,1,1);
SetPositionSize(100,spsShares);

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

_SECTION_END();
NHours=Param("Number of Hours",30,1,50,1);
HoursC=TimeFrameGetPrice("O",inHourly,0);
NHoursDHLAvg=0;
for(i=1;i<=NHours;i++)
{
HourH=TimeFrameGetPrice("H",inHourly,-i);
HourL=TimeFrameGetPrice("L",inHourly,-i);
NHoursDHLAvg=NHoursDHLAvg+(HourH-HourL);
}
NHoursDHLAvg=NHoursDHLAvg/NHours;

TenDHLAvg= NHoursDHLAvg;

Buy= C>((HoursC)+((0.618)*(TenDHLAvg)));
Sell= C<((HoursC)-((0.618)*(TenDHLAvg)));

Cover= C>((HoursC)+((0.382)*(TenDHLAvg)));
Short= C<((HoursC)-((0.382)*(TenDHLAvg)));

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

BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorDarkRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorDarkRed, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorDarkRed, 0,H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorDarkRed, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorGreen, 0,L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
SetPositionSize(300,spsShares);

ApplyStop(0,1,10,1);
//-----------end--------------
Long=Flip(Buy,Short);
Shrt=Flip(Sell,Cover);

Edc=(
WriteIf (Buy , " BUY at "+C+" ","")+
WriteIf (Sell, " SEll at "+C+" ","")+
WriteIf (Cover , " Sell Stop at "+C+" ","")+
WriteIf (Short , " Buy Stop at "+C+" ","")
);
_SECTION_END();

BarColors =
IIf(BarsSince(Buy) < BarsSince(Short)
AND BarsSince(Buy)!=0, colorGreen,
IIf(BarsSince(Sell) < BarsSince(Cover)
AND BarsSince(Sell)!=0, colorRed, colorWhite));

//Plot the Candlestick charts
Plot(C, "Close", BarColors, styleNoTitle | ParamStyle("Style") | GetPriceStyle() ) ;

for( i = 0; i < BarCount; i++ )
{
//if( Buy ) PlotText( "BUY@" + C[ i ], i, C[ i ], colorWhite, colorBlue );
//if( Sell ) PlotText( "SELL@" + C[ i ], i, C[ i ], colorWhite, colorViolet );
// if( Cover ) PlotText( "Sell Stop@" + C[ i ]+ "\nSell Profit= " + ((SellPrice-CoverPrice)), i, L[ i ]-3, colorLightGrey, colorBlack );
//if( Short ) PlotText( "BuyStop@" + C[ i ]+ "\nBuy Profit= " + ((ShortPrice-BuyPrice)), i, H[ i ]+3, colorLightGrey, colorBlack );

}

_SECTION_BEGIN("Background text");
C11=ParamColor("up panel",colorBlack );
C12=ParamColor("dn panel",colorBlack );
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 );
GfxSetOverlayMode(1);
GfxGradientRect(0,0,pxwidth, pxheight, C11, C12 );
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextColor(colorBrown);
GfxSetTextAlign( 6 );
//GfxTextOut( "LTP "+WriteVal(C,1.2), Status("pxwidth")/C14, Status("pxheight")/C15);
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor(colorBrown);
GfxSelectFont("Tahoma", 20, 800, False, False, 0);
GfxSetTextColor(colorYellow);
GfxTextOut(""+edc+"", Status("pxwidth")/1.15, Status("pxheight")/C15*0.3 );



please help........


just explain entry and exit conditions in english , request


It will buy when
Close price is above the (Hourly Open price + 0.618 * (simple average of (last 30 hourly high - last 30 hourly low))).

It will exit from buy when
Close price is below the (Hourly Open price - 0.618 * (simple average of (last 30 hourly high - last 30 hourly low))).
 

arora

Well-Known Member
It will buy when
Close price is above the (Hourly Open price + 0.618 * (simple average of (last 30 hourly high - last 30 hourly low))).

It will exit from buy when
Close price is below the (Hourly Open price - 0.618 * (simple average of (last 30 hourly high - last 30 hourly low))).
Mastermind, i appreciate your quick response, i will be glad if you explain the terms

hourly open price and simple average of(last 30 hourly high - last 30 hourly low).

what i understood ?
Hourly open price means open price every one hour.
like for example 9am to 10am,open price at 9am is 100 rupees and by 10am price closed at 102, so hourly open price is 100, and at 10am to 11am, open price is 102 and by 11am price closed at 104. so hourly open price is 102.

Am i right or wrong?

however i didn't get this term
(simple average of (last 30 hourly high - last 30 hourly low)))


if you can explain i will be thankful thanks
 

casoni

Well-Known Member
however i didn't get this term
(simple average of (last 30 hourly high - last 30 hourly low)))


if you can explain i will be thankful thanks
it is simple moving average of range
[ range = last 30 hourly high - last 30 hourly low]

this formula is modified version of ADM,

http://www.wisestocktrader.com/indicators/4059-ultimate-volatility-trading-system-v-2
//----------------------------------------------------------
as per thinking there is mistakes in the formula
i.e
Buy= C>((HoursC)+((0.618)*(TenDHLAvg)));
Sell= C<((HoursC)-((0.618)*(TenDHLAvg)));
Cover= C>((HoursC)+((0.382)*(TenDHLAvg)));
Short= C<((HoursC)-((0.382)*(TenDHLAvg)));

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

it should be

Buy = C>((HoursC)+((0.618)*(TenDHLAvg)));
Sell= C<((HoursC)-((0.382)*(TenDHLAvg)));
Cover= C>((HoursC)+((0.382)*(TenDHLAvg)));
Short= C<((HoursC)-((0.618)*(TenDHLAvg)));
Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

thank you

add this , to see buy-sell-short-cover rules
Plot(HoursC,"",3,32);
Plot(HoursC+(0.618*(TenDHLAvg)),"",5,1);
Plot(HoursC-(0.618*(TenDHLAvg)),"",4,1);
Plot(HoursC+(0.382*(TenDHLAvg)),"",5,32);
Plot(HoursC-(0.382*(TenDHLAvg)),"",4,32);
 

arora

Well-Known Member
it is simple moving average of range
[ range = last 30 hourly high - last 30 hourly low]

this formula is modified version of ADM,

http://www.wisestocktrader.com/indicators/4059-ultimate-volatility-trading-system-v-2
//----------------------------------------------------------
as per thinking there is mistakes in the formula
i.e
Buy= C>((HoursC)+((0.618)*(TenDHLAvg)));
Sell= C<((HoursC)-((0.618)*(TenDHLAvg)));
Cover= C>((HoursC)+((0.382)*(TenDHLAvg)));
Short= C<((HoursC)-((0.382)*(TenDHLAvg)));

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

it should be

Buy = C>((HoursC)+((0.618)*(TenDHLAvg)));
Sell= C<((HoursC)-((0.382)*(TenDHLAvg)));
Cover= C>((HoursC)+((0.382)*(TenDHLAvg)));
Short= C<((HoursC)-((0.618)*(TenDHLAvg)));
Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

thank you

add this , to see buy-sell-short-cover rules
Plot(HoursC,"",3,32);
Plot(HoursC+(0.618*(TenDHLAvg)),"",5,1);
Plot(HoursC-(0.618*(TenDHLAvg)),"",4,1);
Plot(HoursC+(0.382*(TenDHLAvg)),"",5,32);
Plot(HoursC-(0.382*(TenDHLAvg)),"",4,32);
thanks for update, its helping me,

Only thing still i don't get is , how should i calculate

simple moving average of range
[ range = last 30 hourly high - last 30 hourly low]

what is term last 30??

do i have to HourH-HourL/30 ??? am i right?

or

30simple average of HourlyH-30Simple average of Houlry low

i need to put this formula in excel , if you can help me in this term simple moving average of range
[ range = last 30 hourly high - last 30 hourly low]

thanks
 

arora

Well-Known Member
thanks for update, its helping me,

Only thing still i don't get is , how should i calculate

simple moving average of range
[ range = last 30 hourly high - last 30 hourly low]

what is term last 30??

do i have to HourH-HourL/30 ??? am i right?

or

30simple average of HourlyH-30Simple average of Houlry low

i need to put this formula in excel , if you can help me in this term simple moving average of range
[ range = last 30 hourly high - last 30 hourly low]

thanks
Any reply please...can explain me my above question.
 

bpr

Well-Known Member
No! The code as written will not wait for candle close. However, your data feed provider may have a code that introduces delay and wait for a candle close before streaming data down into your amibroker instance.

However the real worry is not the candle close. How will you avoid all the previous fake calls?
-------------------------------------------
 
Last edited:

arora

Well-Known Member
thanks for update, its helping me,

Only thing still i don't get is , how should i calculate

simple moving average of range
[ range = last 30 hourly high - last 30 hourly low]

what is term last 30??

do i have to HourH-HourL/30 ??? am i right?

or

30simple average of HourlyH-30Simple average of Houlry low

i need to put this formula in excel , if you can help me in this term simple moving average of range
[ range = last 30 hourly high - last 30 hourly low]

thanks
Can anybody help me with my above question, Request. thanks
 

Dawood

Active Member
Dear Friends , I need this afl to take only the values of open high low and close of previous day from 3.00 pm to 3.30 pm. Please help.

SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_BEGIN("BSP");
function ParamOptimize( pname, defaultval, minv, maxv, step )
{
return Optimize( pname,
Param( pname, defaultval, minv, maxv, step ),
minv, maxv, step );
}

O1 = SelectedValue( TimeFrameGetPrice( "O", inHourly, -1 ));
H1=SelectedValue( TimeFrameGetPrice( "H", inHourly, -1 ));
L1=SelectedValue( TimeFrameGetPrice( "L", inHourly, -1 ));
C1 = SelectedValue( TimeFrameGetPrice( "C", inHourly, -1 ));


bu1 = (C1-L1)+C1;
se2 = C1-(H1-C1);
PP = (H1 + L1 + C1 + O1) / 4 ;
R1 = (2 * PP) - L1;
S1 = (2 * PP) - H1;
R2 = PP + R1 - S1;
S2 = PP + S1 - R1;
R3 = R2 + (R1 - PP);
S3 = S2 - (PP - S1);

Plot (se2,"Sell Pressure",32,4);
Plot (bu1,"Buy Pressure",27,4);

_SECTION_END();
O1-H1-L1-C1 must be the values of open high low and close of previous day from 3.00 pm to 3.30 pm only.
 

Similar threads