Simple Coding Help - No Promise.

cellclinic

Well-Known Member
Hello Bro ...

I need help for the Kelthner Channel formula to be written for following requirements included for amibroker 5.5 .

MA Period : 39 ( or adjustable )
MA Mode : 3 ( or adjustable )
Price Mode : 5 ( or adjustable )
ATR Period : 20 ( or adjustable )
K : 0.02 ( or adjustable )

http://postimg.org/image/3zrfqienz/
 
Happy Singh

Please help :sos:
Filter = 1 will give you all the rows in the data set . . .

You just had to make the changes that Pratap has already told you . . .


:) Happy



amit just replace

filter = 1

with the relevant condition you want

like

cond1 = .....
cond 2 = .....

filter = cond1 or cond2 ;
replace filter line I said

Buy=diffd1>0 AND diffh1>0 AND diff30a>0 AND diff15a>0 AND diff5a>0;
Sell=diffd1<0 AND diffh1<0 AND diff30a<0 AND diff15a<0 AND diff5a<0;

filter = buy or sell ;

(assuming buy and sell condition is written correctly)

remove filter = 1 and filter = 2 line..... also I think Add Column lines should be after Filter statement
 

amitrandive

Well-Known Member
Filter = 1 will give you all the rows in the data set . . .

You just had to make the changes that Pratap has already told you . . .


:) Happy
Happy Singh , I have made the changes suggested and am attaching the Screen shot of the Scan.I am not able to make the requirements that I have marked.

Please overlook my ignorance, I do not have any knowledge of Amibroker coding.

 
i want time of days high and low
in doing this i tried for

x=ValueWhen(C==HHV(C,BarsSince(Day() != Ref(Day(),-1))+1),TimeNum());

but i want value of x as the time at which Days high was fallen

Plz anybody help me...

Happy sir or anybody who can plz help me
Have you tried HHVBars?
 

KelvinHand

Well-Known Member
Happy Singh , I have made the changes suggested and am attaching the Screen shot of the Scan.I am not able to make the requirements that I have marked.

Please overlook my ignorance, I do not have any knowledge of Amibroker coding.


The draft idea for the last column is

AddTextColumn(Writeif(Buy, "Buy", WriteIf(Sell, "Sell", "")), ....);


The rest you figure out yourself.


This is most difficult part for people to tell you.
:cool:
 
Last edited:
The draft idea for the last column is

AddTextColumn(Writeif(Buy, "Buy", WriteIf(Sell, "Sell", "")), ....);


The rest you figure out yourself.


This is most difficult part for people to tell you.
You can see for yourself, you squeeze until all the software expert don't want to answer you.:cool:

How we wish people would make more use of the search facility on the forum . . . .


Code:
DN = C > tdstba*1.05 OR C < tdstba*0.95;
UP = C > tdstsa*1.05 OR C < tdstsa*0.95;
Buy  = UP AND NOT DN;
Sell = DN AND NOT UP;
Filter =  Buy OR Sell;
[B]AddTextColumn(WriteIf(Buy, "TDST Buy", "TDST Sell"), "Signal", 1.2, IIf(Buy,colorGreen,colorRed));
[/B]AddColumn(IIf(Buy, tdstba, tdstsa), "value");
AddColumn(Close, "close", 1.2, colorBlack);

the above code is on this same thread, just a few posts back,

we can replace our condition for buy // sell . . . and
change the strings to whatever we want to display . . . .

for e.g.

AddTextColumn(WriteIf(Buy, "Buy","Sell"),"Signal", 1.2,IIf(Buy,colorGreen,colorRed));


:) Happy
 

XRAY27

Well-Known Member
hi
happy and pratap sir,
in the below afl i want horizontal line for buytarget at entry+(entry*0.0038) and for selltarget as entry-(entry*0.0038)

_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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("25");
MO=EMA(C,10);
ML=EMA(C,34);


Plot(MO,"",colorBlue,styleDashed);
Plot(ML,"",4,styleDashed);

Buy = Cross(MO,ML);
Sell = Cross (ML,MO);


