function varargout = managerCode(varargin)
% MANAGERCODE MATLAB code for managerCode.fig
%      MANAGERCODE, by itself, creates a new MANAGERCODE or raises the existing
%      singleton*.
%
%      H = MANAGERCODE returns the handle to a new MANAGERCODE or the handle to
%      the existing singleton*.
%
%      MANAGERCODE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MANAGERCODE.M with the given input arguments.
%
%      MANAGERCODE('Property','Value',...) creates a new MANAGERCODE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before managerCode_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to managerCode_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help managerCode

% Last Modified by GUIDE v2.5 12-May-2016 20:41:28

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @managerCode_OpeningFcn, ...
                   'gui_OutputFcn',  @managerCode_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before managerCode is made visible.
function managerCode_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to managerCode (see VARARGIN)

% Choose default command line output for managerCode
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes managerCode wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = managerCode_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in btnLoad.
function btnLoad_Callback(hObject, eventdata, handles)
% hObject    handle to btnLoad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global hist_date hist_high hist_low hist_open hist_close hist_vol selection;

 if (strcmp(selection, 'Yahoo'))   
    
    elstartday1 = str2num(get(findobj('Tag','elstartday'),'string'))
    elstartmonth1 = str2num(get(findobj('Tag','elstartmonth'),'string'))
    elstartyear1 = str2num(get(findobj('Tag','elstartyear'),'string'))
    elendday1 = str2num(get(findobj('Tag','elendday'),'string'))
    elendmonth1 = str2num(get(findobj('Tag','elendmonth'),'string'))
    elendyear1 = str2num(get(findobj('Tag','elendyear'),'string'))

    if((get(findobj('Tag','rbtnWeek'),'Value') == 1))
        [hist_date, hist_high, hist_low, hist_open, hist_close, hist_vol] = get_hist_stock_data('COKE',elstartday1, elstartmonth1, elstartyear1, elendday1, elendmonth1, elendyear1,'w')
    else
        [hist_date, hist_high, hist_low, hist_open, hist_close, hist_vol] = get_hist_stock_data('COKE',elstartday1, elstartmonth1, elstartyear1, elendday1, elendmonth1, elendyear1,'d')
    end
 
 else  
    elstartday1 = get(findobj('Tag','elstartday'),'string')
    elstartmonth1 = get(findobj('Tag','elstartmonth'),'string')
    elstartyear1 = get(findobj('Tag','elstartyear'),'string')
    elendday1 = get(findobj('Tag','elendday'),'string')
    elendmonth1 = get(findobj('Tag','elendmonth'),'string')
    elendyear1 = get(findobj('Tag','elendyear'),'string')
    
     %mydata = Quandl.get('CME/CK2015', 'start_date','2013-01-01','end_date','2015-01-01')
     if((get(findobj('Tag','rbtnWeek'),'Value') == 1))
        mydata = Quandl.get('CME/CZ2016', 'start_date',strcat(elstartyear1, {'-'}, elstartmonth1, {'-'}, elstartday1),'end_date',strcat(elendyear1, {'-'}, elendmonth1, {'-'}, elendday1),'collapse','weekly')
     else
        mydata = Quandl.get('CME/CZ2016', 'start_date',strcat(elstartyear1, {'-'}, elstartmonth1, {'-'}, elstartday1),'end_date',strcat(elendyear1, {'-'}, elendmonth1, {'-'}, elendday1),'collapse','daily') 
     end  
     
     %CH2015 pro rok 2014 - uz neplati
     %CH2016 pro roky 2015 a 2016 - uz neplati
     
     %pro obdobi 1.1.2014 az 31.8.2015 - CZ2015 !
     mydata.TimeInfo.Format = 'dd-mm-yyyy';
       
     hist_date = getabstime(mydata)
     hist_date = datestr(hist_date)
     hist_date = strcat({''} ,hist_date, {''} )
     %hist_date = datestr(hist_date)
     hist_high = mydata.High.Data
     hist_low = mydata.Low.Data
     hist_open = mydata.Open.Data
     hist_close = mydata.Settle.Data
     hist_vol = mydata.Volume.Data
