-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
220 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Application x:Class="WPFGraphMaker.App" | ||
xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:WPFGraphMaker" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
|
||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Windows; | ||
|
||
namespace WPFGraphMaker | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Window x:Class="WPFGraphMaker.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF" | ||
mc:Ignorable="d" | ||
Title="GraphWindow" Height="450" Width="800"> | ||
|
||
<Grid> | ||
<ScottPlot:WpfPlot x:Name="WpfPlot1" /> | ||
|
||
</Grid> | ||
|
||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using Candlestick_Patterns; | ||
using GraphMaker; | ||
using ScottPlot; | ||
using ScottPlot.Plottables; | ||
using ScottPlot.WPF; | ||
using System.Net.Http; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Controls.Primitives; | ||
using System.Windows.Media; | ||
|
||
namespace WPFGraphMaker | ||
{ | ||
public partial class MainWindow : Window | ||
{ | ||
private readonly IFiboTester _fiboTester = new FiboTester(); | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
Loaded += MyLoadedRoutedEventHandler; | ||
WpfPlot1.Refresh(); | ||
|
||
} | ||
|
||
private async void MyLoadedRoutedEventHandler(object sender, RoutedEventArgs e) | ||
{ | ||
var url = "https://gist.githubusercontent.com/przemyslawbak/c90528453d512a8d85ad2deea5cf6ad2/raw/aapl_us_d.csv"; | ||
|
||
HttpClient client = new HttpClient(); | ||
HttpResponseMessage response = await client.GetAsync(url); | ||
response.EnsureSuccessStatusCode(); | ||
string json = await response.Content.ReadAsStringAsync(); | ||
|
||
var patternName = "BullishButterfly"; | ||
List<ZigZagObject> points = GetGraphData(patternName, json); | ||
ViewGraph(points); | ||
|
||
} | ||
|
||
private void ViewGraph(List<ZigZagObject> points) | ||
{ | ||
|
||
var numbers = new List<int>(); | ||
var newList = new List<double>(); | ||
|
||
for (int i = 0; i < points.Count; i++) | ||
{ | ||
numbers.Add(i); | ||
} | ||
|
||
var pointsPlot = points.Select(x => x.Close).ToArray(); | ||
var signals = points.Select(x => x.Signal).ToArray(); | ||
|
||
foreach (var a in numbers) | ||
{ | ||
newList.Add(a); | ||
} | ||
|
||
var numbersArray = numbers.ToArray(); | ||
var myScatter = WpfPlot1.Plot.Add.Scatter(numbersArray, pointsPlot); | ||
|
||
ScottPlot.Palettes.Category20 palette = new(); | ||
for (int i = 0; i < points.Count; i++) | ||
{ | ||
var item = points[i]; | ||
if (item.Signal == true) | ||
{ | ||
var mp = WpfPlot1.Plot.Add.Marker(i, (double)item.Close); | ||
mp.MarkerShape = MarkerShape.OpenDiamond; | ||
|
||
mp.MarkerStyle.FillColor = palette.GetColor(8); | ||
mp.MarkerStyle.Size = 1.5F; | ||
mp.MarkerStyle.OutlineColor = palette.GetColor(8); | ||
mp.MarkerStyle.OutlineWidth = 2; | ||
mp.MarkerStyle.LineWidth = 2f; | ||
mp.MarkerStyle.LineColor = palette.GetColor(10); | ||
} | ||
} | ||
|
||
myScatter.Color = ScottPlot.Colors.Green; | ||
myScatter.LineWidth = 1; | ||
myScatter.MarkerSize = 1.2F; | ||
myScatter.MarkerShape = MarkerShape.OpenSquare; | ||
myScatter.LinePattern = LinePattern.Solid; | ||
WpfPlot1.Plot.Axes.AutoScale(); | ||
|
||
WpfPlot1.Refresh(); | ||
|
||
//double[] dataX = { 1, 2, 3, 4, 5 }; | ||
//double[] dataY = { 1, 4, 9, 16, 25 }; | ||
//WpfPlot1.Plot.Add.Scatter(dataX, dataY); | ||
////WpfPlot1.Plot.Axes.SetLimits(0, 5000, 0, 250); | ||
//WpfPlot1.Plot.Axes.AutoScale(); | ||
//WpfPlot1.Refresh(); | ||
|
||
} | ||
|
||
private List<ZigZagObject> GetGraphData(string patternName, string json) | ||
{ | ||
return _fiboTester.GetDataFromJson(patternName, json); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0-windows</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ScottPlot.WPF" Version="5.0.46" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Candlestick_Patterns\Candlestick_Patterns.csproj" /> | ||
<ProjectReference Include="..\GraphMaker\GraphMaker.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |