Simple Coding Help - No Promise.

Hello Happy ji,Pratap ji n seniors

I need help to draw a exploration...

Conditions below :-

1. buy when macd gives bullish signal and adx is above 25 .
2. sell when macd gives negative signal or u get decent 25 points or market is closed.
3. short when macd gives bearish signal and adx is above 25.
4. cover when macd gives bullish signal or u get decent 25 points or market is closed.

( Conditions posted by Masterstroke in his thread -
http://www.traderji.com/technical-analysis/93368-macd-adx-deadly-combo.html)


Kindly help for the same...

Thanx you in advance
Hello shruti

Lets try the do it yourself approach . . .

To start with post any exploration, from your collection.

Something that would be similar to the one you need

If you can't get similar then any will do . . .

If you learn to do it for one case then it will be easy for other cases.


Happy :)
 
do you expect me to search then spoon feed you the post no....this forum has thread tools like search which you could have used to find if you wanted to......everybody wants to just sit back and make others do the work.....sorry I am not going to do that, especially since you chose to mock with LOL for not giving the code on a platter.

FYI it took me less than a minute to find it...I have searched and got the post number but you make the effort and get it

P.S. let each person find it themselves. those you get it take the code...but don't post the link here....let people interested show that they are really interested by making at least this small effort to get it
With few people exibit this attitude (maybe even unintentionally) it puts off many helping hands here at Traderji,

Just to give one example, Kelvin.Hand. . . who has far better coding skills than most of us here :thumb:
and also many other members have stopped or avoid responding to queries,
unless the person asking seems to be making a genuine effort

Pratap besides running his two legendary threads, has been helping on this thread consistently and patiently. :thumb:

Many of the AFL coding help/problems that can be addressed here on this thread are of common nature and most of them are already tackled / addressed before on this thread.

What we are trying to do is help with small issues that will take 10-15 minute of our time,
but for the person who is stuck it can save a few days of frustrating efforts . . .
However we cannot handle offering solutions like converting to AFL from different platforms or
debugging or coding entire systems that may take anywhere from 2 hours to 2/3 days.

Most of the members understand these constrains are are ready to put in efforts from their side.

Few have even offered a :cheers: but a glass of Lassi will do for me :D

Anyway lets settle back to "Simple Coding Help" and pass it on to others . . .


Happy :)
 
do you expect me to search then spoon feed you the post no....this forum has thread tools like search which you could have used to find if you wanted to......everybody wants to just sit back and make others do the work.....sorry I am not going to do that, especially since you chose to mock with LOL for not giving the code on a platter.

FYI it took me less than a minute to find it...I have searched and got the post number but you make the effort and get it

P.S. let each person find it themselves. those you get it take the code...but don't post the link here....let people interested show that they are really interested by making atleast this small effort to get it
****************************
allright ok could have edited his post too ... but ok i will stop
 
Last edited:
Hi Happy ji and other AFL experts,

I am working on a strategy requested by a friend which requires me to get Previous days highest PVI and also todays highest PVI.

Could you please help by providing this code.

Vijay
 

Nehal_s143

Well-Known Member
Hi Happy ji and other AFL experts,

I am working on a strategy requested by a friend which requires me to get Previous days highest PVI and also todays highest PVI.

Could you please help by providing this code.

Vijay
Try this

_SECTION_BEGIN("High");
Plot( C, "Close", ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
twDC=TimeFrameGetPrice( "C", inDaily, -1);
twdh=TimeFrameGetPrice( "H", inDaily, 0);
twdh1=TimeFrameGetPrice( "H", inDaily, -1);

Plot(twdh, "",colorRed,styleDashed);
Plot(twdh1, "",colorYellow,styleDashed);

_SECTION_END();

What is PVI ? above afl will mark and plot yesterday high and today's high
 
Strategy works based on highest and lowest price and PVI so I wrote below code, but was not able to code for same for PVI as I was not able to find TimeFrameGetPrice equivalent for PVI.

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, "", IIf(O>=C, colorRed, colorGreen), ParamStyle("Price Style",styleCandle,maskPrice));

PevH = TimeFrameGetPrice("H", inDaily, -1);
PevL = TimeFrameGetPrice("L", inDaily, -1);
PevClose = TimeFrameGetPrice("C", inDaily, -1);
GfxTextOut( ("Prev Day High: " + PevH + " Low : " + PevL + " Close : " + PevClose ), 30 ,30);
Plot(PevH ,"",colorBlue,styleStaircase|styleSwingDots|styleNoRescale);
Plot(PevL ,"",colorRed,styleStaircase|styleSwingDots|styleNoRescale);
Plot(PevClose ,"",colorGreen,styleStaircase|styleSwingDots|styleNoRescale)

But what I require is same high and low for PVI which is nothing but Positive Volume Index indicator which is by default available as AFL in Amibroker Indicators.

