Latest Threads

Forum Statistics
  • Forum posts:226
  • Forum threads:59
  • Members:13,493
  • Latest member:g6syqjd295


Posted by: Hassam
07-08-2019, 06:28 AM
Forum: Python
- No Replies

There are a number of famous membership sites that allow you to upload documents as well as download PDFs free. There are many ebooks that are available for premium members only. I found a number of good ebooks on one such membership site. I had come across an article online that explained how I can use to python to download ebooks from such sites. I started a one month free trial of the membership site. In the beginning, I was unable to make sense how to download the ebook. The googling and reading I finally developed the following script that did the job for me and I was able to download a number of ebooks from that site. Below is the python script:

from PIL import Image
from time import sleep
import os
#import re
import img2pdf
#browser = webdriver.Chrome()
from selenium import webdriver
#from selenium.webdriver.common.keys import Keys
#from selenium.webdriver.common.action_chains import ActionChains
#D:\\Shared\\Python\\geckodriver-v0.24.0-win64\\geckodriver.exe
browser = webdriver.Firefox(executable_path=\
r'D:\\Shared\\Python\\geckodriver-v0.24.0-win64\\geckodriver.exe')

url ="https://www.xxxxx.com/login"
browser.get(url)
browser.maximize_window()
#loginto site 
usr='xxxxxxxxxxxx'  
pwd='xxxxxxxxxxx'
#print ("Opened Site")
#sleep(5)

#scroll the pages and make screenshots
#body = browser.find_element_by_css_selector('body')
#body.send_keys(Keys.PAGE_DOWN)
count=1
browser.save_screenshot(\
"D:/Shared/Downloads/Ebooks1/{}.jpg".format(\
   str(count).zfill(3)))
#ActionChains(browser).send_keys(Keys.PAGE_DOWN).perform()
count=count+1
print(count)
#sleep(10)
browser.quit()
#remove the alpha channel and save again
images=[]
newpath="D:/Shared/Downloads/ScribdEbooks1/"
images=[newpath+i \
           for i in os.listdir(newpath) \
           if i.endswith(".jpg")]
for image in images:
   imageObject  = Image.open(image)
   cropped = imageObject.crop((220,65,1700,815))
   cropped.convert("RGB").save(image)

#images=os.listdir(newpath)
#crop the image
# import the Python Image processing Library

# Create an Image object from an Image
#width, height = imageObject.size
#width, height
# storing pdf path
pdfPath = 'D:/Shared/Downloads/ScribdEbooks1/ebook1.pdf'
with open(pdfPath, "wb") as f:
   f.write(img2pdf.convert(\
       [newpath+i \
           for i in os.listdir(newpath) \
           if i.endswith(".jpg")]))
# closing pdf file
f.close()


In the above python script, we first import PIL (python image library) previously known as Pillow. Then we need the Selenium. In order to use Selenium we need to install the geckdriver for firefox. After taking images of the webpages, I had to remove the alpha channel. Alpha Channel just gives the transparency. When I was cropping I found out I have remove the alpha channel as cropping was only possible with RGB channels. Then I converted the images into a PDF.

Print this item


Posted by: Hassam
01-29-2019, 12:32 PM
Forum: Million Dollar Trading Challenge
- No Replies

1 pips on GBPNZD is less than $10 on a standard lot. 1 pip on GBPNZD is equal to around $7 for a standard lot. But it should concern you much. GBPNZD is a highly volatile. You can make a lot of pips. If you trade GBPUSD, making 100 pips means making $1000. But if you make 100 pips on GBPNZD, you make $700 roughly not exactly. So you need to make 140 pips, you make around $980. So making 150 pips on GBPNZD is equal to making 100 on GBPUSD. The plus side. If you stop loss was 20 pips on GBPUSD, it means $200 risk. In case of GBPNZD, 20 pips stop loss means $140. So you risk is lower. Below is the GBPNZD H4 chart:
[Image: GBPNZD+H411.png]
As you can see, GBPNZD makes big candles on H4. Today is not a good day to trade. UK Parliament is voting on Brexit Plan. Theresa May UK PM has a Brexit Plan that has a very high chance of getting rejected by the UK Parliament. So we should avoid the market today as things can become uncertain and most likely market is going to whipsaw.

