I can Create AFL but Need Strategy

#31
Hello friends,


I have one afl in these afl there are two color candle one is green and second is red. These aft give buy sell signal ( If price go above line buy and if price below line short ) But i want Buy and sell call on candle color when Green candle is come buy and when red candle is come means short.
If any one can do pls try these.

Alf code here.

_SECTION_BEGIN("NICK MA Swing");
SetBarsRequired(200,0);

GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k = Optimize("K",Param("K",1,0.25,5,0.25),0.25,5,0.25) ;
Per= Optimize("atr",Param("atr",4,3,20,1),3,20,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorBlack, styleCandle | styleNoLabel );
j=Haclose;

//================================================== ================================================== ===================
//=========================Indicator================ ================================================== ============================
f=ATR(14);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;
NW[0] = 0;


for(i = 1; i < BarCount; i++)
{
if(Trend[i-1] == 1)
{
if(j < NW[i-1])
{
Trend = -1;
NW = j + Revers;
}
else
{
Trend = 1;
if((j - Revers) > NW[i-1])
{
NW = j - Revers;
}
else
{
NW = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j > NW[i-1])
{
Trend = 1;
NW = j - Revers;
}
else
{
Trend = -1;
if((j + Revers) < NW[i-1])
{
NW = j + Revers;
}
else
{
NW = NW[i-1];
}
}
}
}

//===============system================

Plot(NW, "", IIf(Trend == 1, 27, 4), 4);
Buy=Cover=Ref(Cross(j,nw),-1);
Sell=Short=Ref(Cross(nw,j),-1);
BuyPrice=SellPrice=CoverPrice=ShortPrice=O;
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
_SECTION_END();
//=================TITLE============================ ================================================== ==================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorWhite)+ "NICK MA Swing System" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+
WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
 

rohitsx

Active Member
#34
I use the Magic T Trading system, if i give the rules, will u code it for me.
 
#36
Hi,
Can you write few lines of codes which can create like this below features.

In the chart left side there should be 8-10 small buttons
upon clicking each button the chart shows its pictures as per it's particular afl.
when other button clicked the previous afl picture chart should be gone and new afl chart be shown.
in each button one afl stored as user wants can change 'from the edit formula popup window.
-------------------------------------------------------------------------------------

another further scenario in this one is,
each button contain one afl and in that afl it should send into the candlestick chart , only buy / sell signal - one signal onto the chart with arrow mark.
like that each button should send similarly upon clicking , without erasing the other afls signals.
in that each button, it should contain each afl with the following indicators like stochastic, macd, rsi, w%r, cci, ema, nma, south-breeze, etc etc with buy sell conditions in each one separately. sending the buy/sell arrow signals upon the price chart.
each button and it's arrows should have same color upon it different buttons diff colors.
 
Last edited:
#39
Friends
As i have good knowledge of programming, So i can Create AFL for the given strategy but I dont know much about Technical Analysis.
So if you have a good technical strategy then share with me and i will code it for our benifit and we can discuss everything here
Condition based on Opeing Price

Buy

Buyentry=Openprice+(openprice*0.382%)
tgt1=entryprice+(entryprice*0.618%)
tgt2=entryprice+(entryprice*1%)
If buy trigger stoploss starts days low and trailing

Sell

Sellentry=Openprice-(openprice*0.382%)
tgt1=entryprice-(entryprice*0.618%)
tgt2=entryprice-(entryprice*1%)
If sell trigger stoploss starts days high and trailing

Also need the Messageboard
 

sr114

Well-Known Member
#40
Hello I want One AFL for intraday
Every One hour I want High and low display.
screen shots


afl code

Code:
 // Intraday Statregy - Hourly Hilo

 _SECTION_BEGIN("Price");
 SetChartOptions(0,chartShowArrows|chartShowDates);
 SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack));
 upbar= H > Ref(H,-1) AND L > Ref(L,-1);
 dnbar= H < Ref(H,-1) AND L < Ref(L,-1);
 
 SetBarFillColor(IIf(upbar,ParamColor("Candle UP Color", colorGreen),IIf(dnbar,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
 Plot(C,"Close",IIf(upbar,ParamColor("UP Color", colorDarkGreen),IIf(dnbar,ParamColor("Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);

 grid_day = IIf(Day()!=Ref(Day(),-1),1,0); 
 Plot(grid_day,"",colorGrey50,styleHistogram|styleDots|styleNoLabel|styleOwnScale);

 _SECTION_END();

 //.....................................................
 HiDay = TimeFrameGetPrice("H", inDaily);
 LoDay = TimeFrameGetPrice("L", inDaily);
 //Plot(HiDay ,"",colorGrey40,styleDashed); // ,styleOwnScale);
 //Plot(LoDay ,"",colorGrey40,styleDashed); // , styleOwnScale);

 //================================
 HiHrly = TimeFrameGetPrice("H", inHourly);
 LoHrly = TimeFrameGetPrice("L", inHourly);
 Plot(HiHrly ,"",10,styleLine); 
 Plot(LoHrly ,"",50,styleLine); 

 PlotShapes(shapeSmallCircle*(H==HiDay),colorOrange,0,H,20);
 PlotShapes(shapeSmallCircle*(L==Loday),colorSkyblue,0,L,-20);

 //PlotShapes(shapeStar*(H==HiHrly),4,0,H,20);
 //PlotShapes(shapeStar*(L==LoHrly),51,0,L,-20);

 GraphXSpace =5;
 _SECTION_BEGIN("trending ribbon");

 GraphXSpace=20;
 uptrend		=PDI()>MDI()AND Signal()<MACD();
 downtrend		=MDI()>PDI()AND Signal()>MACD();

 Plot( 1, /* defines the height of the ribbon in percent of pane width*/"ribbon",
 IIf( uptrend, colorBrightGreen, IIf( downtrend, colorRed, 0 )), /* choose color */styleOwnScale|styleArea|styleNoLabel, -1, 100 );



 _SECTION_END();

 if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
 {
 ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1.0 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
 }

 Title = EncodeColor(colorBrightGreen)+ "Hourly  Hi ~ Lo  [Subroto- 29032013 ]" + "\n" + Name() + "\n " + EncodeColor(colorBrightGreen)+ Interval(2) 
 + EncodeColor(colorBrightGreen) + " | " + Date() +" | "
 +"\n"+EncodeColor(10) +"Open ="+O +","+" High ="+H +" ,"+" Low ="+L +","+ " Close ="+C + "\nVolume : "+ WriteVal(V,1.0)
 +EncodeColor(colorBrightGreen) + "\n\nDay's Range = Rs." + EncodeColor(colorBrightGreen) + StrToNum(NumToStr((HiDay - LoDay), 1.2))+ "\n"
 +EncodeColor(colorWhite) + "Day's Hi =  Rs." + EncodeColor(colorWhite) + Hiday + "\n" 
 +EncodeColor(colorWhite) + "Day's Lo=  Rs." + EncodeColor(colorWhite) + Loday + "\n" + "\n"
 +EncodeColor(colorBrightGreen) + "Hrly Range = Rs." + EncodeColor(colorBrightGreen) + StrToNum(NumToStr((Hihrly - Lohrly), 1.2))+"\n"
 +EncodeColor(colorWhite) + "Hrly Hi  = Rs." + EncodeColor(colorWhite) + HiHrly + "\n" 
 +EncodeColor(colorWhite) + "Hrly Lo = Rs." + EncodeColor(colorWhite) + LoHrly + "\n" +"\n";


 _SECTION_BEGIN("Magnified Market Price");
 //by Vidyasagar, [email protected]//
 FS=Param("Font Size",28,11,100,1);
 GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
 GfxSetBkMode( colorWhite );
 GfxSetTextColor( ParamColor("Color",colorViolet) );
 Hor=Param("Horizontal Position",350,1,1200,1);
 Ver=Param("Vertical Position",1,1,1,1);
 GfxTextOut("Cls : "+C,Hor , Ver );

 YC=TimeFrameGetPrice("C",inDaily,-1);
 DD=Prec(C-YC,2);
 xx=Prec((DD/YC)*100,2);
 GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
 GfxSetBkMode( colorWhite );
 GfxSetTextColor(ParamColor("Color",colorYellow) );
 //GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
 _SECTION_END();
rgds
subroto
 

Similar threads