If you find it confusing, even if u can provide code for previous days Highest and Lowest RSI, it would be of great help for me, I can make requried changes later with PVI
 

amitrandive

Well-Known Member
Hello shruti

Lets try the do it yourself approach . . .

To start with post any exploration, from your collection.

Something that would be similar to the one you need

If you can't get similar then any will do . . .

If you learn to do it for one case then it will be easy for other cases.


Happy :)
Happy Singh

Found this on the net and modified it slightly.Please advise if it is correct.

Code:
_SECTION_BEGIN("ADX +MACD");
// This combines two indicators into one timing Signal
//function ParamOptimize( description, default, minv, maxv, step )
//    { return Optimize(description, Param(description,default, minv, maxv, step ), minv, maxv, step ); }
tgl = ParamToggle("Result", "AND logic|Compare");
// adx di lines
range = Param("ADX Periods", 10, 2, 200, 1 );
myPdi = PDI(range );
myMdi = MDI(range );
upAdx = IIf( myPdi > myMdi, 1, 0);
// macd 
r1 = Param( "Macd Fast avg", 12, 2, 200, 1 );
r2 = Param( "Macd Slow avg", 26, 2, 200, 1 );
r3 = Param( "Macd Signal avg", 9, 2, 200, 1 ); 
myMacd = MACD(r1,r2);
mySignal = Signal(r1,r2,r3);
upMacd = IIf(myMacd  > mySignal, 1, 0);
// switch test calculation and compare the results
if(tgl)
{
myBuy =upAdx  AND upMacd;
myShort = !upAdx AND !upMacd; 
}
else
{
myBuy = IIf(myMacd > mySignal AND myPdi > myMdi,1,0);
myShort = IIf(myMacd < mySignal AND myPdi < myMdi,1,0);
}
Buy = Cover = ExRem(myBuy, myShort);
Short = Sell = ExRem(myShort, myBuy);
// exploration
Filter = Buy OR Short; 
AddColumn(Close, "Close", 1.2);
AddColumn(Buy, "Buy", 1.0);
AddColumn(Short, "Short",1.0);
_SECTION_END();
But not able to define values for ADX and the other required logic.
 
Hello Amit

All the 4 conditions are given in the post requesting the AFL . . .
Just convert line for line English to AFL :)

Code:
range = Param("ADX Periods", 10, 2, 200, 1 );
r1 = Param( "Macd Fast avg", 12, 2, 200, 1 );
r2 = Param( "Macd Slow avg", 26, 2, 200, 1 );
r3 = Param( "Macd Signal avg", 9, 2, 200, 1 ); 
myADX = ADX(range);
myMacd = MACD(r1,r2);
mySignal = Signal(r1,r2,r3);

//1. Buy when MACD gives bullish Signal AND ADX is above 25 .
Buy = myMacd > mySignal AND myADX > 25;
//2. Sell when MACD gives negative Signal OR u get decent 25 points OR market is closed. 
Sell = myMacd < mySignal OR Cross(H, ValueWhen(Buy,Close)+25) OR TimeNum()>152500;
//3. Short when MACD gives bearish Signal AND ADX is above 25. 
Short = myMacd < mySignal AND myADX > 25;
//4. Cover when MACD gives bullish Signal OR u get decent 25 points OR market is closed.
Cover = myMacd > mySignal  OR Cross(ValueWhen(Short,Close)-25,L) OR TimeNum()>152500; 

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short, Cover);
Cover= ExRem(Cover,Short);
// exploration
Filter = Buy OR Short; 
AddColumn(Close, "Close", 1.2);
AddColumn(Buy, "Buy", 1.0);
AddColumn(Short, "Short",1.0);
_SECTION_END();
Happy :)
 
System is positional system. we will exit the trade only when the stoploss/ trailing stoploss hits.
we have to take 74 ema value daily on closing basis.
Buy rules :-
for eg:
1.On march 14, 74 ema is 6345 then at 15th march, buy @ 74 ema +10= 6355 with stoploss : 74ema -20 .

2,Once the buy SL tiggered then at same price reverse to sell with 30 points Stoploss.
3. If the market goes in favour of our buy trade. Take 74 ema of the previous day closing and subtract it to 20 for the tomo stoploss eg: if market closes 74 ema at 6375 then move the stoploss to 6375 -20 on the next day


Sel rules :-
1.on the march 14 74 ema is 6345 then at 15th march, sell at 74 ema -10=6335 with stoploss 74 ema +20.
2. Once the sell stoploss trigerred reverse to buy.
3.if the market goes in favour of our sell trade. Take 74 ema of the previous day closing and add it to 20 for the tomo stoploss eg: if market closes 74 ema at 6375 then move the stoploss to 6375 +20 on the next day..

I would be really thankful if someone can help me with afl



Please do ask in case of doubts
 

Similar threads