Tag Archives: Simplest

Simplest machine learning tutorials I have seen with deep learning

 

Simplest machine learning tutorials I have seen with deep learning

After watching the most recent videos in this blog, I am more than convinced this can workfor automated trading. How do you understand all this? There is a decent set of video series out there to get you started with the advanced topics

K Nearest Neighbor Algorithm (KNN) | Data Science | Big Data

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Simplest candlestick demo with Python Matplotlib

Simplest candlestick demo with Python Matplotlib

This is from the book Python in Finance p107

Join my FREE newsletter to learn more about other simple charting in Python for automated trading

Source code:

# -*- coding: utf-8 -*-
“””
Created on Tue Jan 26 19:28:55 2016

@author: quantlabsnet
“””
#Python in Finance p107

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.finance as mpf

start = (2014, 5, 1)
end = (2014, 6, 30)
quotes = mpf.quotes_historical_yahoo_ohlc(‘^GDAXI’, start, end)
#quotes = mpf.quotes_historical_yahoo(‘^GDAXI’, start, end)
quotes[:2]

fig, ax = plt.subplots(figsize=(8, 5))
fig.subplots_adjust(bottom=0.2)

print “Hello”
#use Line2d
#mpf.plot_day_summary_oclh(ax, quotes, ticksize=3, colorup=’k’, colordown=’r’)#
mpf.candlestick_ohlc(ax, quotes, width=0.6, colorup=’b’, colordown=’r’)
#mpf.candlestick(ax, quotes, width=0.6, colorup=’b’, colordown=’r’)
plt.grid(True)
ax.xaxis_date()
# dates on the x-axis
ax.autoscale_view()

plt.setp(plt.gca().get_xticklabels(), rotation=30)
#raw_input(“Press Enter to continue…”)
print “bye”

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Simplest Bollinger Band calculation ever

Simplest Bollinger Band calculation ever

Here are some over engineered answers

http://www.metastock.com/customer/support/kb/faq.aspx?fc=120#/120

http://www.investopedia.com/articles/trading/05/022205.asp

Here is the simplest yet but I wish more would it explain this exactly like this (the world would be more peaceful if this was the case)

http://www.great-trades.com/Help/bollinger%20bands%20calculation.htm

Join my FREE newsletter to learn more about using trading indicators in your automated trading

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Simplest notes for Auto ABC pattern trading algo

Simplest notes for Auto ABC pattern trading algo

I have listed various URLs on this blog but I have not done any summary notes on it. Here they are:

Join my FREE newsletter to learn more about this indicator

E mini futures es, ym, nq

Market indicator $adv $decl xlf $esinx spy $trin $tick
One trend indicator ktrend

Fib bands with k moving average trend
Fib band zone pivots of 21 pd moving average 89 ema 200 sma

Uses combine market internals which is 7 indicators with one histogram to show market direction with 5 min chart
Enter trade once pattern Is completely formed. Price must be below neckline.

Price needs to trade at 2 bar high or 2 bar low 40:06. Price must close below that line before entry takes place. Or it must trade above swing high or low. Or wait for the breakout bar to take place. Also enter at a high range bar high/low.

Planned exits
Key support and resistance
Fib levels defined
ATR exits
Bar size exits

Moving average periods of 21 and 89 EMA and 200 SMA
Abc pattern is harmonic which works best 56:34 is type of abc formation which can be retracement or externsion (c went beyond ab leg) so they belong to either side, price projections are 62%ab 100%ab or 162%ab 57:24 you can project the time to t1 t2 or t3. This could be used for daily as in options timing projection but cannot be used intraday effectively. 1:06 shows c bearish leg for pricing projection.

Ktrend indicators can be used with this.

1:13 abc can be used in options data of options price which affects stock price. You could target premium price as well.
Perfect abc pattern (goal to target for these levels) 1:16
Outside fib band, is above mid fib band
Is retraced below mid fib band at least 50% but retracement no more than 78.6%
After long above the el or mid fib band level el is entry level
STop below c
Target 1: 62% ab 100% ab
Target 2: 127% ab 162 % ab
Example chart at 1:19:30
Set trade as same direction of ab