dist = 1.5*ATR(10);

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Buy " + H[ i ], i, H[ i ]-dist,2, colorGreen );
if( Sell ) PlotText( "SELL " + L[ i ], i, L[ i ]+dist, colorRed, colorYellow );
}

PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorYellow, colorYellow ) );
AlertIf(Cross(MO,ML), "SOUND C:\\Windows\\Media\\Ringin.wav", "BUY", 2 );
AlertIf(Cross(ML,Mo), "SOUND C:\\Windows\\Media\\Ringin.wav","SELL", 2 );



_SECTION_END();
 
Last edited:

KelvinHand

Well-Known Member
Hello Bro ...

I need help for the Kelthner Channel formula to be written for following requirements included for amibroker 5.5 .

MA Period : 39 ( or adjustable )
MA Mode : 3 ( or adjustable )
Price Mode : 5 ( or adjustable )
ATR Period : 20 ( or adjustable )
K : 0.02 ( or adjustable )

http://postimg.org/image/3zrfqienz/

The ProTrader V1.0 was not efficient enough.

The following script is for Version 5.60 and above
PHP:
// -- Modified from ProTrader v1.0 
// -- http://www.wisestocktrader.com/indicators/3156-protrader-v1-0
// -- ProTrader V2.0
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);

SetBarFillColor(IIf(C>O,ParamColor("Candle Up Color",colorBrightGreen),
							IIf(C<=O,ParamColor("Candle Down Color",colorRed),colorLightGrey)));//Up=Lime/Down=Red

Plot(C,"Price",IIf(C>O,ParamColor("Shadow Up Color",colorLightGrey),
		IIf(C<=O,ParamColor("Shadow Down Color",colorLightGrey),colorLightGrey)),64,0,0,0,0);//Up=DarkGreen/Down=DarkRed/64=Candle/128=Bar

SetChartBkColor(ParamColor("Panel Color",colorBlack));
SetChartBkGradientFill(ParamColor("Upper Chart",colorBlack),ParamColor("Lower Chart",colorBlack));

GraphXSpace=Param("GraphXSpace",20,-10,25,1);

if(ParamToggle("Horizontal PriceLine","Show|Hide",0))
{
	PriceLineColor= colorPaleBlue;
	PriceLevel=C; 
	Daysback= 100; 
	FirstBar= BarCount - DaysBack; 
	YY= IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null); 
	Plot(YY,"Current Price",PriceLineColor,styleLine|styleDashed|styleNoTitle|styleNoLabel,maskAll);
	Side=1; 
	Dist=0; 
	for(i = 0; i < BarCount; i++ ) 
		if(i+Side== BarCount) PlotText("\n    " + PriceLevel[ i ], i, YY[ i ]-Dist[i], colorBlack ); 
}

BarTime1=LastValue(TimeNum() - Now(4));  
DataError=IIf(Now(4) > TimeNum(),True,False); 
TimeBase=IIf(Interval(1)>0,1,0); 
_N(StrBarTime=NumToStr(BarTime1,1.0,False)); 
BT_Length=StrLen(StrBarTime); 
_N(TimeLeft_= 
WriteIf(BT_Length==1,"0:0"+StrBarTime,WriteIf(BT_Length==2,"0:"+StrBarTime, 
WriteIf(BT_Length==3,StrLeft(StrBarTime,1)+":"+StrRight(StrBarTime,2), 
StrLeft(StrBarTime,2)+":"+StrRight(StrBarTime,2))))); 
TimeLeft=WriteIf(TimeBase==1,TimeLeft_,"N/A"); 
_SECTION_END();

_SECTION_BEGIN("KelvinHand");
procedure GetTriggerLines(p1, p2)
{
global TL1, TL2;
TL1 = LinearReg(C, p1);
TL2 = EMA(TL1, p2);
}

procedure GetKBands(KBandMid, ATRPeriods, K)
{
global KBandTop, KBandBot;

KBandTop=KBandMid + K * ATR( ATRPeriods );
KBandBot=KBandMid - K * ATR( ATRPeriods );

}

_SECTION_END();


