Nguyễn Vinh Bình
Tel$: 0886.525.798 TPBank
Telegram
Nhận định cổ phiếu
Zalo
Hỏi đáp cổ phiếu
Bản đồ quy hoạch
Soi quy hoạch toàn quốc
Giao dịch Bất động sản
Sàn Bất động sản giá tốt
Code bắn tín hiệu mua bán tự động từ Amibroker vào Telegram
_SECTION_BEGIN( "Gui tin hieu vao telegram" ); SetChartOptions( 0, chartShowArrows | chartShowDates ); //_N( Title = StrFormat( "BINHMYCO 0886525798: {{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) ); Plot( C, "Close", colorDefault, styleNoTitle | GetPriceStyle() ); // 1. Heiken Ashi 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 ) ); xDiff = ( HaHigh - Halow ); barcolor = IIf( HaClose >= HaOpen, colorBrightGreen, colorRed ); //PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle ); // 2. Bolinger Bands BBTop = BBandTop( H, 12, 2 ); BBBot = BBandBot( L, 12, 2 ); BBMid = ( BBTop + BBBot ) / 2; KC2Bien = ( 100 * ( BBTop - BBBot ) ) / BBBot; //Bo so TK = Param( "TK", 9 ); KJ = Param( "KJ", 17 ); CK = Param( "CK", 26 ); DG1 = Param( "DG1", 65 ); DG2 = Param( "DG2", 129 ); //Cong thuc cac duong chi bao TKS = ( HHV( H, TK ) + LLV( L, TK ) ) / 2; KJS = ( HHV( H, KJ ) + LLV( L, KJ ) ) / 2; CKS = C; DG65 = ( HHV( H, DG1 ) + LLV( L, DG1 ) ) / 2; DG129 = ( HHV( H, DG2 ) + LLV( L, DG2 ) ) / 2; SPA = ( TKS + KJS ) / 2; SPB = ( HHV( H, CK ) + LLV( L, CK ) ) / 2; // return Difference by Percentage, Unit : % function DiffPercent( inA, inB ) { return ( inA / inB - 1 ) * 100; } // return Absolute Difference by Percentage, Unit : % function AbsDiffPercent( inA, inB ) { return abs( DiffPercent( inA, inB ) ); } KC2Kiem = Optimize( "Max k/c (%)", 0.6, 0, 2, 0.01 ); //Dieu kien giao dich DKL = Cross( HaClose, BBMid ) AND C > O AND xDiff > 1 AND ADX( 14 ) < 40 //AND BBMid > Ref( BBMid, -1 ) // AND KC2Bien > 0.3 ; DKS = Cross( BBMid, HaClose ) AND C < O AND xDiff>1 //AND KJS <= Ref( KJS, -1) //AND BBMid < Ref( BBMid, -1 ) //AND KC2Bien > 0.3 ; CL = (TKS > Ref (TKS, -1) AND KJS == Ref (KJS, -1) AND TKS > KJS AND C > KJS AND AbsDiffPercent(TKS, KJS) >= KC2Kiem) ; CS = (TKS < Ref (TKS, -1) AND KJS == Ref (KJS, -1) AND TKS < KJS AND C < KJS AND AbsDiffPercent(TKS, KJS) >= KC2Kiem) ; Buy = DKL; Sell = DKS; //Buy = ExRem( Buy, Sell ); //Sell = ExRem( Sell, Buy ); Short = CL AND CL != DKS; Cover = CS AND CS != DKL; //Short = ExRem( Short, Buy ); //Cover = ExRem( Cover, Sell ); TelegramAlerts = ParamTrigger("Telegram Alert","Send Alert"); TelegramAPI_ID = "1836076122:AAHVsCfgWr4JDyYG4NDnRyaAtpJP8PMSDz8"; // API_ID cua BOT TelgramCHAT_ID = "@BinhMycoPhaisinh"; // ID cua Channel EnableScript("VBScript"); <% Public Sub Telegram(Message_Text) sAPI_ID = AFL.Var("TelegramAPI_ID") sChat_ID = AFL.Var("TelgramCHAT_ID") sMSG = Message_Text 'URL to open.... sUrl = "https://api.telegram.org/bot" & sAPI_ID & "/sendMessage" 'POST Request to send. sRequest = "text=" & sMSG & "&chat_id=" & sChat_ID set oHTTP = CreateObject("Microsoft.XMLHTTP") oHTTP.open "POST", sUrl,false oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" oHTTP.setRequestHeader "Content-Length", Len(sRequest) oHTTP.send sRequest HTTPPost = oHTTP.responseText 'Store response 'msgbox(objXmlHttpMain.responseText) 'response.Write (objXmlHttpMain.responseText) End Sub %> tang = GetScriptObject(); if (LastValue(ValueWhen(Buy[BarCount - 2] == True,BarIndex())==BarIndex()) AND StaticVarGet(Name()+GetChartID()+"buyAlert")==0 ) { tang.Telegram(Now(1) + ": LONG " + BuyPrice + " SL <" + (BuyPrice-3)); StaticVarSet(Name()+ GetChartID() + "buyAlertBar", LastValue(TimeNum())); } if (LastValue(TimeNum()) == StaticVarGet(Name()+GetChartID()+"buyAlertBar")) StaticVarSet(Name()+GetChartID()+"buyAlert",1); //alert was triggered, no more alerts on this bar else StaticVarSet(Name()+GetChartID()+"buyAlert",0); // new bar formed, and alerts can be trigered. giam = GetScriptObject(); if (LastValue(ValueWhen(Sell[BarCount - 2] == True,BarIndex())==BarIndex()) AND StaticVarGet(Name()+GetChartID()+"sellAlert")==0 ) { giam.Telegram(Now(1) + ": SHORT " + SellPrice + " SL >" + (SellPrice+3)); StaticVarSet(Name()+ GetChartID() + "sellAlertBar", LastValue(TimeNum())); } if (LastValue(TimeNum()) == StaticVarGet(Name()+GetChartID()+"sellAlertBar")) StaticVarSet(Name()+GetChartID()+"sellAlert",1); //alert was triggered, no more alerts on this bar else StaticVarSet(Name()+GetChartID()+"sellAlert",0); // new bar formed, and alerts can be trigered. donglong = GetScriptObject(); if (LastValue(ValueWhen(Short[BarCount - 2] == True,BarIndex())==BarIndex()) AND StaticVarGet(Name()+GetChartID()+"shortAlert")==0 ) { donglong.Telegram(Now(1) + ": Close Long " + ShortPrice ); StaticVarSet(Name()+ GetChartID() + "shortAlertBar", LastValue(TimeNum())); } if (LastValue(TimeNum()) == StaticVarGet(Name()+GetChartID()+"shortAlertBar")) StaticVarSet(Name()+GetChartID()+"shortAlert",1); //alert was triggered, no more alerts on this bar else StaticVarSet(Name()+GetChartID()+"shortAlert",0); // new bar formed, and alerts can be trigered. dongshort = GetScriptObject(); if (LastValue(ValueWhen(Cover[BarCount - 2] == True,BarIndex())==BarIndex()) AND StaticVarGet(Name()+GetChartID()+"coverAlert")==0 ) { dongshort.Telegram(Now(1) + ": Close Short " + CoverPrice); StaticVarSet(Name()+ GetChartID() + "coverAlertBar", LastValue(TimeNum())); } if (LastValue(TimeNum()) == StaticVarGet(Name()+GetChartID()+"coverAlertBar")) StaticVarSet(Name()+GetChartID()+"coverAlert",1); //alert was triggered, no more alerts on this bar else StaticVarSet(Name()+GetChartID()+"coverAlert",0); // new bar formed, and alerts can be trigered. _SECTION_END();
Nhận xét
Tìm kiếm
Lượt xem
Đăng nhận xét