Whatever, you can day trade GBP pairs like GBPUSD, GBPJPY, GBPNZD, GBPAUD, GBPCAD etc. All of these pairs have a lot of volatility which means we can make a lot of pips. GBPNZD is a good pair for day trading. When you trade this pair, just keep en eye on GBP and NZD currencies.

Print this item


Posted by: Hassam
01-29-2019, 07:50 AM
Forum: Million Dollar Trading Challenge
- Replies (1)

GBPJPY is a volatilie pair and many day traders love to trade it. You can trade GBPJPY daily and make 50-100 pips easily. On one side we have GBP and on the other side we have JPY. So when you trade this pair, you should keep an eye on British Pound (GBP) and Japanese Yen (JPY). Today Brexit Voting is scheduled in UK Parliament. Below is GBPJPY H4 chart:
[Image: GBPJPY+H411.png]
As you can see GBPJPY has been on a strong upward move. Today it is moving very slow as the market people are keenly awaiting the outcome of UK Parliament Brexit Voting. GBPJPY can move in any direction. When GBPJPY moves up for example, it can be either GBP is getting strong or JPY is getting weak. How do you know what is happening? You should look at the other GBP pairs like GBPUSD, GBPNZD, GBPAUD etc. If all these pairs are moving up, it means GBP is getting strong.

Print this item


Posted by: Hassam
01-06-2019, 12:17 PM
Forum: Million Dollar Trading Challenge
- No Replies

NZDUSD weekly chart is showing a downtrend. NZDUSD daily chart is showing an uptrend. NZDUSD H4 chart is showing downtrend with the EMA55 below EMA21. So overall NZDUSD trend is down. We will have a retracement in the up direction before NZDUSD restarts the downtrend. As a day trade NZDUSD is an important pair. NZDUSD is one of the major pairs. Take a look at NZDUSD H4 chart:
[Image: NZDUSD+H411.png]
As you can see, the trend on NZDUSD H4 chart is down. Price has made a retracement in the up direction. Most probably the downtrend will continue when this retracement in the up direction will be over. As a day trader, our aim should be to make 50-100 pip per pair. Just trade 4-5 pairs and if we are able to make 50 pip per pair, we can make 200-250 pips daily. Automation is the name of the game now. Developing an EA that can implement our trading strategy can be a good idea.

When you trade NZDUSD, you should keep an eye on the New Zealand economy and on the US economy. New Zealand is a beautiful place to visit. It has many scenic places. So while you day trade NZDUSD, you can contemplate visiting New Zealand with the profit you make trading NZDUSD.

Print this item


Posted by: Hassam
01-06-2019, 07:17 AM
Forum: Million Dollar Trading Challenge
- No Replies

USDCAD is a commodity currency. USDCAD is a good pair for day trading as well as swing trading. Just keep this in mind that a 1 pip on USDCAD is around $7 whereas 1 pip on EURUSD, GBPUSD, AUDUSD and NZDUSD is $10. So when you make 100 pips on USDCAD you will be making less as compared to EURUSD. USDCAD is highly volatile and many day traders fail to completely master its moves which make USDCAD trading challenging for most day traders. Take a look at the following USDCAD H4 chart:
[Image: USDCAD+H411.png]
Now you can see two good swing trading opportunities in the above chart. First USDCAD rallied for many days. You could have profited from it. After that it started falling like a stone and you could again profit from it. USDCAD is notorious for showing erratic behavior. You need to be aware of this fact. USDCAD can give good swing trades if you can understand its erratic behavior.

Print this item


Posted by: Hassam
01-06-2019, 06:33 AM
Forum: Million Dollar Trading Challenge
- No Replies

