RTD 1-6 Source Code
RTD 1-6 Source Code
#AutoIt3Wrapper_Icon=icons\1404401545_282477.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
Developed by Josh1
Script RTD, Background backfill, Improved settings Update By Shankar4kv
Purpose - to backfill quotes automatically from NOW/Nest/Zerodha Trader
from Market watch window and Hourly Statistics
16th April, 2016
1. Added support for RTDMan2.0 with Ninja
2. Support for right+click on Scrip in marketwatch due to changes in Shift+D
by brokers
30th June, 2014
Modified by Josh1 on 21-JAN-2015
1. Removed Function Select_Scrips_from_Market_Watch
It was getting index of scrips and program crashed when user did not
select any scrip\
2. We now use Array of scrips $MarketWatchScrips that we collect in function
_Get_Scrips_from_Mwatch when we fill ListView
3. Added error catch when user did not select scrips
3. Added DeleteTics button and function to delete tics
4. $oMyret and $oMyError variable deleted - not used any where.
Version 1.20 by Josh1 on 22-JAN-2015
1. Added Index backfill functionality
2. Fixed issue of Last Scrip not backfilling with Nestplus
Version 1.3 by Josh1 on 18-AUG, 2015
1.Moved all global variables declared inside functions to top of code. That
should fix memory leak
2.Closing RTDMan.exe by processclose was creating big memory leak and
deleting preferences of Amibroker.
Fixed by using WinClose("RTDMan.exe")
3.RTD main window and Backfill window seperated.
4.Start RTD Added to backfill
5.Index Radio button was faded in Nest- Fixed
6.Hide button added to Main RTD window- by Shankar4kv
Version 1.4 by Josh1 on 18-AUG, 2015
1.Main GUI split into two.
2.GUI1 is a thin strip that can remain on top of AmiBroker
3.GUI2 for selecting Scrips backfill etc.
Version 1.5 by Josh1 on 06-MARCH, 2017
1. Index backfill from DataTable
2. Name of Backfill button in GUI1 changed to "Select"
3. Backfill now takes scrip alias from RTDMan.ini if available.
#ce
_Gui1()
Func _Gui1()
; Create GUI for Main Program
#Region ### START Koda GUI section ### Form=
If Not $hgui1 Then
$hgui1 = GUICreate("RTD V 1.60", 345, 30,900,1, BitOR($WS_MINIMIZEBOX,
$WS_SYSMENU, $WS_DLGFRAME, $WS_POPUP, $WS_GROUP, $WS_CLIPSIBLINGS))
$hLabel = GUICtrlCreateLabel("RTD V 1.60", 0, 0,365, 13, -1,
$GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x00FF00)
Local $h = 0 ;horizontal space
Local $v = 13 ; vertical space
Local $vh = 18 ; height of charachters
GUICtrlSetOnEvent($Button1, "_OnSettings")
GUICtrlSetOnEvent($Button2, "_OnHelp") ; inserted by Shankar
GUICtrlSetOnEvent($Button3, "_Gui2")
GUICtrlSetOnEvent($Button4, "_On_Rtd_Click") ; inserted by Shankar
GUICtrlSetOnEvent($Button6, "_Set_ini") ; inserted by Shankar
GUICtrlSetOnEvent($Button7, "_On_DeleteTics_Click") ; inserted by Josh1
GUICtrlSetOnEvent($Button8, "CLOSEButton") ; inserted by Josh1
GUICtrlSetOnEvent($Button9, "RTD_HIDE") ; inserted by shankar
16.08.2015
GUISetState()
EndIf
#Region .............. Set Title for Nest main window and get its handle if
open
If Not WinExists($Title) Then
MsgBox(262144, "NOW/Nest Error", "Is NOW/Nest Trader Open? " & @CRLF &
"If yes- Please Copy title of NOW/Nest Trader Window Title" & @CRLF & "it should
match exact upto version number ")
_OnSettings()
Else
$hWnd = WinGetHandle($Title) ; Get handle for NOW main window
$hWatch = ControlGetHandle($hWnd, "", 1003) ;Get handle of Market Watch
Control
if $hStat = 1 Then
WinActivate($hWnd)
Send("+P")
Local $sMessage = "If Plus Login Opens - login and wait for
Market Monitor " & @CRLF & @CRLF & _
"If chart opens - continue"
SplashTextOn("Invoking NestPlus", $sMessage, 500, 100, -1, -1,
$DLG_TEXTVCENTER, "")
Sleep(4000)
SplashOff()
EndIf
#EndRegion .............. Set Title for Nest main window and get its handle
if open
EndFunc ;==>_Gui1
Func _Gui2()
; Create GUI for Backfill
; GUICtrlSetState($Npn, $GUI_CHECKED)
GUICtrlSetOnEvent($Npy, "_OnPlusbackfill")
GUICtrlSetOnEvent($Npn, "_OnPlusbackfill")
GUICtrlSetOnEvent($Npi, "_OnIndexbackfill")
GUICtrlSetOnEvent($Button1, "_SelectAll")
GUICtrlSetOnEvent($Button2, "_DeselectAll")
GUICtrlSetOnEvent($Button3, "_On_DoBackfill_Click")
GUICtrlSetOnEvent($Button14, "_On_Rtd_Click") ; inserted by Shankar
GUICtrlSetOnEvent($Button5, "_On_Rtd_Restart") ; inserted by Shankar
GUICtrlSetOnEvent($Button7, "_On_DeleteTics_Click") ; inserted by Josh1
GUISetState()
If $Input6 <> "Nest" then GUICtrlSetState($Npi, $GUI_DISABLE )
EndIf
EndFunc ;==>_Gui2
While 1
; Wait for user instructions
$start2 = _NowCalc()
EndIf
Sleep(100)
WEnd
Func _START_STOP()
; Start stop Realtime feed by RTDMan
; To Change title of Start RTD button if RTDMan process exists
If ProcessExists("RTDMan.exe") Then
GUICtrlSetData($Button4, "STOP RTD")
EndIf
EndFunc ;==>_START_STOP
Func _Delete_Rtd_Scripts()
; Delete scrips from list
; To delete Scrips from RTDMan.ini
Local $Pre = IniRead(@WorkingDir & "\RTDMan.ini", "NestTrader", "Preserve",
"") ; Check - Preserve any scrips in Settings ?
; Copy Server name, Server prog ID, Bar period, temp. CSV folder path
from Settings Nest or NOW
$RTDMANSERVER = IniRead(@WorkingDir & "\RTDMan.ini", "NestTrader",
"Terminal", "")
$Folder = IniRead(@WorkingDir & "\RTDMan.ini", "NestTrader",
"CSVFolder", "")
$BARP = IniRead(@WorkingDir & "\RTDMan.ini",
"NestTrader", "BarPeriod", "")
$Archive = IniRead(@WorkingDir & "\RTDMan.ini", "RTDMan",
"Archive", False)
EndIf
EndFunc ;==>_Delete_Rtd_Scripts
Func _On_Rtd_Restart()
; Restart Realtime feed with changed scrip list --- to do hide part
Local $SSRTD = GUICtrlRead($Button4, 0)
; Read Button4 (Start /Stop ) text from GUI
Local $UpdRTD = IniRead(@WorkingDir & "\RTDMan.ini", "NestTrader", "UpdateRTD", "")
; Read Settings to check whether Scrips are to be updated
If $SSRTD = "STOP RTD" Then ;
If $UpdRTD = "Yes" Then
_Delete_Rtd_Scripts()
_RTD_Script_Update()
Else
MsgBox(48, "WARNING!", "(RTDMan) Realtime Feed will Restart with the same
scripts that was previously saved, Make sure you have right setting in update
script option")
EndIf
EndIf
EndFunc
Func _On_Rtd_Click()
; Start Realtime feed
;To start and Stop RTDMan.exe as required
Local $SSRTD = GUICtrlRead($Button4, 0) ; Read Button4 (Start /Stop )
text from GUI
Sleep(500)
Else
; Stop RTDMan process and Change Button4 Text to Start RTD
If WinExists("RTDMan.exe") Then ; If RTDMan not started
WinActivate("RTDMan.exe")
Send("^{BREAK}")
WinClose("RTDMan.exe")
EndIf
GUICtrlSetData($Button4, "START RTD")
If WinExists($hgui) Then
GUICtrlSetData($Button14, "START RTD")
EndIf
TrayTip("Real Time Feed Stopped", "You May START RTD Anytime", 5, 0)
EndIf
EndFunc ;==>_On_Rtd_Click
Func _FillList()
; Fill list view with scrips captured from Market watch
EndFunc ;==>_FillList
Func _On_DoBackfill_Click()
; Start Backfill
If $Ndxbackfill Then
_Get_Index_Data_from_DataTable($NdxScrips)
Else
_RTD_PLUSCHART_Update()
_Get_Text_from_VWAP_Stat_Data_Table()
EndIf
WinClose($hStat)
Else
MsgBox(64, "Real Time Data", "Select Nestplus or Vwap or Index radio
button from Source to Do Backfill", 3)
EndIf
EndFunc ;==>_On_DoBackfill_Click
Func _Get_Scrips_from_Mwatch()
; Capture scrips from market watch
Local $iItemCount = _GUICtrlListView_GetItemCount($hWatch), $i, $j
Local $iColumnCount = _GUICtrlListView_GetColumnCount($hWatch)
Local $aReturn[$iItemCount][$iColumnCount] ;= [[$iItemCount, $iColumnCount]]
For $i = 0 To $iItemCount - 1
For $j = 0 To $iColumnCount - 1
$aReturn[$i][$j] = ControlListView($hWnd, "", 1003, "GetText",
$i, $j) ; Get text of all items from Mktwatch into 2D array $aReturn
Next
Next
Func _Check_MarketWatchColumns()
; Check order of Market watch columns (This is not working with NestTrader
3.13/14/15)
; To check whether requisite columns are available in Market watcha
Next
EndFunc ;==>_Check_MarketWatchColumns
Func _RTD_Script_Update()
; Update list of scrips in ini file with other options
; To update scrips in RTDMan Settings
Local $PlusState = ControlCommand($hgui, "", $Npi, "IsChecked")
Local $CheckedScrips = 0
Local $RTNOW = IniRead(@WorkingDir & "\RTDMan.ini", "NestTrader", "Terminal",
"") ;Read RTNow settings as NEST or NOW in RTDMan.ini
Local $Pre = IniRead(@WorkingDir & "\RTDMan.ini", "NestTrader", "Preserve",
"") ;Reads the Preserve value in RTDMan.ini
EndIf
Else
$TempSymbol = $NdxScrips[$i][0]
IniWrite(@WorkingDir & "\RTDMan.ini", "RTDMan",
"Scrip" & $CheckedScrips + $Pre, $TempSymbol & ";" & $TempSymbol & ";Index
Value;;") ;Updates indexes in RTDMan.ini with Row NO as scripts number by adding
one and preserve value number
_GUICtrlListView_SetItemText($hiListView, $i, "Scrip
" & $CheckedScrips + $Pre & " Updated", 1)
EndIf
EndIf
Next
If $CheckedScrips = 0 Then
If WinActive("Backfill","") And $hiListView Then
MsgBox(64,"Real Time Data","No Scrip selected to add to
RTDMan.ini ..." & $hiListView,2)
EndIf
_Gui1()
EndIf
EndFunc ;==>_RTD_Script_Update
Func _RTD_PLUSCHART_Update()
; To display Plus chart
Next
If $CheckedScrips = 0 Then
MsgBox(64,"Real Time Data","Select atleast one Scrip Dude ...",2)
_Gui1()
EndIf
Sleep(3000)
EndIf
EndFunc ;==>_RTD_PLUSCHART_Update
Func _Get_Text_from_VWAP_Stat_Data_Table()
; This captures backfill data from VWAP/Hourly Statistics or Data Table
Opt("TrayOnEventMode", 1)
; Use event trapping for tray menu
Opt("TrayMenuMode", 3)
; Default tray menu items will not be shown.
Else
TrayItemSetText($hTray_Show_Item, "Show")
EndIf
; end - Hide RTD window if if $Hide is Yes
;Start searching checked scrips through all rows of $hilListView (Backfill Window)
Local $CheckedScrips = 0
For $i = 0 To $iRows - 1
For $tr = 1 To 3
;Try 3 times to open -I think its not needed now
; _GUICtrlListView_SetItemText($hiListView, $i, "Try-"
& $tr, 1)
_GUICtrlListView_SetItemFocused($hWatch, $i)
;focus on checked scrip in Marketwatch
;WinActivate($Title)
If $CheckedScrips = 1 Then
;Open Vwap if it is first scrip
If $RTNOWVwap = "Nest" Then
;open Hourly statistics accordingly
$hStat = WinWait("[Title:Vwap
Statistics; Class:#32770]", "", $DataDelay) ;Wait to open Vwap Statistitics and get
handle
;EndIf
Else
; $RTNOWVwap = "NOW"
EndIf
EndIf
Else
;Open Data Table
Opt("SendKeyDelay", 250)
; send keys to the tradingsymbol, Here it's
focusing but not actually selecting, so used down and up to get the actual text
selected.
$aPos =
_GUICtrlListView_GetItemPosition($hWatch, $i)
ControlClick($hWnd, $Sname1, $hWatch,
"right",1,$aPos[0]+4 ,$aPos[1]+4) ;First see if data table opens directly
ControlSend($hWnd, "", 1003, "pd")
EndIf
Next
EndIf
Local $Sname
; First get scrip name from ini file
Do
$Sread = IniRead(@WorkingDir &
"\RTDMan.ini", "RTDMan", "Scrip" & $line , "F") ; Read Scrips from ini file
Local $Sread2 = StringSplit($Sread,"|;")
; MsgBox("64","Sread",$Sread2)
If $Sread = "F" then
_GUICtrlListView_SetItemText($hiListView,
$i,"New Scrip" , 1)
$Sname = $MwatchScrips[$i][$Symbol]
& $FNO
ExitLoop
ElseIf $MwatchScrips[$i][$TSymbol] =
$Sread2[2] Then
$Sname = $Sread2[3]
EndIf
$line += 1
Until $MwatchScrips[$i][$TSymbol] = $Sread2[2]
Else
;If option, keep name as is.
$Sname = $MwatchScrips[$i][$TSymbol]
EndIf
_GUICtrlListView_SetItemText($hiListView, $i, $Sname, 4)
_GUICtrlListView_SetItemText($hiListView, $i,
"GettingData", 1)
$pos = $i
ControlFocus($hStat, "", "[CLASS:SysListView32;
INSTANCE:1]")
; Sleep(2000)
$DayDeleteFrom =
_Date_Time_Convert(GUICtrlRead($D1) & GUICtrlRead($T1), "yyyy/MM/ddHH:mm:ss",
"yyyyMMddHHmmss")
$DayDeleteUpto =
_Date_Time_Convert(GUICtrlRead($D2) & GUICtrlRead($T2), "yyyy/MM/ddHH:mm:ss",
"yyyyMMddHHmmss")
Local $T = ""
_GUICtrlListView_SetItemText($hiListView, $pos,
"Processing", 2)
$ts = TimerInit()
_GUICtrlListView_SetItemText($hiListView,$pos,
$DayDeleteUpto,2)
For $j = 0 To $STLVitemcount - 1
; Start extracting data from listview
$sText = ""
For $k = 0 To 5
_GUICtrlListView_SetItemText($hiListView,$pos,$DayDeleteFrom,1)
$sText1 =
StringReplace($sText1,":","")
EndIf
If $k = 5 And $MwatchScrips[$i]
[$Exchange] = "MCX" And $DivideVolume = "Yes" Then
$sText1 = $sText1/$MwatchScrips[$i]
[$LotQty] ;divide volume by lot qty
EndIf
$sText &= $sText1 & ","
Next
Else
For $k = 1 To 6
$sText1 = ControlListView($hStat, "",
"[CLASS:SysListView32; INSTANCE:1]", "GetText", $j, $k)
_GUICtrlListView_SetItemText($hiListView,$pos,$Checktime,1)
_GUICtrlListView_SetItemText($hiListView,$pos,$DayDeleteUpto,2)
EndIf
EndIf
If $k = 6 And $MwatchScrips[$i]
[$Exchange] = "MCX" And $DivideVolume = "Yes" Then
$sText1 = $sText1/$MwatchScrips[$i]
[$LotQty] ; Divide volume by lot Qty
EndIf
Next
EndIf
Next
If $Client="AB" Then
_DeleteTics($Sname)
EndIf
If $Plusbackfill Then
WinClose($hStat)
$hStat = 9999
EndIf
EndIf
EndIf
Next
EndFunc ;==>_Get_Text_from_VWAP_Stat_Data_Table
Func To_Tray()
; Hide RTDman(console) and RTD window and send to tray
Local $CH = WinWait("[CLASS:ConsoleWindowClass]", "", 1)
If TrayItemGetText($hTray_Show_Item) = "Hide" Then
WinSetState($CH, "", @SW_HIDE)
WinSetState("RTD V", "", @SW_HIDE)
WinSetState("Backfill", "", @SW_HIDE)
TrayItemSetText($hTray_Show_Item, "Show")
Else
WinSetState($CH, "", @SW_SHOW)
WinSetState("RTD V", "", @SW_SHOW)
WinSetState("Backfill", "", @SW_SHOW)
TrayItemSetText($hTray_Show_Item, "Hide")
EndIf
EndFunc ;==>To_Tray
Func RTD_HIDE()
; Hide RTD window 16.08.2015
EndFunc
Func On_Exit()
; Exit RTD
If $Client = "AB" Then
$oAB.SaveDatabase
$oAB = 0
EndIf
Exit
EndFunc ;==>On_Exit
Func _DeleteTics($Scrip)
; Delete existing tic data from Amibroker for selected period
Local $Filename = $DataDir & $Scrip & ".txt"
_GUICtrlListView_SetItemText($hiListView, $pos,
"Deleting pr.quotes", 1)
$ts = TimerInit()
; MsgBox(0,"","Removing quotes " &
$Scrip)
Next
; import data from csv file into AB using rtd1 format, refresh chart
and save database
With $oAB
.Import(0, $Filename, "rtd1.format")
.RefreshAll
.SaveDatabase
EndWith
Else
#cs
; User wants to delete previous quotes with Tickmode 1
Local $sString = FileReadToArray($Filename) ; read csv file into 1D
array each line will be in one element.
;Local $aString = StringSplit($sString, @CRLF, 2);
;_ArrayDisplay($sString)
Local $aRet = _ArraySortInOrder($sString) ; sort array chronologically
on start time
If Not @error Then _ArrayDisplay($aRet, "Sorted Array")
_FileWriteFromArray($Filename, $aRet, @CRLF) ; write sorted array into
csv file
; import data from csv file into AB using rtd1 format, refresh chart
and save database
#ce
With $oAB
.Import(0, $Filename, "rtd2.format")
.RefreshAll
.SaveDatabase
EndWith
EndIf
_GUICtrlListView_SetItemText($hiListView, $pos, "Done", 1)
EndFunc ;==>_DeleteTics
Func _ArraySortInOrder($aStr)
; Sort backfill data ascending before import into Amibroker
; Description - Sorts an array or a space separated string in the order of
the characters listed in a given string.
; Parameters:
; $aStr - The array, or the space separated string to be sorted.
; $sAlphabetOrder - A string containing the sorting order of the
characters which appear in the array or string.
; Requirement: #include <Array.au3>
; Returns: A sorted array.
;
;--- Convert the array ($aStr) to a string or convert the string ($aStr) to
an array.----
Local $sToSort
If IsArray($aStr) Then
For $i = 0 To UBound($aStr) - 1
$sToSort &= $aStr[$i] & " "
Next
$sToSort = StringTrimRight($sToSort, 1) ; Remove trailing space.
ElseIf IsString($aStr) Then
$sToSort = StringStripWS($aStr, 7)
$aStr = StringSplit($sToSort, " ", 2)
Else
Return SetError(0, 0, 1)
EndIf
;--->End of Convert array_string.----
For $i = 0 To UBound($aStr) - 1
$aArr[$i][0] = ($aToSort[$i])
$aArr[$i][1] = $aStr[$i]
Next
;--->End of Create 2D array
-------------------------------------------------------------
Return $aStr
EndFunc ;==>_ArraySortInOrder
Func _SelectAll()
; Select all scrips in Listview
For $i = 0 To $iRows - 1
Next
EndFunc ;==>_SelectAll
Func _DeSelectAll()
; DeSelect all scrips in Listview
For $i = 0 To $iRows - 1
_GUICtrlListView_SetItemChecked($hiListView, $i, 0)
Next
EndFunc ;==>_DeSelectAll
Func _OnPlusbackfill()
; Manage Radio buttons in backfill window
Local $PlusState
If ControlCommand($hgui, "", $Npy, "IsChecked") Or ControlCommand($hgui, "",
$Npi, "IsChecked") Then
$PlusState = True
EndIf
If $PlusState Then
ControlEnable($hgui, "", $D1)
ControlEnable($hgui, "", $D2)
Else
GUICtrlSetData($D1, _NowCalc())
GUICtrlSetData($D2, _NowCalc())
ControlDisable($hgui, "", $D1)
ControlDisable($hgui, "", $D2)
EndIf
GUICtrlSetState($Button1, $GUI_ENABLE )
GUICtrlSetState($Button2, $GUI_ENABLE )
GUICtrlSetState($Button3, $GUI_ENABLE )
GUICtrlSetState($Button7, $GUI_ENABLE )
_FillList()
EndFunc ; ==>_OnPlusbackfill
Func _OnSettings()
; Open Settings window
$Label3 = GUICtrlCreateLabel("Rename Future as" & @CRLF & "Symbol+ " & "-1/-
F1/_F1 etc.", $h, $v + 56, 140, 36)
$Input3 = GUICtrlCreateInput(IniRead(@WorkingDir & "\RTDMan.ini",
"NestTrader", "Future", ""), $h + 170, $v + 60, 150, 18)
;added on 14-4-2016
$Label18 = GUICtrlCreateLabel("Client Amibroker|Ninja Trader", $h, $v + 345,
140, $vh)
$Input18 = GUICtrlCreateCombo(IniRead(@WorkingDir & "\RTDMan.ini", "RTDMan",
"Client", "AB"), $h + 170 , $v + 345, 50, $vh)
GUICtrlSetData($Input18, "AB|NT", "")
GUISetState()
WinSetOnTop($settingsgui, "", 1)
EndIf
EndFunc ;==>_OnSettings
Func _OnSave()
; Save settings to ini file
Do
$Title = GUICtrlRead($Input1)
$DataDir = GUICtrlRead($Input2)
$FNO = GUICtrlRead($Input3)
$DataDelay = GUICtrlRead($Input4)
$Pluschart = GUICtrlRead($Input5)
$RTDMANSERVER = GUICtrlRead($Input6)
$DeleteQuote = GUICtrlRead($Input7)
$VWAPTry = GUICtrlRead($Input8)
$MinData = GUICtrlRead($Input9)
$BarPeriod = GUICtrlRead($Input10)
$RTDHide = GUICtrlRead($Input11)
$UpdateRTD = GUICtrlRead($Input12)
$Preserve = GUICtrlRead($Input13)
$Version = GUICtrlRead($Input14)
$RequestRefresh = GUICtrlRead($Input16)
$BellWaitTime = GUICtrlRead($Input17)
$Client = GUICtrlRead($Input18)
$RefreshPeriod = GUICtrlRead($Input19)
$BidAskRates = GUICtrlRead($Input20)
$BidAskQty = GUICtrlRead($Input21)
$Archive = GUICtrlRead($Archive)
$DivideVolume = GUICtrlRead($Input23)
If $RefreshPeriod < 50 Then ;Rtd man does not accept lower value than
50, if lower than 50 show warining!
MsgBox(48, "Warning!", "RTDMan Refresh Period Interval Must not
be Lower Than 50 MilliSec (1000 = 1Sec)")
ExitLoop
EndIf
Until 1
EndFunc ;==>_OnSave
Func CLOSEButton()
; Close Amibroker
If $oAB Then
$oAB.SaveDatabase
$oAB = 0
EndIf
Exit
EndFunc ;==>CLOSEButton
Func CLOSE_Gui2()
; Close backfill window
GUIDelete($hgui) ; If it was this GUI - we just delete the GUI
<<<<<<<<<<<<<<<
_Gui1()
EndFunc ;CLOSE_Gui2 ;ok
Func _OnInfo()
; Open Youtube site for help
ShellExecute("http://youtu.be/H-ZZHlZs6sM")
EndFunc ;==>_OnInfo
Func _Set_ini()
; Run shell program to write ini file
ShellExecute(@WorkingDir & "\RTDMan.ini")
EndFunc
Func _OnHelp()
; open help file
ShellExecute(@WorkingDir & "\Tutorial.chm")
EndFunc ;==>_OnHelp
Func CLOSESettings()
; close settings window
GUIDelete($settingsgui) ; If it was this GUI - we just delete the GUI
<<<<<<<<<<<<<<<
_Gui1()
EndFunc ;==>CLOSESettings
Func _On_DeleteTics_Click()
; Run program Delete_RT_Tics
$RunDeleteRT_Tics = ShellExecute ("DeleteRT_Tics.exe")
If not $RunDeleteRT_Tics Then
MsgBox(64, "DeleteTicsFailure", "Could not find the program
DeleteRT_Tics.exe in current directory")
EndIf
#cs
$DayDeleteFrom = _Date_Time_Convert(GUICtrlRead($D1) & GUICtrlRead($T1),
"yyyy/MM/ddHH:mm:ss", "yyyyMMddHHmmss")
$DayDeleteUpto = _Date_Time_Convert(GUICtrlRead($D2) & GUICtrlRead($T2),
"yyyy/MM/ddHH:mm:ss", "yyyyMMddHHmmss")
Local $DQ = IniRead(@WorkingDir & "\RTDMan.ini", "NestTrader", "DeleteQuote",
"")
Local $CheckedScrips = 0
Local $Ndxbackfill = ControlCommand($hgui, "", $Npi, "IsChecked")
If $DQ = "Yes" Then ; If Delete Quotes is yes then start deleting previous
tick data
If $Ndxbackfill Then
$TempSymbol = $NdxScrips[$i][0]
Else
EndIf
Next
If $CheckedScrips = 0 Then
MsgBox(64,"Real Time Data","Select atleast one Scrip Dude ...",2)
_Gui1()
EndIf
With $oAB
.RefreshAll
EndWith
Else
Msgbox(64, "Real Time Data", "Select Yes in the Delete Quote Option in
Settings and Try Again", 3)
EndIf
#ce
EndFunc ;==> _On_DeleteTics_Click
Func _OnIndexbackfill()
; backfill from index data table
$NdxScrips = _Get_Scrips_from_IndexValueBar()
$iRows = UBound($NdxScrips, 1)
$iCols = UBound($NdxScrips, 2)
If $iListView Then GUICtrlDelete($iListView) ; if Listview is already
present, delete it
GUICtrlSetState($Button1, $GUI_ENABLE )
GUICtrlSetState($Button2, $GUI_ENABLE )
GUICtrlSetState($Button3, $GUI_ENABLE )
GUICtrlSetState($Button7, $GUI_ENABLE )
EndFunc
Func _Get_Scrips_from_IndexValueBar()
; capture indexes from index value bar
Local $iItemCount = _GUICtrlListView_GetItemCount($hNdxWatch), $i, $j
Local $iColumnCount = _GUICtrlListView_GetColumnCount($hNdxWatch)
Local $aReturn[$iItemCount][$iColumnCount] ;= [[$iItemCount, $iColumnCount]]
If Not $iItemCount Then ;if there is no index then show msg box, Added by
josh 24-01-2015
MsgBox(64, "No Index found", "Add atleast one index in Index Watch",2)
Return
EndIf
For $i = 0 To $iItemCount - 1
For $j = 0 To $iColumnCount - 1
$aReturn[$i][$j] = _GUICtrlListView_GetItemText($hNdxWatch,
$i, $j)
Next
Next
Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn)
MsgBox(64, "Real Time Data", "Insert Altleast one Index in your
Nest Index value bar", 3)
EndFunc ;==>_Get_Scrips_from_IndexValueBar
For $tr = 1 to 3
_GUICtrlListView_SetItemText($hiListView,$i,"Try-" &
$tr,1)
Sleep(1000)
_GUICtrlListView_ClickItem($hNdxWatch,$i,"right")
Sleep(1000)
ControlSend(("[CLASS:#32768]"), "",0, "p")
; Sleep(2000)
; $hChart = WinWait("[Title:Intraday Chart : ]" &
$Sname, "", $DataDelay) ; Wait to chart window and get handle
Sleep(5000)
; ControlSend($hChart,"",1020,"^D")
; Now open data table from Plus chart
ControlClick($hWnd,"Intraday
chart",1020,"right",1,15,15)
Sleep(1000)
ControlSend($hWnd, "Intraday chart",1020, "D")
$pos = $i
_GUICtrlListView_SetItemText($hiListView, $pos,
"Processing", 2)
$ts = TimerInit()
_GUICtrlListView_SetItemText($hiListView,$pos,
$DayDeleteUpto,2)
For $j = 0 To $STLVitemcount - 1
$sText = ""
For $k = 1 To 6
$sText1 = ControlListView($hStat, "",
"[CLASS:SysListView32; INSTANCE:1]", "GetText", $j, $k)
_GUICtrlListView_SetItemText($hiListView,$pos,$Checktime,1)
;_GUICtrlListView_SetItemText
($hiListView,$pos,$Checktime,2)
EndIf
EndIf
Next
Next
_GUICtrlListView_SetItemText($hiListView,$pos,"Data
retrieved",1)
;FileDelete($DataDir & $Sname & ".txt")
If Not FileExists($DataDir) Then DirCreate($DataDir)
If $Client="AB" Then
_DeleteTics($Sname)
EndIf
_GUICtrlListView_SetItemText($hiListView, $pos, "Done", 1)
WinClose($hStat)
$hStat=9999
EndIf
EndIf
Next
If $CheckedScrips = 0 Then
MsgBox(64,"Real Time Data","Select atleast one Scrip Dude ...",2)
_Gui1()
EndIf
EndFunc ;==>_Get_Text_from_Hourly_Statistics