end
    a = [hist_high hist_low hist_open hist_close]
    set(findobj('Tag','tblData'),'Data',a);

% --- Executes on selection change in lbxTrendInd.
function lbxTrendInd_Callback(hObject, eventdata, handles)
% hObject    handle to lbxTrendInd (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns lbxTrendInd contents as cell array
%        contents{get(hObject,'Value')} returns selected item from lbxTrendInd


% --- Executes during object creation, after setting all properties.
function lbxTrendInd_CreateFcn(hObject, eventdata, handles)
% hObject    handle to lbxTrendInd (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over btnLoad.
function btnLoad_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to btnLoad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btnPrepoc.
function btnPrepoc_Callback(hObject, eventdata, handles)
% hObject    handle to btnPrepoc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global hist_close today_close last_ma;

%today_close = str2double(get(findobj('Tag','txtTodayValue'),'Value'))

%if (get(findobj('Tag','lbxTrendInd'),'Value') == 1)
%    set(findobj('Tag','txtVysl'),'String',ma(hist_close));
%elseif (get(findobj('Tag','lbxTrendInd'),'Value') == 2)
%    set(findobj('Tag','txtVysl'),'String',exp_ma(last_ma, today_close));
%end


% --- Executes on button press in btnClose.
function btnClose_Callback(hObject, eventdata, handles)
% hObject    handle to btnClose (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close all;



function txtTodayValue_Callback(hObject, eventdata, handles)
% hObject    handle to txtTodayValue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global today_close
% Hints: get(hObject,'String') returns contents of txtTodayValue as text
  today_close = str2double(get(hObject,'String')) %returns contents of txtTodayValue as a double


% --- Executes during object creation, after setting all properties.
function txtTodayValue_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtTodayValue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in btnVyktesli.
function btnVyktesli_Callback(hObject, eventdata, handles)
% hObject    handle to btnVyktesli (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global hist_high hist_low hist_date hist_close hist_vol willResult fastStochResult slowStochResult histMACDResult hist_open

if  (get(findobj('Tag','chbxClose'),'Value') == 1)
   h = figure
   set(h, 'Position', [100, 50, 1200, 600])
   drawPrice(hist_date, hist_open, hist_close, hist_low, hist_high);
end

if (get(findobj('Tag','chbxSimpless'),'Value') == 1)
    h9 = figure
    set(h9, 'Position', [100, 50, 1200, 600])
    drawSimpless(hist_date,hist_close);
end

if (get(findobj('Tag','chbxExp'),'Value') == 1)
    h8 = figure
    set(h8, 'Position', [100, 50, 1200, 600])
    drawExp(hist_date,hist_close);
end

if (get(findobj('Tag','chbxDirectional'),'Value') == 1)
    h2 = figure
    set(h2, 'Position', [100, 50, 1200, 600])
    drawDirectSystem(hist_date, hist_high, hist_low, hist_close)
end

if (get(findobj('Tag','chbxWilliams'),'Value') == 1)
    h3 = figure
    set(h3, 'Position', [100, 50, 1200, 600])
    willResult = drawWilliamsR(hist_date, hist_open, hist_close, hist_low, hist_high, hist_vol)
end

if (get(findobj('Tag','chbxMACDhist'),'Value') == 1)
    h4 = figure
    set(h4, 'Position', [100, 50, 1200, 600])
    histMACDResult = drawMACD(hist_date, hist_close)
    if(histMACDResult == 1) 
        set(findobj('Tag','txtMACDhist'),'String','Trend changed - Buy!');
    end
end

if (get(findobj('Tag','chbxFastStoch'),'Value') == 1)
    h5 = figure
    set(h5, 'Position', [100, 50, 1200, 600])
    drawFastStochastic(hist_date, hist_open, hist_close, hist_low, hist_high, hist_vol)
end

if (get(findobj('Tag','chbxSlowStoch'),'Value') == 1)
    h6 = figure
    set(h6, 'Position', [100, 50, 1200, 600])
    slowStochResult = drawSlowStochastic(hist_date, hist_high, hist_low, hist_close)
    if(slowStochResult == 1) 
        set(findobj('Tag','txtSlowStochResult'),'String','Oversold - Buy!');
    end
    
    if(slowStochResult == 2) 
        set(findobj('Tag','txtSlowStochResult'),'String','Overbought - Sell!');
    end
    
    if(slowStochResult == 0) 
        set(findobj('Tag','txtSlowStochResult'),'String','be calm');
    end
end

if (get(findobj('Tag','chbxForce'),'Value') == 1)
    h7 = figure
    set(h7, 'Position', [100, 50, 1200, 600])
    drawForceIndex(hist_date, hist_open, hist_close, hist_low, hist_high, hist_vol)
end


% --- Executes on button press in chbxSimpless.
function chbxSimpless_Callback(hObject, eventdata, handles)
% hObject    handle to chbxSimpless (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxSimpless


% --- Executes on button press in chbxExp.
function chbxExp_Callback(hObject, eventdata, handles)
% hObject    handle to chbxExp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxExp


% --- Executes on button press in chbxTri.
function chbxTri_Callback(hObject, eventdata, handles)
% hObject    handle to chbxTri (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxTri


% --- Executes on button press in chbxWeighted.
function chbxWeighted_Callback(hObject, eventdata, handles)
% hObject    handle to chbxWeighted (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxWeighted


% --- Executes on button press in chbxModified.
function chbxModified_Callback(hObject, eventdata, handles)
% hObject    handle to chbxModified (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxModified



function elendday_Callback(hObject, eventdata, handles)
% hObject    handle to elendday (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of elendday as text
%        str2double(get(hObject,'String')) returns contents of elendday as a double


% --- Executes during object creation, after setting all properties.
function elendday_CreateFcn(hObject, eventdata, handles)
% hObject    handle to elendday (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function elstartday_Callback(hObject, eventdata, handles)
% hObject    handle to elstartday (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of elstartday as text
%        str2double(get(hObject,'String')) returns contents of elstartday as a double


% --- Executes during object creation, after setting all properties.
function elstartday_CreateFcn(hObject, eventdata, handles)
% hObject    handle to elstartday (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function elstartmonth_Callback(hObject, eventdata, handles)
% hObject    handle to elstartmonth (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of elstartmonth as text
%        str2double(get(hObject,'String')) returns contents of elstartmonth as a double


% --- Executes during object creation, after setting all properties.
function elstartmonth_CreateFcn(hObject, eventdata, handles)
% hObject    handle to elstartmonth (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function elendmonth_Callback(hObject, eventdata, handles)
% hObject    handle to elendmonth (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of elendmonth as text
%        str2double(get(hObject,'String')) returns contents of elendmonth as a double


% --- Executes during object creation, after setting all properties.
function elendmonth_CreateFcn(hObject, eventdata, handles)
% hObject    handle to elendmonth (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function elstartyear_Callback(hObject, eventdata, handles)
% hObject    handle to elstartyear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of elstartyear as text
%        str2double(get(hObject,'String')) returns contents of elstartyear as a double


% --- Executes during object creation, after setting all properties.
function elstartyear_CreateFcn(hObject, eventdata, handles)
% hObject    handle to elstartyear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function elendyear_Callback(hObject, eventdata, handles)
% hObject    handle to elendyear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of elendyear as text
%        str2double(get(hObject,'String')) returns contents of elendyear as a double


% --- Executes during object creation, after setting all properties.
function elendyear_CreateFcn(hObject, eventdata, handles)
% hObject    handle to elendyear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in chbxDirectional.
function chbxDirectional_Callback(hObject, eventdata, handles)
% hObject    handle to chbxDirectional (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxDirectional


% --- Executes on button press in chbxWilliams.
function chbxWilliams_Callback(hObject, eventdata, handles)
% hObject    handle to chbxWilliams (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxWilliams


% --- Executes on button press in chbxMACDhist.
function chbxMACDhist_Callback(hObject, eventdata, handles)
% hObject    handle to chbxMACDhist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxMACDhist


% --- Executes on button press in chbxFastStoch.
function chbxFastStoch_Callback(hObject, eventdata, handles)
% hObject    handle to chbxFastStoch (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxFastStoch


% --- Executes on button press in chbxSlowStoch.
function chbxSlowStoch_Callback(hObject, eventdata, handles)
% hObject    handle to chbxSlowStoch (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxSlowStoch


% --- Executes on button press in chbxForce.
function chbxForce_Callback(hObject, eventdata, handles)
% hObject    handle to chbxForce (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxForce



function elWillResult_Callback(hObject, eventdata, handles)
% hObject    handle to elWillResult (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of elWillResult as text
%        str2double(get(hObject,'String')) returns contents of elWillResult as a double


% --- Executes during object creation, after setting all properties.
function elWillResult_CreateFcn(hObject, eventdata, handles)
% hObject    handle to elWillResult (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in btnSimulateOldData.
function btnSimulateOldData_Callback(hObject, eventdata, handles)
% hObject    handle to btnSimulateOldData (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%global hist_high hist_low hist_date hist_close hist_vol willResult fastStochResult slowStochResult histMACDResult

%elstartday1 = str2num(get(findobj('Tag','elstartday'),'string'))
%elstartmonth1 = str2num(get(findobj('Tag','elstartmonth'),'string'))
%elstartyear1 = str2num(get(findobj('Tag','elstartyear'),'string'))
%elendday1 = str2num(get(findobj('Tag','elendday'),'string'))
%elendmonth1 = str2num(get(findobj('Tag','elendmonth'),'string'))
%elendyear1 = str2num(get(findobj('Tag','elendyear'),'string'))

%nahrajeme tydenni data pro prvni filtr - hledani trendu
%[hist_date, hist_high, hist_low, hist_open, hist_close, hist_vol] = get_hist_stock_data('COKE',elstartday1, elstartmonth1, elstartyear1, elendday1, elendmonth1, elendyear1,'w');
 
% macd_buy = {};  
% macd_sell = {};
 
% vout = indicators(hist_close, 'macd', 12,26,9)

 %    macd = vout(:,1);
 %    signal = vout(:,2);
 %    macdh = vout(:,3);
     
%for i = 3:length(macd)    
 %   last_value = macd(i)
 %  last_1_value = macd(i - 1)
 %  last_2_value = macd(i - 2)
 %   today_result = hist_date(i)
    %today_result = last_value
    
    %otoceni trendu z klesajiciho na rostouci - nakupovat
 %   if (last_2_value > last_1_value && last_1_value < last_value) 
       %macd_buy(end+1) = today_result
 %   end
    %otoceni trendu z rostouciho na klesajici - prodavat
 %   if (last_2_value < last_1_value && last_1_value > last_value) 
       %macd_sell(end+1) = today_result
 %   end
 
%end

%macd_buy
%macd_sell
%nahrajeme denni data pro druhy filtr - oscilatory
%[hist_date, hist_high, hist_low, hist_open, hist_close, hist_vol] = get_hist_stock_data('COKE',elstartday1, elstartmonth1, elstartyear1, elendday1, elendmonth1, elendyear1,'d');


% --- Executes on selection change in selectBoxDataResource.
function selectBoxDataResource_Callback(hObject, eventdata, handles)
% hObject    handle to selectBoxDataResource (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns selectBoxDataResource contents as cell array
%        contents{get(hObject,'Value')} returns selected item from selectBoxDataResource
global X selection

val = get(hObject,'Value')
string_list = get(hObject,'String')
selection = string_list(val)

% --- Executes during object creation, after setting all properties.
function selectBoxDataResource_CreateFcn(hObject, eventdata, handles)
% hObject    handle to selectBoxDataResource (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in chbxClose.
function chbxClose_Callback(hObject, eventdata, handles)
% hObject    handle to chbxClose (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chbxClose
