Simple Coding Help - No Promise.

Happy I think he is looking for something like this.....for a given swing (need a way to decide this) give alerts at specified fibonnacci levels

just showing fibonnacci levels for morning fall of today as e.g.

Happy Singh Ji

I need an exploration, which will alert the Fibonacci retracement values when a price crosses it for a swing,the complete swing can be intraday or overnight.

This will be on a 5 minute time frame.

For example for a swing of intraday high and intraday low, the exploration should alert that the price has crossed the fibonacci values which can be changed like 23%,50%. etc.

Thanks
Amit
Code:
_SECTION_BEGIN("FIB_Range");
n    = Param("Num of Bars",10,2,50,1);
Hi   = SelectedValue(HHV(H,n));
Lo   = SelectedValue(LLV(L,n));
D    = Hi - Lo;
P50  = Hi-D/2; 
M50  = Lo-D/2;
P150 = Hi+D/2;

Plot(SelectedValue(Hi),"100%",colorBlue,styleDashed,0,0,10);
Plot(SelectedValue(Lo)," 0%",colorRed,styleDashed,0,0,10);
Plot(SelectedValue(P50),"50%",colorLightGrey,styleDashed,0,0,10);
Plot(SelectedValue(P150),"50%",colorBlueGrey,styleDashed,0,0,10);
Plot(SelectedValue(M50),"-50%",colorLime,styleDashed,0,0,10);
_SECTION_END();
How to use the above code.

The above code does not try to determine the swing high or low or range over which swing high/lows are made.

We need to select the first bar of the range (swing high or low) for which we want to plot range and other SR lines.

Set the parameter Num of Bars.

For now have added 0,50,100,150 & -50%, its easy to add any other levels of your choice.

:) Happy
 
Hello Happy and Pratap sir, I have this AFL..quit nice AFL after market close..but during market hour this blue and red arrow keep changing.....anyway to fix this arrow that after completing a 5 min bar this arrow will not be changed ( actually what happen in real time is that once a bar close and that have suppose blue or red arrow upside ..after 2-3 bar market condition change and that arrow disappear or change it position)....I want in AFL that once a red or blue formed top of the bar that should not changed after that..if condition changes then there can be new arrow formed in next bar
Thanks
From what you write, its obvious the AFL looks into future and adjusts the Buy/Sell signals depending on the data that happens hours/minutes after the signal is generated.

Just avoid these type of systems, cannot be used for trading.

Cheers

:) Happy
 
Happy Singh Ji

I need an exploration, which will alert the Fibonacci retracement values when a price crosses it for a swing,the complete swing can be intraday or overnight.

This will be on a 5 minute time frame.

For example for a swing of intraday high and intraday low, the exploration should alert that the price has crossed the fibonacci values which can be changed like 23%,50%. etc.

Thanks
Amit
Amit

Lots of things are missing in your requirement. Please think it through.

Why exploration? How many scrips do u intend to run this for? and how frequently do you intend to run it?; Do you intend to use High low of the current day or one day prior or high/low within few days past?

To be very honest, Fib retracements are best detected by using the built in tool that Ami provides. You manually draw it between the High low that you feel are significant and then define the study name. AFL then simply has to alert on a cross relative to the named study. But that approach will not work with exploration.


Alert Levels as percentage
 

dell

Well-Known Member
after whole day work i am able to code it , plz take a look on it and if any improvement needed than plz .............

_SECTION_BEGIN("wilder multitimeframe");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
w=Wilders(C,20);
CandlCol = IIf(L > w, colorGreen, IIf(H < w, colorRed,colorYellow));
SetBarFillColor(IIf(C < O, CandlCol, GetChartBkColor()) );
Plot(C,"",CandlCol,styleCandle|styleNoTitle);
Plot(W, "Wilders", IIf(w > Ref(w,-1), colorGreen, colorRed),styleThick);

Cond1= Ref(Cross(C,w),-1) AND O>w AND C>MA(C,200)AND ADX(14)>15 AND C>MA(C,100) AND RSI(14)>30;

Cond2=Cross(w,C);
cond5=cross(c,w);
//PlotShapes(Cond1*shapeHollowUpArrow,colorBlue,0,L,-10);
//PlotShapes(Cond2*shapeHollowDownArrow,colorBlack,0,H,-10);


TimeFrameSet(inDaily);

wd = Wilders(C,20);
m1= MA(C,200);
a1=ADX(14);
r1=RSI(14);
TimeFrameRestore();


K = TimeFrameExpand(wd, inDaily);
m= TimeFrameExpand(m1, inDaily);
a=TimeFrameExpand(a1, inDaily);
r=TimeFrameExpand(r1, inDaily);


Cond3=Ref(Cross(C,k),-1) AND O>k AND C>m AND a>15 AND r>30;
Cond4=Cross(K,C);
cond6=cross(c,k);
CandlCol = IIf(L > k, colorGreen, IIf(H < w, colorRed,colorViolet));

Plot(k, "Wildersdaily", IIf(k > Ref(k,-1), colorGreen, colorRed),styleThick);


//PlotShapes(Cond3*shapeUpArrow,colorGreen,0,L,-20);
//PlotShapes(Cond4*shapeDownArrow,colorRed,0,H,-20);

Buy=Cond1 AND Cond3;
Sell=Cond2;
Short=Cond2 AND Cond4;
Cover=Cond5;
//Buy=ExRem(Buy,Sell);
//Sell=ExRem(Sell,Buy);
PlotShapes(Buy*shapeUpArrow,colorGreen,0,L,-35);
PlotShapes(Sell*shapeDownTriangle,colorRed,0,H,-35);
PlotShapes(Short*shapeDownArrow,colorRed,0,L,-35);
PlotShapes(Cover*shapeUpTriangle,colorGreen,0,H,-35);

_SECTION_END();

but i stuck at below condition ;
if buy triggered at daily than at my trading tf (30m)all buy signals r taken and traded and sell on triggering in 30m..........no short trades r taken....... buy sell arrows according to above condition ........

same on short side , if short triggered in daily than all short trades r taken and no buy trades r there .........and cover short trades on 30m tf ......buy sell arrows are there according to above condition ..........

i want to backtest this idea , plz take a look on this .............
 
Last edited:
after whole day work i am able to code it , plz take a look on it and if any improvement needed than plz .............

_SECTION_BEGIN("wilder multitimeframe");
....

TimeFrameSet(inDaily);

....

_SECTION_END();


First, you are missing a call to TimeFrameRestore.

Second whenever you expand from higher to lower, same data is copied and that is why you get multiple signals ...
 

ocil

Well-Known Member
Hi Friends,
Can you advice me which indicator is batter for intraday no 1 or no 2.
Below is the back-test result for 2 indicators. script is same, time frame is same, lot size is same. Thanks for your help.

1)(579 row) Profit=1161.74(0.00%),CAR=0.00%,MaxSysDD= -113.57(-0.00%)CAR/MDD = 8.45, #winners =322 (55.61%), # losers = 257 (44.39%)

2)(354 row) Profit=984.10(0.00%),CAR=0.00%,MaxSysDD= -55.93(-0.00%)CAR/MDD = 14.53, #winners =190 (53.67%), # losers = 164 (46.33%)
 

extremist

Well-Known Member
@ ocil
depend on individual with so close figures
by simple numbers 1st looks better
but if some one like me with lill conservative thoughts i would prefer 2nd
coz no. of trades produced r less and importantly max draw down is much lower than the 1st one. this will never put me in more danger as in 1st one.
i would definitely vote for the 2nd one.
 

ocil

Well-Known Member
@ ocil
depend on individual with so close figures
by simple numbers 1st looks better
but if some one like me with lill conservative thoughts i would prefer 2nd
coz no. of trades produced r less and importantly max draw down is much lower than the 1st one. this will never put me in more danger as in 1st one.
i would definitely vote for the 2nd one.
Thanks Extremist for your thought. :)
 

toughard

Well-Known Member
respected sir

can you help me in setting this right?

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

_SECTION_BEGIN("TIPS ROBOTICA");
p = 10;
q = 20;
m = EMA(C,p);
n = EMA(C,q);
Plot(m," MA",IIf(m < Ref(m,-1),colorBlue,colorRed),styleThick);
Plot(n," MA",IIf(n < Ref(n,-1),colorBlue,colorRed),styleThick);

UP = m > n;
DN = m < n;

Buy = UP
Sell = DN
Buy = ExRem(Buy,Sell); Sell = ExRem(Sell,Buy);
Short = DN
Cover = UP
Short = ExRem(Short,Cover); Cover= ExRem(Cover,Short);
PlotShapes(Buy+2*Short,colorWhite,0,IIf(Buy,L,H),-24);
PlotShapes(Cover*3+4*Sell,colorWhite,0,IIf(Cover,L,H));
_SECTION_END();


its not working!

please help

toug
 

amitrandive

Well-Known Member
Amit

Lots of things are missing in your requirement. Please think it through.

Why exploration? How many scrips do u intend to run this for? and how frequently do you intend to run it?; Do you intend to use High low of the current day or one day prior or high/low within few days past?

To be very honest, Fib retracements are best detected by using the built in tool that Ami provides. You manually draw it between the High low that you feel are significant and then define the study name. AFL then simply has to alert on a cross relative to the named study. But that approach will not work with exploration.


Alert Levels as percentage
Happy Singh Ji thanks for the code.
MasterMind, I agree with you completely.This can be checked out manually using a very few scrips.

Thanks for your input.:clapping:
 

Similar threads