pts afl code

#1
Hello Friends,
I am Bharat. And I am new for Amibroker AFL Coding.
I need help of you to complete my afl code.
Strategy is that,
Scenario 1:
from today's Open if price goes up and it will reach till level 'L2' then "Long" order should be generated and sell order should be generated at 'L3' level. If price movement will not move as expected to level 'L3" and goes down towards today's Open then stop loss should be the today's Open.

Scenario 2:
From today's Open if price goes down and it will reach till level 'S2' then "Short" order should be generated and target should be 'S3', other ways if price movement will not move as expected to level "S3" and goes up towards today's Open, then stop loss should be triggered as today's Open.

Thanks.
The code is given below:


_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();

////////////////code for open////////////////////////
_SECTION_BEGIN("trace open");
O1 = SelectedValue( TimeFrameGetPrice( "open", inDaily, 0 ) );
Plot( O1, "DAY_Open",colorWhite );
PlotText( "Day Open" , BarCount-25, O1, 0 );
_SECTION_END();

////////////////code for LTP////////////////////////
_SECTION_BEGIN("trace LTP");
L1 = SelectedValue( TimeFrameGetPrice( "short", inDaily, 0 ) );
Plot( L1, "LTP",colorGrey40 );
PlotText( "LTP" , BarCount-35, L1, colorGrey40 );
_SECTION_END();

////////////////code for long////////////////////////
_SECTION_BEGIN("Long");
L2 = Param("Long",20,1,50,1) + O1;
Plot( L2, "Long",colorGreen );
PlotText( "Long" , BarCount-15, L2, colorGreen );

L3 = Param("Target",20,1,100,1) + L2;
Plot( L3, "L3",colorGreen );
PlotText( "L3" , BarCount-15, L3, colorGreen );


_SECTION_END();

////////////////code for short////////////////////////
_SECTION_BEGIN("Short");
S2 = Param("Short",-20,-50,0) + O1;
Plot( S2, "Short",colorRed );
PlotText( "Short" , BarCount-15, S2, colorRed );

S3 = Param("Cover",-20,-100,0) + S2;
Plot( S3, "S3",colorRed );
PlotText( "S3" , BarCount-15, S3, colorRed );

_SECTION_END();
/*
if (Close (L1 <= S2));
{
Buy;
}


for( i = 0; i < BarCount; i++ )
{if( Buy ) PlotText( "Buy\n@" + e[ i ], i, L[ i ]-dist, colorBrightGreen );
if( Sell ) PlotText( "Sell\n@" + e[ i ], i, H[ i ]+dist,
colorRed);
}
*/

/*
_SECTION_BEGIN("ORDER");
if (L1 <= S2)
{
Buy;
}

Buy = Cross(L1, L2);

Short = Cross(L1, L3);
Cover = Cross(L1, s3);



shapelong = Buy *shapeUpArrow + Sell *shapeDownArrow;

PlotShapes(shapelong, IIf(Buy, colorBlue, colorYellow), IIf(Buy, Low, High));

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

_SECTION_END("ORDER");
*/
 

MewarLion

Active Member
#2
Welcome to Traderji

Please take benefit from Trading Community. You may also contribute for benefit of other users of the Forum.

Please read the FORUM RULE http://www.traderji.com/rules.php

We have many good threads here, specially in "Beginner's Guide". So go through the reading material, take your time looking at the market moves. Don't rush
 

Similar threads