EURUSD is one of the most important major pairs. Many day traders love to trade EURUSD. When you trade a currency pair, you should have a rough idea of its daily range. Average daily range of EURUSD is around 40-60 pips. But sometime it can move big time. This happens when there is uncertainty in the financial markets. Take a look at EURUSD H1 chart below:
[Image: EURUSDH111.png]
Above you can see EURUSD price action during the last week. First negative news and EURUSD starts falling. Then it rises. When I trade EURUSD, I am able to find find trades with tight stop loss. Most of the time the stop loss can be less than 10 pips. Just make sure that you don't have a very high take profit target. 40-50 pips profit target is okay for most of the days. Sometimes the pair will move big time. But you cannot predict those days. Most of the time you just have a vague idea. Take a look at EURUSD daily chart below:
[Image: EURUSDD11.png]
Now you can see in the above EURUSD daily chart, EURUSD has been ranging for many days on the daily chart. This is precisely what I had said above. Most of the time, EURUSD will be ranging. EURUSD moves big time when there is a press conference by ECB. European Central Bank has a tight control over EURO. EURO is now roughly 19 years old. It has faced many challenges and come out safe and sound. But still there are some structural problems that can make this currency experiment a failure. More on that in a future post.

Print this item


Posted by: Hassam
01-06-2019, 05:40 AM
Forum: Million Dollar Trading Challenge
- Replies (1)

GBPUSD is a highly volatile pair. Many day traders love to trade GBPUSD. British Pound has been under tremendous pressure ever since Brexit announcement was made. Just after the Brexit vote GBPUSD fell more than 2000 pips. Then it made recovery. Next year it suffered a terrible flash crash and fell 1100 pips in a few months before making recovery. In the last few months, a lot of pressure has build up as Brexit negotiations are not going well. Take a look at GBPUSD H1 chart below!
[Image: GBPUSDH122.png]
In the above chart, you can see see GBPUSD activity last week. First it fell heavily. This fall was due to the Brexit
pressure. UK Prime Minister May has failed to get Brexit plan approval from parliament. Then GBPUSD turned and has made a rally. GBPUSD is a resilient currency pair. If you are a day trader, you will love to trade it. Just keep this in mind that GBPUSD has the habit of taking unexpected turns. So always be on your guard. Take a look at GBPUSD H4 chart below:
[Image: GBPUSDH411.png]
You can see the big bearish candle with a long lower shadow. Almost all the currency pairs having USD on one side has this candle with a long shadow. After that you can see there was a strong rally and GBPUSD has almost recovered. 

When you are trading GBPUSD, keep on eye on the Bank of England and the US Federal Reserve Bank. These two central banks have a major influence on GBPUSD. Bank of England take are of British Pound and the US Federal Reserve Bank take care of US Dollar. When anyone gets weak or strong, we see this pair move tremendously. European Central Bank ECB also sometimes exerts influence indirectly. Whatever just keep this in mind that financial markets are highly interlinked. All markets are interlined and move starting in one market can easily ripple into the other markets. Take a look at GBPUSD Weekly chart:
[Image: GBPUSDW11.png]
In the above chart, you can see the bullish pinbar. This is a strong signal that in the next few weeks, we are going to see GBPUSD bullish. 1.24363 appears to be the support for the next few months.

Print this item


Posted by: Hassam
01-03-2019, 02:48 PM
Forum: Million Dollar Trading Challenge
- Replies (2)

USDJPY Falls 300 Pips In A Few Minutes!
USDJPY fell around 300 pips today and then recovered. Flash crashes are becoming a norm in the currency market. We currency traders should be aware of this fact. Bank of Japan (BOJ) controls Japanese Yen and most of the time it intervenes to keep it weak as compared to other currencies. A strong Japanese Yen is not good for Japanese exports. On the other side we have US Dollar. US Dollar is the international currency that is most used in trade and commerce. Most of the time we will see the the move originating in the US market and then rippling through to the rest of the global financial markets. Take a look at USDJPY H4 chart:
[Image: USDJPY+H411.png]
Now you can see in the above charts, USDJPY is already in the downtrend. Then we have a big bearish H4 candle. This drop in USDJPY price happened during thin market hours i.e the Asian Market Hours. When there is a huge sell order and the market is thin, we have a flash crash. We currency traders now risk facing a flash crash on a constant basis. We should be always ready for a flash crash. If you are on the right side, you can make quick pips and if you are on the wrong side, you can get burned.