_SECTION_BEGIN("Keltner Band");
Version(5.6);
//-- Created by KelvinHand on 2013-Dec-15

KC_Mode = ParamList("Band Mode", "SMA|EMA|SSMA|LWMA",2);
Periods = Param("Keltner Periods", 28, 2, 300, 1 );
P = ParamField("Price field",3);

ATRPeriods = Param("ATR Periods", 0, 0, 300, 1 );
if (ATRPeriods==0) ATRPeriods=Periods;
K = Param("K Factor", 3.50, 0, 10, 0.05 );


switch (KC_Mode)
{

  case "EMA":  KBandMid=EMA(P, Periods); break;
  case "SSMA": KBandMid=Wilders(P, Periods); break;
  case "LWMA": KBandMid=WMA(P, Periods); break;
  default:  	 KBandMid=MA(P, Periods); break;
}


GetKBands(KBandMid, ATRPeriods, K);

NOTe1=ParamStr("Style 1", "### MidBand ###");
KCMidW=Param("KCMid Width",3,0,10);
KCMidS=ParamStyle("KCMid Style",styleNoLabel|styleNoRescale);
KCMidCUp = ParamColor("KCMid Up Color", colorAqua);
KCMidCDn = ParamColor("KCMid Dn Color", ColorRGB(0,191,255));

ColM = IIf(C>KBandMid,KCMidCUp,KCMidCDn);
Plot( KBandMid, "KC.Mid" , ColM,KCMidS,Null,Null,0,0, KCMidW);


NOTe2=ParamStr("Style 2", "### OuterBand ###");
KCOutW=Param("KCOuter Width",3,0,10);
KCOutS=ParamStyle("KCOuter Style",styleNoLabel|styleNoRescale);
KCOutC = ParamColor("KCOuter Color", colorGrey40);

Plot( KBandTop, "KC.Top", KCOutC,KCMidS,Null,Null,0,0, KCOutW);
Plot( KBandBot, "KC.Bot", KCOutC,KCMidS,Null,Null,0,0, KCOutW);

_SECTION_END();

_SECTION_BEGIN("Small_TL");
p1 = Param("TL1.Periods", 20, 5, 50, 1);
p2 = Param("TL2.Periods", 5, 3, 25, 1);
GetTriggerLines(p1, p2);


_O = IIf(TL1>TL2, TL1, TL2);
_H = IIf(TL1>TL2, TL1, TL2);

_C = IIf(TL1>TL2, TL2, TL1);
_L = IIf(TL1>TL2, TL2, TL1);


Col1 = IIf(TL1 > TL2, ParamColor("Up_Color", colorLime), ParamColor("Dn_Color", ColorRGB(255,0,255)));

//PlotOHLC(_O, _H, _L, _C, _SECTION_NAME(), Col1, styleCloud|styleNoLabel, Null, Null, 0, -1);
Plot(TL1, _SECTION_NAME()+"1", Col1, styleThick|styleNoLabel);
Plot(TL2, _SECTION_NAME()+"2", Col1, styleThick|styleNoLabel);
_SECTION_END();

_SECTION_BEGIN("Large_TL");
p1 = Param("TL1.Periods", 80, 5, 100, 1);
p2 = Param("TL2.Periods", 20, 3, 100, 1);
GetTriggerLines(p1, p2);

_O = IIf(TL1>TL2, TL1, TL2);
_H = IIf(TL1>TL2, TL1, TL2);

_C = IIf(TL1>TL2, TL2, TL1);
_L = IIf(TL1>TL2, TL2, TL1);
Col1 = IIf(TL1 > TL2, ParamColor("Up_Color", colorBlue), ParamColor("Dn_Color", colorRed));

//PlotOHLC(_O, _H, _L, _C, _SECTION_NAME(), Col1, styleCloud|styleNoLabel, Null, Null, 0, -2);
Plot(TL1, _SECTION_NAME()+"1", Col1, styleThick|styleNoLabel);
Plot(TL2, _SECTION_NAME()+"2", Col1, styleThick|styleNoLabel);
_SECTION_END();
 
Last edited:

Similar threads