For ab how many bars were there? What was retracement for c%? Need entry and stop targets

 

https://www.tradestation.com/en/education/events/on-demand-webcasts/spotlight-on/suri-duddella

Perfect ABC Trading Pattern

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

The simplest quant math you’ll ever see …


Recently I've had feedback from people who think I'm not providing
enough "free stuff" prior to people taking on a Premium membership.
This baffles me, because Quantlabs.net offers more than 10,000 posts
of material, 179 Youtube videos and 20+ face-to-face meetups ... all
for free.

The best stuff is available for Premium members, of course. I couldn't
fund the ongoing research, time-consuming trial & error, and detailed
tutorial creations without paying members.

In return, my members don't have to do all that themselves.

What's *your* time worth? More than 10 bucks an hour? 20? If you're
serious about quant, my materials are doing to save you a whole lot
more than 2-4 hours a month when it comes to learning about algos ...
models ... software packages ... and every tip & trick I can cram into
each busy month of ongoing research.

In fact, it's safe to say that Premium members have "done the math"
and figured out it's worth $42.50 a month to save themselves a heck of
a lot of time, stress, and effort. They've realized it's a great deal
to let me do all the grunt work for them instead.

Meanwhile, don't forget all the new stuff that's going live right now
or within the next few weeks:

1. A new Q&A section for building community. Just press Q? or Q’s at
the top of the Private section to get started. If you're working on
something and need an answer from another member (or me), we can all
help each other out.

2. Membership webinars are under way. I'll send out a schedule once
they're set.

3. More and more R/Matlab model coding walkthroughs have been posted.
These include the most popular techniques you've asked for after I
sifted through recent poll results.

4. The best trading platform has been finally confirmed so look out
for demos on integrating with R for the new models.

5. Demos will be shown for our upcoming private network with an
internal cluster for parallelizing heavy number crunching simulations
within these models.

6. After that, an exhausting comparison will be under way to focus on
most profitable models.

7. And finally, we'll be embarking upon an aggressive paper trading
campaign with the above technology and models once built.

Join today, and you'll get it all for a ridiculously low $42.50 a
month. That rate is guaranteed for as long as you remain a member.
Even after the price rises dramatically due to the expanded features.

-- > Get immediate access here.
<http://quantlabs.net/dlg/sell.php?prodData=m%2C3>
<--

Membership Benefits here. <http://quantlabs.net/membership-new.html>

Good trading,

Bryan

Quantlabs.net Editor

"Those that know, don't tell. Until now."

P.S. You've probably already invested thousands of dollars in a
university education to get where you are right now. Is $500/year too
much to ask for something that will teach you what quant trading is
really about?
NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

This is easily the best and simplest C or C++ Posix compliant Linux Unix multi thread pthread tutorial I have found

This is easily the best and simplest C or C++ Posix compliant Linux Unix multi thread pthread tutorial I have found

http://www.mobydisk.com/softdev/techinfo/pthreads_tutorial/

POSIX threads tutorial
This is a short tutorial on how to code POSIX threads in C++ on GNU/Linux. For up-to-date information on the Linux implementation of pthreads called LinuxThreads, check out Xavier Leroy’s page.
What you need
Any modern Linux should be able to do this. For specific requirements, check outthe link above. This tutorial does not explain what threads are, how they work, or how to synchronize multiple threads. It assumes you know what you plan to use threads for, and that you have a good reference on synchronizing threads. If you don’t have any of this information, then visit the Links section at the bottom of this page.
Compiling this demo
At your Linux prompt type:
g++ threaddemo.cpp -o threaddemo -lpthread -D_REENTRANT
then:
./threaddemo
Program description
This sample program will create 2 threads. One thread displays the word “ping” and the other displays “pong.” The resulting output will look something like this:
ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,
ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,
ping,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,
pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,
pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,
pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,pong,ping,
Done!
Sample source
The sample source code is threaddemo.cpp. You will also need Morgan McGuire’s great kbhit.cpp which makes things a little easier.
The how-to
The pthreads library hides out in the pthread.h file, as you can see below.
#include #include
#include “kbhit.cpp”