Flash crashes are highly risky. When the price starts dropping, there is no one who is willing to buy. So the stop loss that you have placed most probably will not work as a risk management measure. Price will fall and you will see the stop loss didn't execute as no one was willing to take the buy side. So you should be ever vigilant against these Flash Crashes.Take a look at USDJPY M5 chart:
[Image: USDJPY+M511.png]
Now you can see above USDJPY price fell and we have two very big 5 minute candles. After that USDJPY price recovers and the USDJPY starts rising. This is precisely what is happening in most of these flash crashes. Price falls rapidly and then it recovers in the next 5-10 minutes.

Print this item


Posted by: Hassam
01-03-2019, 02:16 PM
Forum: Million Dollar Trading Challenge
- No Replies

AUDUSD Falls To Its Lowest Level in 9 Years!
AUDUSD is a good pair that most of the time behaves very well. But sometimes it can show erratic behavior. Currencies in recent years have shown tendency of falling sharply suddenly and then recovering in a few minutes. This is precisely what happened today with AUDUSD. It fell to the low of 0.67190 and then recovered in the next 10-15 minutes to 0.69351. Take a look at the following AUDUSD H4 screenshot:
[Image: AUDUSD+H411.png]

Now can you see the most recent H4 candle showing a very long tail? This tail was formed on breaking news that made the financial media nervous. The catalyst this time has been the Apple. Apple sales have been impacted heavily by the slowdown in the Chinese domestic economy where Apple iPhones were selling well. This news first caused havoc in the stock market and then it was the turn of the currency markets. Whatever, as currency traders we just have the charts. We look at the charts and from those charts we make our buy and sell decisions. Take a look at the AUDUSD H1 chart below:
[Image: AUDUSD+H111.png]
Now in the above AUDUSD H1 chart, you can see the big lower shadow in the AUDUSD H1 candle that is followed by the bullish candle. These flash crashes are becoming frequent in the currency market. This sudden drop happened when the market is having low liquidity as it is the start of the new year and most traders are still on holidays and it will take the market few more days to recover its full volume and liquidity. Below is the AUDUSD M30 chart:
[Image: AUDUSD+M3011.png]
Now the problem with these flash crashes is that when they happen, most of the time the traders get caught on the wrong side of the market and get their accounts blown. Most of these flash crashes are being blamed on rogue algorithms that trade news. When they see news like bad Apple sales and bad EU performance, they open huge sell orders that can wrack havoc with the currency market during times of low volume and low volatility. Below is AUDUSD M5 chart:
[Image: AUDUSD+M511.png]
Now in the above AUDUSD M5 chart, you can see two very big AUDUSD M5 candles. First M5 candle is bearish and AUDUSD falls heavily like a stone. But then in the next 5 minute candle we see AUDUSD recovering rapidly and AUDUSD price rising. Fortunately we didn't trade AUDUSD. There must be many trader who would have been burned by this sudden price drop and then price rise.

As you can see, it is always a good idea to take at the different timeframes. The change in the market regime first appears on the lower timeframe then propagates to the higher timeframes. When you are trading a currency pair you are trading two currencies in fact. In case of AUDUSD, we are trading Aussie Dollar against the US Dollar. We need to keep an eye on what is happening on the two economies the Aussie economy and the US economy. Sometimes the move starts in the Aussie economy and most of time, the move will start in the US economy. You need to understand both the economies.

Print this item


Posted by: Hassam
12-14-2018, 05:36 PM
Forum: Algorithmic Trading With R
- No Replies

If you are compiling a package from source than you will need RTools. I was reading the book,"Statistical Analysis of Financial Data In R". The book has got an R package that is available on R Forge as a source package or binary package. It is not available on the standard CRAN. I wanted to install the binaries. When I tried to install it, I got the message that R will need to compile the C/C++/Fortran binaries. I would need Rtools for that. Rtools is separate from R. So I download it and installed it on my computer. I have installed R on my D drive in the folder Program Files. I installed Rtools on the same D drive Program Files Folder. Now I try and find the following error:

