Re: XTL Buy Arrow

#1
Hi all,

Following is the xtl formula.

_SECTION_BEGIN("xtl");
tgt = 35;
a = CCI(20) < -tgt;
b = CCI(20) > tgt;
state = IIf(a>b,-1,IIf(a==b,0,1));
Color = IIf(state == 0, colorBlack, IIf(state == 1, colorLime, IIf(state == -1, colorRed, 0)));


I would to have buy arrow for the following the condition.

Here are the values for the bar when CCI(20)> tgt

O = 342
H = 350
L = 340
C = 348

The range for this bar is 10 (i.e. 350-340)

I would like to get buy arrow at value of 355 i.e. adding half of the range to the high of the trigger bar.

350 + ((350-340)/2) = 355

Can anyone help me on this?

Thanks
Amruta
 

sr114

Well-Known Member
#3
mam....
1. how come u can have 0.5*range before the completion of the candle?
2. though we formulate it; it will always be in buy state as already the half of the range mark has been crossed.

plz correct me if i'm wrong

it will always be in the buy state - only it can be filtered by some other condition but will be always on.

strange strategy

rgds
subroto
 
#4
As I mentioned, when CCI(20) > tgt - It is an uptrend.

However, I want to buy only when the price reach at High plus the half of the range of the trigger bar.

This way I will be out off some whipsaws.

I hope you understand what my logic is.


Thanks
Amruta
 

sr114

Well-Known Member
#5
As I mentioned, when CCI(20) > tgt - It is an uptrend.

However, I want to buy only when the price reach at High plus the half of the range of the trigger bar.

This way I will be out off some whipsaws.

I hope you understand what my logic is.


Thanks
Amruta
Amruta

formulate ur complete strategy - then it wud be possible for us to comprehend the logic. ( buy and sell logic also)

posted the code for u - but remaining part is the sell logic - explain it also
then the full code will be ready

rgds
subroto
 
#6
tgt = 35;
uptrend = CCI(20) > tgt;
downtrend = CCI(20) < -tgt;


Buy

Reference Bar - It is the bar when CCI(20) > 35 i.e. uptrend.

Follwoing are the four values for the reference bar.

O = 342
H = 350
L = 340
C = 342

The range for this bar is 10 (i.e. 350-340)

I would like to get buy arrow at value of 355 i.e. adding half of the range to the high of the reference bar.

350 + ((350-340)/2) = 355


So I will buy only if the price reaches 355. Otherwise I will not buy. This price could be in future after 3-5 bars.



Sell

Reference Bar - It is the bar when CCI(20) < -35 i.e. downtrend.

Follwoing are the four values for the reference bar.

O = 348
H = 350
L = 340
C = 342

The range for this bar is 10 (i.e. 350-340)

Sell arrow at value of 335 i.e. deducting half of the range from low of the reference bar.

340 - ((350-340)/2) = 335


So I will sell only if the price reaches 335. Otherwise I will not Sell.


There will beno trade when the value of CCI(20) is between +35 and -35.



Regards
Amruta
 
#8
Simple :)

Code:
_SECTION_BEGIN("CCI");
t	=	Param("CCI Limit", 35, 0,200,5);
BO	=	H+(H-L)/2;				BD	=	L-(H-L)/2;		
BO	=	IIf(Cross(CCI(20), t), BO, Ref(BO,-1));
BD	=	IIf(Cross(-t,CCI(20)), BD, Ref(BD,-1));
UP	=	Cross(H,BO);			DN	=	Cross(BD,L);
UP	=	ExRem(UP,DN);			DN	=	ExRem(DN,UP);
PlotShapes(shapeUpArrow  *  UP,colorWhite,0,L,-30);
PlotShapes(shapeDownArrow * DN,colorWhite,0,H,-30);
_SECTION_END();


Cheers
::thumb::
 
#9
Hi Parttime Trader

Look at the attched picture.

As you can see it shows lots of buy/sell arrows and this is what I am looking for.


Does anyone know how to get buy/sell arrow as per the strategy mentioned into post #6 here.


Thanks
Amruta
 
Last edited:
#10
The code is as per the logic you have given, test it by plotting the BO/BD lines and plot the CCI in a diff pane below the price pane.

Code:
Plot(BO,"",colorBlueGrey, styleDashed | styleStaircase);
Plot(BD,"",colorLime,       styleDashed | styleStaircase);
Cheers
::thumb::
 

Similar threads