forked from heathermils98/AFL_code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scan realtime loop.afl
120 lines (95 loc) · 4.2 KB
/
Scan realtime loop.afl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
_SECTION_BEGIN("RSI_Alert");
RSI_alert = ParamToggle("RSi_Alert", "No|Yes",0);
period = Param("period", 10, 1,100,1);
r = RSI(period);
Buy = Cross(r, 20);
Sell = Cross(r, 80);
TelegramAlerts = ParamTrigger("Telegram Alert","Send Alert");
TelegramAPI_ID = ParamStr("Telegram Bot API Key","1200942736:AAEG8y9qyJ7aHefUm4vt_xKqkNBxfKd3qCc");
// TelgramCHAT_ID = ParamStr("Telegram Channel ID","@Victor_AlgoTrading");
TelgramCHAT_ID = ParamStr("Telegram Channel ID","@Victor_realtime");
Message = numtostr(C) + " Spead = " + NumToStr(H - L) + " Volume = " + NumToStr(V) + " " + WriteVal(ROC(V, 1), 1.2) + ROC(V, 1) + " "
+ " \n" + TimeNum() + " " + Interval() ;
current_time = DateTimeToStr(Now(5), 5) ;
printf(current_time + "\n");
config_timestamp = StrToDateTime("2022-11-02 01:30:00");
for(shift=0; shift <= 60; shift++)
{
compared_time = DateTimeToStr( DateTimeAdd( config_timestamp, shift, in1Minute ), 5) ;
printf(compared_time + "\n");
if(current_time == compared_time)
{
exportPath = "C:\\Program Files\\AmiBroker\\ExportedImages\\";
fmkdir(exportPath);
AB = CreateObject("Broker.Application");
ABDocs = AB.Documents;
AD = ABDocs.Item(1); // Use the first chart only - set your default layout accordingly
ADWindows = AD.Windows;
AD.Name = Name();
AW = AB.ActiveWindow; //SelectedTab = 1;
// filename = Name() + " " + Interval(2) + " " + StrReplace(StrReplace(Now(0), "/", "-"), ":", ".") + ".png";
filename = Name() + " " + Interval(2) + " " + StrReplace(StrReplace(DateTimeToStr(Now(5), 3 ), "/", "-"), ":", ".") + ".png";
AW.ExportImage(exportPath + filename);
// Test Debug AW.ExportImage(exportPath + Name() + "-" + "10/29/2022 1.27.32 AM" + ".png");
Message1 = "Buy@1h@" + Name()+" " + C;
arguments = Message1 + " " + filename;
ShellExecute("C:\\Users\\Admins\\Desktop\\stock_price\\pythonfile\\test1.py", arguments , "C:\\Bot\\", 1 );
ih = InternetOpenURL("https://api.telegram.org/bot"+ TelegramAPI_ID + "/sendMessage?chat_id="+TelgramCHAT_ID+"&text=" + Message );
InternetClose(ih);
// fdelete(exportPath + filename);
fdelete(exportPath + "Screenshot_5" + ".png");
}
}
// if(Buy[BarCount - 1] == 1 OR Sell[BarCount - 1] == 1 OR TelegramAlerts)
if(current_time == compared_time)
{
exportPath = "C:\\Program Files\\AmiBroker\\ExportedImages\\";
fmkdir(exportPath);
AB = CreateObject("Broker.Application");
ABDocs = AB.Documents;
AD = ABDocs.Item(1); // Use the first chart only - set your default layout accordingly
ADWindows = AD.Windows;
AD.Name = Name();
AW = AB.ActiveWindow; //SelectedTab = 1;
// filename = Name() + " " + Interval(2) + " " + StrReplace(StrReplace(Now(0), "/", "-"), ":", ".") + ".png";
filename = Name() + " " + Interval(2) + " " + StrReplace(StrReplace(DateTimeToStr(Now(5), 3 ), "/", "-"), ":", ".") + ".png";
AW.ExportImage(exportPath + filename);
// Test Debug AW.ExportImage(exportPath + Name() + "-" + "10/29/2022 1.27.32 AM" + ".png");
Message1 = "Buy@1h@" + Name()+" " + C;
arguments = Message1 + " " + filename;
ShellExecute("C:\\Users\\Admins\\Desktop\\stock_price\\pythonfile\\test1.py", arguments , "C:\\Bot\\", 1 );
ih = InternetOpenURL("https://api.telegram.org/bot"+ TelegramAPI_ID + "/sendMessage?chat_id="+TelgramCHAT_ID+"&text=" + Message );
InternetClose(ih);
// fdelete(exportPath + filename);
fdelete(exportPath + "Screenshot_5" + ".png");
}
GfxSetBkMode(1);
X=750;
Y=1;
Font=10;
GfxSetTextColor( colorGold );
GfxTextOut(DateTimeFormat("%H:%M:%S", Now(5)), x+100, y+10 );
// GfxTextOut( DateTimeToStr( NUMBER, mode = 0 ) x+100, y+10 );
GfxSelectFont( "Century Gothic", 15, 100, False );
printf(DateTimeFormat("%H:%M:%S", Now(5)));
/*
GfxSetBkMode(1);
X=750;
Y=1;
Font=10;
GfxGradientRect( 1, 1, 1400, 40, colorGrey50, colorDarkGrey);
GfxSetBkMode(0);
GfxSelectFont( "Georgia", 18, 800, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "ULTIMATE VOLATILITY EXPERT ", x+600, y+10 );
GfxSelectFont( "Tahoma", 16, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( Name(), x+100, y+10 );
GfxSelectFont( "Century Gothic", 15, 100, False );
GfxSetTextColor( colorWhite );
GfxTextOut( Date(), x+1000, y+10 );
GfxSelectFont( "Comic Sans MS", 15, 500, False );
GfxSetTextColor( colorYellow );
GfxTextOut( Interval(2), x+275, y+10 );
*/
_SECTION_END();