> install.packages("D:/Shared/R/Rsafd_1.2.tar.gz",repos=NULL,
+ type="source")
In R CMD INSTALL
* installing *source* package 'Rsafd' ...
** libs
c:/Rtools/mingw_64/bin/g++  -I"D:/Program Files/R/R-3.5.1/include" -DNDEBUG          -O2 -Wall  -mtune=generic -c empirfunc.cpp -o empirfunc.o
sh: c:/Rtools/mingw_64/bin/g++: No such file or directory
make: *** [D:/Program Files/R/R-3.5.1/etc/x64/Makeconf:215: empirfunc.o] Error 127
ERROR: compilation failed for package 'Rsafd'
* removing 'D:/Program Files/R/R-3.5.1/library/Rsafd'
Warning message:
In install.packages("D:/Shared/R/Rsafd_1.2.tar.gz", repos = NULL,  :
  installation of package 'D:/Shared/R/Rsafd_1.2.tar.gz' had non-zero exit status

Now Error 127 means R is unable to do the compilation. On close examination I find R trying to find Rtools on the C Drive. I change the Environment Variable path on Windows and find that it is correctly pointed to D Drive Program Files Rtools folder. What's the problem then? I search google and find the R has a file:

> file.path(R.home("etc"), "Makeconf")

[1] "D:/Program Files/R/R-3.5.1/etc/Makeconf"

This Makeconf file has been hard wired into looking for the Rtools on the C Drive c:/Rtools/mingw_64/bin/g++. There is a variable BINPREF that needs to be added to the Environment Variables that will override the default Makeconf file settings. So I add this Environment Variable:

BINPREF=D:\Program Files\Rtools\mingw_$(WIN)\bin\

I do that. Now R knows where to find Rtools in the new location but again it is stuck and can't find the files as there is a space in the Program Files and it cannot go beyong D:\Program. After doing the search on Google. I find the solution that I need to reinstall Rtools to a folder that hasn't got a space in it. So I install Rtools to the Stuff folder on D Drive and now I don't add the BINREF environment variable. I can do that but I change it for the current R session with the command:

Sys.setenv(BINPREF="D:/Stuff/Rtools/mingw_$(WIN)/bin/")

This command works and tells R that use this BINPREF for the session. I again run the install.packages command and viola the source package gets compiled and everything starts working nicely. I have made this thread so that anyone who is facing the same problem can easily solve it now. Rtools needs to be recognized by R before R can use it to compile package binaries. The most important thing is the BINPREF variable that needs to be properly set. $WIN in the above command ensures that it properly recognize whether your system is 32 or 64. Once you have done that R will have no problem whatsoever using Rtools in compiling source packages. With the R command Sys.setenv(0 above we don't need to add the environment variable BINPREF. If you want to add the BINPREF to the environment, add the following environment variable:

BINPREF=D:\Stuff\Rtools\mingw_$(WIN)\bin\

In the same manner you can use the following command to add the Rtools to the path:

Sys.setenv(PATH = paste("D:/Stuff/Rtools/bin", Sys.getenv("PATH"), sep=";"))

You can also check the path variables with the following command:

Sys.getenv()['PATH']

Now these were a little tips when you install Rtools on a drive different than C. If you install it on C than R will immediately recognize it otherwise you will have to use the above tricks to make R recognize the new Rtools location. R is a robust software and I think it is much better than Python when it comes to installation and management. I now check whether I can call Rsafd:

> library(Rsafd)
Loading required package: MASS
Loading required package: mvtnorm
Loading required package: robustbase
Loading required package: quantreg
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

Loading required package: splines
Loading required package: timeDate
Loading required package: rgl

Attaching package: 'Rsafd'

The following objects are masked from 'package:mvtnorm':

    dmvnorm, rmvnorm

If you are interested in reading Statistical Analysis of Financial Data in R, you can safely install its package Rsafd.

Print this item