// On Linux, you must compile with the -D_REENTRANT option. This tells
// the C/C++ libraries that the functions must be thread-safe
#ifndef _REENTRANT
#error ACK! You need to compile with _REENTRANT defined since this uses threads
#endif
Whenever compiling an application for pthreads, you must use the -D_REENTRANT option to inform the C/C++ libraries that they are in multithread mode. The #ifndef _REENTRANT line verifies that this is the case before allowing the compile to continue. Further, you should only make calls to other libraries that were compiled with -D_REENTRANT. If you need to know if your favorite library is compiled with this code, seek the author or the documentation. For more information about this subject see the links at the bottom of this page.
volatile int bStop = false;
The bStop variable is used to tell the threads when to stop. If the variable is not declared volatile, then the compiler may think that the value is always false, and may not even pay attention to it! More later.
////////////////////////////////////////////////////////////////////////////////
// Starting point for a thread
////////////////////////////////////////////////////////////////////////////////
void * runMe(void *generic_pointer)
{
// Do this until we are told to stop
while (!bStop)
{
// Output some text
cout << static_cast(generic_pointer) << ","; // Relenquish the CPU for another thread pthread_yield(); } return NULL; } This routine will be executed in each of the 2 threads that we will create. The function takes a void pointer, and returns a void pointer. This is necessary, since it is a requirement of the pthread_create function that we are about to use. The parameter, and the return value are arbitrary; that is, they can be used for whatever purpose you wish. In this demo, the parameter is assumed to be a char * that holds a string for the thread to display. In a real application, this parameter may be a pointer to a structure with information about what the thread needs to do. For example, imagine a multithreaded game, with a thread controlling each of the enemy characters. This parameter may be a pointer to the character's information, with the character position, intelligence, weapons, etc. The return value is not used here. It could be treated similarly to the parameter, in that it can be used to return some arbitrary data to the parent thread. It could be a pointer to an integer return value indicating success or failure, or an exception structure, or error message. The basic function of this thread is to display a message over and over, while not using up the entire CPU. The thread avoids hogging the CPU by calling pthread_yield() after displaying the message. This function tells the OS that the thread isn't busy and something else can go happen now. Note that the OS may not wait until the thread calls pthread_yield to switch threads. It may happen at any point. This call just tells the OS that this would be a good time to do so. More on this later. The thread will stop displaying the message once the value of bStop becomes true. At this point, the thread will exit with a return value of NULL. This return statement does not return control to the caller: it stops the thread from executing entirely. This is the equivalent to calling pthread_exit(NULL). pthread_t nThreadID1, nThreadID2; Every thread has an ID. Nothing special there. pthread_create(&nThreadID1, NULL, runMe, szMessage1); pthread_create(&nThreadID2, NULL, runMe, szMessage2); This code is kinda like doing: runMe(szMessage1); runMe(szMessage2); Except that the code executes in the background, instead of sequentially. After this code, there are 3 threads: the parent, and 2 children. Let's check out the pthread_create call. The first parameter is the address of nThreadID. pthread_create will stuff the thread ID into this. The second parameter has all sorts of nifty stuff about the thread: priority, scheduling, stack size, whatever. We don't care about any of this so it is NULL. Next is the name of the function to use as the starting point for the thread. The function must take a void * and return a void *. Lots of tutorials do this incorrectly, and must cast the function with some crazy C-style weirdness. If you declare the function exactly right, you can just place the name there and nothing else. The last function is the generic parameter, which we use for the message. while (!_kbhit()) { pthread_yield(); } At this point the child threads are running. The parent thread now loops until the user presses a key. It is crucial that this loop call pthread_yield() or the child threads may not execute. This is because the parent thread would spend all its time checking for a key, and never giving anyone else a chance to work. This behavior of threads varies with operating system, kernel, processor, phase of the moon, etc. Pthreads makes no guarantee that each thread executes "fairly." Threads may be interrupted at any time, for any length of time. If this isn't appropriate, then you may need some thread synchronization code, or to provide a hint during the pthread_create call about how you want the threads to behave. bStop = true; This changes the value of the bStop variable. When the threads check this value they will exit. If this value were not declared volatile, then it is possible that the threads may not notice it, and continue running forever! pthread_join(nThreadID1, NULL); pthread_join(nThreadID2, NULL); The pthread_join call tells a thread to wait until the specified thread has exited. This is why we saved the thread IDs. What happens if we remove this code? In this demo, nothing. The child threads will stop anyway, once the parent thread exits. In more complex code, you may need to wait for your threads to free their memory, close open files, etc. before your application exits. The pthread_join call also allows you to see the return value of the thread. Remember the void * return value? The second parameter to pthread_join() tells you where to put this value. For this application, we don't care what they returned. Further improvements A nifty improvement (left to the reader, of course) would be to have each thread return the number of times it displayed the message. In a perfect world, it would be the same for each thread. But as we know, threads aren't guaranteed fair excecution time! In theory, this code is POSIX compliant (except for the kbhit.cpp) and should run on other operating systems. You may wish to compile this code and run it on Coolix or Niftyux or FreeBVD or whatever and see if it works. Links Most of these are pretty much the first things you find in a search for threads, linux, and POSIX or some combination thereof. • Xavier Leroy is the author of LinuxThreads and his page has lotsa info. • posix threads programming • DMOZ links on Linux threads programming

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Simplest C++ Multithreading with Thread classes, mutex, set, wait, lock, unlock defined

Simplest C++ Multithreading with Thread classes, mutex, set, wait, lock, unlock defined

I have searched high and low for the best and simplest multi threading explained within C++. As you know, I have already posted some articles on Linux processes and how deadlocks work. Theoretically, we are trying to prevent the Dead Diamond of Death syndrome. Both Java and C++ have potential solutions but Java has all these features built in natively. C++ needs a new set of classes defined which includes a specialized Thread class.
Using a set of mutex method, we can lock certain processes from subsequent messing up the state of a current thread. An example of mutex locking a storage block of code, look at:
int g_iStorage = 0;
CMutexClass MyMutex;

void StoreValue( int *pInt )
{
MyMutex.Lock(); //the gate keeper. only one thread
//allowed in at a time

g_iStorage = *pInt; //protected data, critical code section

MyMutex.Unlock(); //unblocks, allowing another thread to
//access g_iStorage

}

There are some other methods which work the same way Java’s Threading class and methods. These methods are explained below:
void Set() Sets an event state to signaled, notifying the blocked thread.
BOOL Wait() Places the calling thread in a blocked state until the event state is set to signaled. Returns TRUE on success, FALSE on failure.
void Reset() Resets a signaled event to unsignaled.
event object being used by a receiving thread::
CEventClass event;
.
.
//thread code

.
.
while(bContinueRunning)
{

event.Wait(); // wait for an event to occur

// perform some task

.
.
event.Reset(); // reset the event to un-signaled

}
.
.
Example of an event object used by one thread signaling another:
EventClass event;
.
.
// change some data

.
.
event.Set(); // notify thread that an event has occured,

// set event to signaled

There is more detailed info you could go into. I do believe if you know enough of above, you should be able to show some rudimentary knowledge in multithreading within C++. I would recommend following through with the link below as it is fairly close representation of how Java works.
To download and better understand how all this Thread classes work, go to http://www.codeproject.com/KB/threads/threadobject.aspx
It also contains a very good end to end set of source files to generate your own Thread classes which include the mutexes explained.

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!