Disclaimer | The
candlestick patterns explained herein are intended
to inform. They come with no warranty of any kind. If you
should choose
this information for your investment decisions, you do so at
your
own risk. Investing can be a very dangerous venture and it
is you
who must assume the entire cost and risk involved in all of
your investment
decisions, should you choose to follow this system or use
this information.
The information contained on the this site is drawn
from sources believed to be factual and reliable, but in no
way does this site represent or guarantee the accuracy or completeness
thereof, nor in providing it, does this site assume any
liability. The information found on the this web site is protected by the copyright laws of the Croatia and may not be copied, or reproduced in any way without the expressed, written consent of the editors. |
C# 4.0 programming using Japanese candlesticks as an example. Calculation, drawing and trading decision management.
Thursday, 26 July 2012
28. Trader - 26.7. during trading day analyse for Google stock - GOOG:US
As we can see bellow price grow is in progress (as predicted in chapter 27) and confirmed but for tomorrow is pattern set to fall. So, conclusion is not to buy. In left list box we can see what was analyse for today and in the upper right what is at the moment. Still, trading is in progress and conclusion could be changed.
27. Trader - Before 26.7. trading analyse for Google stock - GOOG:US
27. Trader - Before 26.7. trading analyse for Google stock - GOOG:US
There are information for other stocks on other forms which can be accessed with their name in list box.
There are information for other stocks on other forms which can be accessed with their name in list box.
Disclaimer | The
candlestick patterns explained herein are intended
to inform. They come with no warranty of any kind. If you
should choose
this information for your investment decisions, you do so at
your
own risk. Investing can be a very dangerous venture and it
is you
who must assume the entire cost and risk involved in all of
your investment
decisions, should you choose to follow this system or use
this information.
The information contained on the this site is drawn
from sources believed to be factual and reliable, but in no
way does this site represent or guarantee the accuracy or completeness
thereof, nor in providing it, does this site assume any
liability. The information found on the this web site is protected by the copyright laws of the Croatia and may not be copied, or reproduced in any way without the expressed, written consent of the editors. |
Friday, 20 July 2012
26. Trader can read/save data to Acess database
I have Access database from previous version so C# will use these Access database data using OleDbConnection.
There are elements needed and code under button "BuySell" (partially hidden behind two lists). Two lists are used to present information in a better way.
private void BuySell_Click(object sender, EventArgs e)
{
string con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=P:\\Private\\Analizator\\Analizator.mdb"; // define connection
using (OleDbConnection c = new OleDbConnection(con)) // create connection
{
c.Open(); // Open connection
string indNow = activeIndice.Text.Replace("RA:CZ", "-R-A");
string selekt = "select * from zatrgovinu where dionica=" + "'" + indNow + "'" + " and Status='Otvoren' " + " order by redbrzt"; // construct sql string
string listRow = "";
string auX = "";
string buYselL = "";
double suMb = 0;
double suMs = 0;
double dou1;
double dou2;
string str1;
Int16 int1;
int sumShS = 0;
int sumShB = 0;
double statusB = 0;
double statusS = 0;
double proD;
double PricE = Convert.ToDouble(pricE.Text);
double deltA = 0;
using (OleDbDataAdapter a = new OleDbDataAdapter(selekt, c)) // Create new DataAdapter
{
DataTable dt = new DataTable(); // Use DataAdapter to fill DataTable
a.Fill(dt);
listBuy.Items.Clear();
listSell.Items.Clear();
sumShB = 0;
sumShS = 0;
int j = -1;
int m = -1;
for (int i = 0; i < dt.Rows.Count; i++)
{
auX = Convert.ToString(dt.Rows[i][3]);
if (auX == "Prodaja")
{
m++;
buYselL = "Buy < @ ";
dou1 = Convert.ToDouble(dt.Rows[i][9]);
dou2 = Math.Round(dou1 * 0.99, 2);
str1 = Convert.ToString(dt.Rows[i][4]);
int1 = Convert.ToInt16(str1);
listRow = buYselL + dou1.ToString("##0.00") + " Kn x " + str1.PadLeft(3)
+ " shares -1% " + dou2.ToString("##0.00");
proD = dou1 * int1;
suMb = suMb + proD;
sumShB = sumShB+ int1;
listRow = listRow + " = " + proD.ToString("##,##0.00") + " Kn";
deltA = Math.Round(dou1 - PricE, 2);
listRow = listRow + " " + deltA.ToString("##0.00");
deltA = Math.Round(deltA * int1, 2);
listRow = listRow + " " + deltA.ToString("#,##0.00");
if (deltA > 0) { listRow = listRow + "++"; } else { listRow = listRow + "--"; }
listBuy.Items.Add(listRow);
if (deltA > 0) { listBuy.SetSelected(m, true); }
toBuyTotal.Text = suMb.ToString("##,##0.00");
buyShares.Text = Convert.ToString(sumShB);
statusB = PricE * sumShB;
buyStatus.Text = Convert.ToString(Math.Round(suMb - statusB, 2));
toBuyAve.Text=Convert.ToString(Math.Round((suMb/sumShB)*1,2)); // minimal selling price
}
else
{
j++;
buYselL = "Sell > @ ";
dou1 = Convert.ToDouble(dt.Rows[i][9]);
dou2 = Math.Round(dou1 * 1.01, 2);
str1 = Convert.ToString(dt.Rows[i][4]);
int1 = Convert.ToInt16(str1);
listRow = buYselL + dou1.ToString("##0.00") + " Kn x " + str1.PadLeft(3)
+ " shares +1% " + dou2.ToString("##0.00");
proD = dou1 * int1;
suMs = suMs + proD;
sumShS = sumShS + int1;
listRow = listRow + " = " + proD.ToString("##,##0.00") + " Kn";
deltA =Math.Round( PricE - dou1,2);
listRow=listRow+" " + deltA.ToString("##0.00");
deltA = Math.Round(deltA*int1, 2);
listRow=listRow + " " + deltA.ToString("#,##0.00");
if (deltA > 0) { listRow = listRow + "++"; } else { listRow = listRow + "--"; }
listSell.Items.Add(listRow );
if (deltA > 0) { listSell.SetSelected(j,true);}
toSellTotal.Text = suMs.ToString("##,##0.00");
sellShares.Text = Convert.ToString(sumShS);
statusS = PricE * sumShS;
sellStatus.Text = Convert.ToString(Math.Round( statusS-suMs, 2));
toSellAve.Text = Convert.ToString(Math.Round((suMs / sumShS) * 1, 2)); // minimal selling price
}
}
dataSelect.DataSource = dt; // // Render data onto the screen
dataSelect.AutoResizeColumns();
}
}
}
There are elements needed and code under button "BuySell" (partially hidden behind two lists). Two lists are used to present information in a better way.
private void BuySell_Click(object sender, EventArgs e)
{
string con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=P:\\Private\\Analizator\\Analizator.mdb"; // define connection
using (OleDbConnection c = new OleDbConnection(con)) // create connection
{
c.Open(); // Open connection
string indNow = activeIndice.Text.Replace("RA:CZ", "-R-A");
string selekt = "select * from zatrgovinu where dionica=" + "'" + indNow + "'" + " and Status='Otvoren' " + " order by redbrzt"; // construct sql string
string listRow = "";
string auX = "";
string buYselL = "";
double suMb = 0;
double suMs = 0;
double dou1;
double dou2;
string str1;
Int16 int1;
int sumShS = 0;
int sumShB = 0;
double statusB = 0;
double statusS = 0;
double proD;
double PricE = Convert.ToDouble(pricE.Text);
double deltA = 0;
using (OleDbDataAdapter a = new OleDbDataAdapter(selekt, c)) // Create new DataAdapter
{
DataTable dt = new DataTable(); // Use DataAdapter to fill DataTable
a.Fill(dt);
listBuy.Items.Clear();
listSell.Items.Clear();
sumShB = 0;
sumShS = 0;
int j = -1;
int m = -1;
for (int i = 0; i < dt.Rows.Count; i++)
{
auX = Convert.ToString(dt.Rows[i][3]);
if (auX == "Prodaja")
{
m++;
buYselL = "Buy < @ ";
dou1 = Convert.ToDouble(dt.Rows[i][9]);
dou2 = Math.Round(dou1 * 0.99, 2);
str1 = Convert.ToString(dt.Rows[i][4]);
int1 = Convert.ToInt16(str1);
listRow = buYselL + dou1.ToString("##0.00") + " Kn x " + str1.PadLeft(3)
+ " shares -1% " + dou2.ToString("##0.00");
proD = dou1 * int1;
suMb = suMb + proD;
sumShB = sumShB+ int1;
listRow = listRow + " = " + proD.ToString("##,##0.00") + " Kn";
deltA = Math.Round(dou1 - PricE, 2);
listRow = listRow + " " + deltA.ToString("##0.00");
deltA = Math.Round(deltA * int1, 2);
listRow = listRow + " " + deltA.ToString("#,##0.00");
if (deltA > 0) { listRow = listRow + "++"; } else { listRow = listRow + "--"; }
listBuy.Items.Add(listRow);
if (deltA > 0) { listBuy.SetSelected(m, true); }
toBuyTotal.Text = suMb.ToString("##,##0.00");
buyShares.Text = Convert.ToString(sumShB);
statusB = PricE * sumShB;
buyStatus.Text = Convert.ToString(Math.Round(suMb - statusB, 2));
toBuyAve.Text=Convert.ToString(Math.Round((suMb/sumShB)*1,2)); // minimal selling price
}
else
{
j++;
buYselL = "Sell > @ ";
dou1 = Convert.ToDouble(dt.Rows[i][9]);
dou2 = Math.Round(dou1 * 1.01, 2);
str1 = Convert.ToString(dt.Rows[i][4]);
int1 = Convert.ToInt16(str1);
listRow = buYselL + dou1.ToString("##0.00") + " Kn x " + str1.PadLeft(3)
+ " shares +1% " + dou2.ToString("##0.00");
proD = dou1 * int1;
suMs = suMs + proD;
sumShS = sumShS + int1;
listRow = listRow + " = " + proD.ToString("##,##0.00") + " Kn";
deltA =Math.Round( PricE - dou1,2);
listRow=listRow+" " + deltA.ToString("##0.00");
deltA = Math.Round(deltA*int1, 2);
listRow=listRow + " " + deltA.ToString("#,##0.00");
if (deltA > 0) { listRow = listRow + "++"; } else { listRow = listRow + "--"; }
listSell.Items.Add(listRow );
if (deltA > 0) { listSell.SetSelected(j,true);}
toSellTotal.Text = suMs.ToString("##,##0.00");
sellShares.Text = Convert.ToString(sumShS);
statusS = PricE * sumShS;
sellStatus.Text = Convert.ToString(Math.Round( statusS-suMs, 2));
toSellAve.Text = Convert.ToString(Math.Round((suMs / sumShS) * 1, 2)); // minimal selling price
}
}
dataSelect.DataSource = dt; // // Render data onto the screen
dataSelect.AutoResizeColumns();
}
}
}
25. Trader can fetch data periodically - C# timer
Trader can fetch data from Internet periodically with period defined in seconds. Button with text "timer Stoped" starts remote data fetching. Period is defined in second in field timinG. After button is clicked text is changed to "timer Started". Button Get live is run every 120 seconds (default value). Also, you'll need Timer control from Toolbox.
There is code:
private void timeR_Click(object sender, EventArgs e)
{
if (tGetLive.Enabled == false)
{
tGetLive.Interval = Convert.ToInt32(timinG.Text)*1000; //60000; - 60 sec
tGetLive.Start();
timeR.Text = "Timer started";
}
else
{
tGetLive.Stop();
timeR.Text = "Timer stopped";
}
}
private void tGetLive_Tick(object sender, EventArgs e)
{
getLive.PerformClick();
}
There is code:
private void timeR_Click(object sender, EventArgs e)
{
if (tGetLive.Enabled == false)
{
tGetLive.Interval = Convert.ToInt32(timinG.Text)*1000; //60000; - 60 sec
tGetLive.Start();
timeR.Text = "Timer started";
}
else
{
tGetLive.Stop();
timeR.Text = "Timer stopped";
}
}
private void tGetLive_Tick(object sender, EventArgs e)
{
getLive.PerformClick();
}
Subscribe to:
Posts (Atom)