Categories
Trading

How to Interpret Trading Volume

For those of us daytraders, intraday volume analysis is an important part of our job. When you trade from the comfort of your home, you lack the ability to see the market in live-action, compared to people trading on the floor. To compensate for that, you need the ability to read chart patterns. Trading volume is an integral part of it.

Trading Volume Analysis

The more volume associated with price action, the surer the move. For example, for breakout trades, we all know from statistics that 80% of all breakouts fail. If you are a breakout trader, how do you know when to enter a trade and when to stay on the sideline? By looking at the volume. If the breakout bar is accompanied by a surge in volume, we know that there are a lot of traders who participate in this breakout trade and the price probably will continue. On the other hand, if the breakout bar shows no significant change in volume, you’d better sit on your hands.

Climatic Volume Bar

For breakout and breakdown trades, you may need high volume bars signifying a change in trend. However, when an abnormally high volume bar appears during a strong rally or selloff, it may signify an end to the current trend. Why? Because the high volume bar signifies that there’s a huge amount of stocks changing hands during that period, meaning there’s no one left who hasn’t participated in the trend. When there’s no more buyer, the price has to come down, and vice versa.

Conclusion

Understanding trading volume and knowing how to read intraday volume will help you succeed as a trader.

Categories
Trading Uncategorized

How Indecision Can Eat Away Your Trading Profits

Most of us traders have experienced this: Your confidence is extremely high and you are very profitable when trading the demo account. However, all of that disappears once you go live. Fear of losing money can negatively affect how you trade. Suddenly, you commit all the errors that you otherwise would not commit while trading with paper money.

How Indecision Can Kill Your Trading Career

So you have been watching that stock for a while and notice it has been trending up strongly since the start of the trading day, signaling the bull is controlling the market. The move was so fast from the beginning that you didn’t have a chance to jump on the bandwagon. Then, the stock stops climbing up and starts moving down, but slowly and on lighter volume. You know this may be a pullback and if you want to join in, now is your chance.

However, you hesitate to press that buy button as the price fluctuates up and down. Every time it moves a little bit lower, you ask yourself if the stock is actually beginning a downtrend instead of having a minor correction.

While you are still considering the alternatives, the stock makes a bold move and jumps up from the low. It keeps moving up, on higher volume. You sit there, freezing. The stock keeps moving higher, without you. Now it’s late to enter the trade. Congratulations. Your indecision has just ruined your chance of having a great trade.

Have many times had this happened to you when you first got started trading with real money? I bet many times. Because that’s exactly what happened to me.

Even though indecision may seem harmless, at least it didn’t result in a loss, it’s actually very harmful because it causes you to miss potentially homerun trades. Of course, you may argue that you just as well avoid potential losing trades as well. To test this theory, let’s keep a journal of the trades you decided not to take or miss. You need to jot down the potential profit (or loss) that missed trade could have generated. Once you have enough data, you can conclude whether you should do the opposite of your hesitation next time or not.

How to Be a Confident Trader

First of all, most new traders suffer from indecision, so do traders who have just experienced big losses. Your confidence level will rise as you gain more experience. However, this doesn’t mean you should let indecision affect how you make trading decisions. To be able to do this, you need to create a trading plan and stick to that plan. To be able to do that, you need discipline and lots of practice. No one can become a disciplined trader overnight. It’s estimated that you need an average of 10,000 hours of practice in any field to become an expert.

Before entering any trade, calculate your risk/reward ratio and your stop loss level. If the trade satisfied your risk/reward requirements, go ahead and push the button. If not, it’s ok to pass it and wait for a better opportunity.

Hesitation and indecision are common among new traders. However, with the right approach, you can speed up the learning curve and move your trading journey to the next level.

Categories
Blog Psychology

How to Hack Your Subconscious Mind

Most of us have heard about the subconscious mind, however, most don’t have a clear idea of what it really is and how to best utilize our subconscious mind to our advantage.

What Is the Subconscious Mind

The subconscious mind is, as its name suggests, a part of the brain that you may not be aware of while you are awake. When you are asleep, however, the subconscious mind becomes more active than ever. It actively runs through what happened in the previous day and stores data into the permanent memory.

How to Hack Your Subconscious Mind

There is a simple tip you can implement today to start making your subconscious mind work for you. First, here’s a fact: Your subconscious mind cannot distinguish between negative thoughts and positive ones. Whatever you feed into the subconscious mind will be used by it to form automatic thought patterns that determine your view of the world.

Now, here’s the trick to hack the subconscious mind: Right before falling asleep, think about something that you would like the subconscious mind to work on. Surely, you don’t want to dwell on sad memories or else your subconscious will work on that and god knows what more of it you will get in the morning.

Make your subconscious mind work for you by deliberately thinking about good memories and things you want to achieve or solve right before falling asleep. The power of the subconscious is unlimited. Even when you feel hopeless and clueless during the day, the subconscious has ways of tapping into the infinite intelligence which will provide a solution to your problem. When you wake up in the morning, you’ll come up with ideas that you never thought about before the previous day.

Categories
Self-Esteem

How to Improve Your Self-Esteem (And How Would It Help You Anyway)

Good and Bad Self Esteem

You initially think as long as it’s high self-esteem, it’s good, right? After all, isn’t it something most books taught you? “Be confident. Believe in yourself. Believe in what you want. And you will get what you want.” I’m not criticizing the aforementioned statement, on the contrary, that’s what I live by. What I’m talking about here are different spectrums of self-esteem.

Back in the 1980s, the Californian State lawmakers carried out an experiment: They funded a project to help increase the self-esteem level of all the Californian residents. The purpose? Because some books stated that low self-esteem was the root cause of all bad things in society: homicides, robberies, unemployment, abortions, teen pregnancies, low grades. Therefore, in an attempt to lower people’s dependency on drugs, state funds, boost the economy and make the world a better place, the legislators came up with the idea. Self-esteem boosting programs were introduced as part of the education system. Grades were inflated to make the students/pupils feel better about themselves. The result? Not so much promising. In fact, the lawmakers were so disappointed that doubts started to creep in.

How Is Self-Esteem Measured

The scientists currently use the Rosenberg Self-Esteem Scale to measure a person’s self- esteem level. If you want to do a little test on your own self-esteem, head over here: www.health.harvard.edu/mentalextra and complete some simple questions regarding your emotional intelligence.

When Is Self-Esteem a Good Thing?

High self-esteem is what motivates people to achieve great things in life. Studies have shown that people with high self-esteem tend to have less mental or relationship problems. They also have a higher chance of success in life. Why? Because their belief in themselves is so high that they don’t view every challenge appearing on their route to obtaining their goal as a dead-end thing or get de-motivated about defeats. And because they keep on going, they will eventually reach their destination.

If you know that low self-esteem increases your risk of poverty, would you be motivated enough to change yourself? Here’s a simple explanation of the phenomenon: People who have low self-esteem don’t usually believe in themselves or the things they do. They negatively self-talk themselves into believing the negative scenario of the future. And when they don’t think their actions will work out, what do they do? They don’t put in their full efforts, and stop trying on encountering the first challenge (which is inherently part of any goal/process). Thus, they achieve minimal or no results. And there goes the circle again. “I knew this wouldn’t work out!” They told themselves so, reinforcing the low self-esteem that was the root cause of their failure in the first place.

Research has also found out that people with high self-esteem tend to bounce back quicker when undergoing a tough time, and their stress hormone levels tend to return to normal quicker as well.

When Is High Self-Esteem Bad?

When high self-esteem is not justified by reality, it becomes questionable. I would scratch my head in confusion if you continue to feel good about yourself while your life is falling apart around you. If you just focus on feeling good all the time, you will become a delusional narcissist who refuses criticism and chase after feeling good no matter what.

John is a person who is always confident about himself. He tells people about the grand schemes he has for his life. He’s always busy chasing after his dreams. The problem is, he has no facts to back his confidence up. Even though he’s busy building, he hasn’t found success. He sells his dreams to his relatives, friends, and anyone who is willing to listen so as to get them to lend him money to fund his projects. Whenever people criticize him, he refuses to listen and counter-strikes back that they are merely jealous or do not understand his scheme. He spends borrowed money on extravagant things such as expensive dinners to impress partners, newly met people, or girls. He has the need to show off his luxury lifestyle to prove to people how successful he is. But soon, reality will catch up with him. People are tired of asking for their money back time after time and all they got was more bullshit promises from John. He cuts contact with them.

John may not be the intentional con artist, but his narcissistic personality makes him one.

Do you know what’s the most dangerous thing about focusing on feeling high all the time? That you end up chasing after the things that make you feel high, regardless of whether they are meaningful to your life or your goal or not. Surely buying new expensive shoes or designer clothes feels good, but does it help if the price of each item is your entire month’s salary? Surely listening to this song feels good, but does it help you pass your imminent test tomorrow morning, which you haven’t even studied yet because you are busy listening to music?

And to make matters worse, most criminals, sex offenders, and child abusers do not suffer from low self-esteem either. In fact, bullies and psychopaths tend to think highly of themselves.

I feel very strongly that we need to regard self-esteem in a more practical way. Toxic self-esteem will not help you grow as a person. Healthy self-esteem does.

Practice Gratitude

Believe it or not, even when you are at your lowest point, you still have something to be grateful for. Being alive at the moment is among those things. You may not realize because your brain works on autopilot, but breathing in the fresh air and feeling it permeate your body is something beautiful and to be grateful for.

“Reflect upon your present blessings, of which every man has plenty; not on your past misfortunes, of which all men have some.” 

Charles Dickens

Even if you are feeling totally shitty and wonder what the heck to be grateful for, stop, and think. IS IT REALLY THAT BAD?! Now, rewind your memory a little bit to think of another difficult time that you have been through. How did you overcome it? The last time you encountered a challenge, you thought it was the end of the world, just like this one, right? The funny thing about our brain and perception is we tend to negative-talk ourselves into believing the extreme. If you are a bit of a stuck-up asshole who thinks too highly of yourself, to the point of delusional confidence, you tend to view everything, you, the situation, your talent, your appearance, in a much better light than the reality. The reverse is true for a pessimistic person. That’s why it gets tricky. That’s why next time your brain tells you how terrible or how brilliant you are, counter-question it.

Now, back to the topic of gratitude. What does it have to do with improving self-esteem anyway, you ask. Well, the basic of high self-esteem is the appreciation we have about our self. Since you can only be appreciative of yourself if you are grateful for what you have, who you are, etc. , gratitude does play a part here. Oprah Winfrey had something to say about gratitude. She said that if you are grateful for what you currently have, you will end up with more. If you only focus on the lack of things, sure enough, you will never be happy, no matter how much you have. Happiness is a state of the mind, so it stands to reason that you can instantly feel happy by changing your state of mind. How do I change my state of mind, you ask. By thinking about something good. And researches have shown that just by changing our posture, we can change the way we feel. The next time you feel sad, just straighten up, and smile. You’ll see the difference.

Categories
Uncategorized

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

Categories
Uncategorized

143. Reorder List Leetcode Javascript Solution

The Problem:

You are given the head of a singly linked-list. The list can be represented as:

L0 → L1 → … → Ln - 1 → Ln

Reorder the list to be on the following form:

L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → …

You may not modify the values in the list’s nodes. Only nodes themselves may be changed.

Example 1:

Input: head = [1,2,3,4]
Output: [1,4,2,3]

Example 2:

Input: head = [1,2,3,4,5]
Output: [1,5,2,4,3]

Constraints:

  • The number of nodes in the list is in the range [1, 5 * 104].
  • 1 <= Node.val <= 1000

The Solution:

var reorderList = function(head) {
    if(head == null) return head
let fast = head, slow = head
while(fast.next && fast.next.next){
    slow = slow.next
    fast = fast.next.next
}
    //console.log(fast.val)
    p2 = slow.next
    //console.log(p2)
    slow.next = null
    let prev = null
    while(p2){
        let next = p2.next
         p2.next = prev
        prev = p2
        p2 = next
    }
    console.log(prev)
    console.log(head)
    let part1 = head, part2 = prev
    while(part2){
        let p1 = part1.next
        let p2 = part2.next
        part1.next = part2
        part2.next = p1
        part1 = p1
        part2 = p2
    }
    return head
};
Categories
Uncategorized

56. Merge Intervals Leetcode Javascript Solution

The Problem:

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.

Example 1:

Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].

Example 2:

Input: intervals = [[1,4],[4,5]]
Output: [[1,5]]
Explanation: Intervals [1,4] and [4,5] are considered overlapping.

Constraints:

  • 1 <= intervals.length <= 104
  • intervals[i].length == 2
  • 0 <= starti <= endi <= 104

The Problem:

var merge = function(intervals) {
    if(intervals.length == 1 || intervals.length == 0){ return intervals}
    intervals.sort((a,b) => a[0] !== b[0] ? a[0]-b[0] : a[1]-b[1])
   // console.log(intervals)
    let ans = [], prev = intervals[0]
    ans.push(prev)
    for(let interval of intervals){
       // console.log(prev)
        if(interval[0] <= prev[1]){
            prev[1] = Math.max(interval[1], prev[1])
            //prev = interval (remember not to update prev in this if
        } else {
            ans.push(interval)
            prev = interval
        }
       // console.log(ans)
    }
    return ans
};
Categories
Uncategorized

1721. Swapping Nodes in a Linked List Leetcode Javascript Solution

The Problem:

You are given the head of a linked list, and an integer k.

Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed).

Example 1:

Input: head = [1,2,3,4,5], k = 2
Output: [1,4,3,2,5]

Example 2:

Input: head = [7,9,6,6,7,8,3,0,9,5], k = 5
Output: [7,9,6,6,8,7,3,0,9,5]

Example 3:

Input: head = [1], k = 1
Output: [1]

Example 4:

Input: head = [1,2], k = 1
Output: [2,1]

Example 5:

Input: head = [1,2,3], k = 2
Output: [1,2,3]

Constraints:

  • The number of nodes in the list is n.
  • 1 <= k <= n <= 105
  • 0 <= Node.val <= 100

The Solution:

I got stuck at trying a new element swapping method with ES6 and wasted a good amount of time. In the end, I printed out variables line by line and used the old swapping method.

var swapNodes = function(head, k) {
    let dummy = new ListNode(0)
    dummy.next = head
    let fast = dummy, slow = dummy
    for(let i = 1; i <= k; i++){
        fast = fast.next
    }
  //  console.log(fast.val)
    let first = fast
    while(fast.next != null){
        slow = slow.next
        fast = fast.next
    }
    let second = slow.next
    //console.log("first: " + first.val + " second: " + second.val)
   // first.val, second.val = second.val, first.val
    //let a = 2, b = 4
    let temp = first.val
    first.val = second.val
    second.val = temp
   // console.log( "a: " + a + " b: " + b)
   // console.log("first: " + first.val + " second: " + second.val)
    return dummy.next
};
Categories
Uncategorized

438. Find All Anagrams in a String Leetcode Javascript Solution

The Problem:

Given a string s and a non-empty string p, find all the start indices of p‘s anagrams in s.

Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100.

The order of output does not matter.

Example 1:

Input:
s: "cbaebabacd" p: "abc"
Output:
[0, 6]
Explanation:
The substring with start index = 0 is "cba", which is an anagram of "abc".
The substring with start index = 6 is "bac", which is an anagram of "abc".

Example 2:

Input:
s: "abab" p: "ab"
Output:
[0, 1, 2]
Explanation:
The substring with start index = 0 is "ab", which is an anagram of "ab".
The substring with start index = 1 is "ba", which is an anagram of "ab".
The substring with start index = 2 is "ab", which is an anagram of "ab".

The Solution:

var findAnagrams = function(s, p) {
    let set = new Map()
    for(let i = 0; i < p.length; i++){
        if(!set.has(p[i])){
            set.set(p[i],1)
        } else{
            set.set(p[i],set.get(p[i]) + 1)
        }
    }
   // console.log(set)
    let ans = []
     let left = 0, right = 0, count = set.size
     while (right < s.length){
         if(set.has(s[right])){
             set.set(s[right],set.get(s[right]) - 1)
             if(set.get(s[right])== 0){
                 count--
             }
         }
         while(count == 0){
             if(set.has(s[left])){
                    set.set(s[left],set.get(s[left]) + 1)
                 if(set.get(s[left]) > 0){
                 count++
             }
             }
             if(right - left +1 == p.length){
                 ans.push(left)
             }
             left++
         }
         right++
     }
    return ans
};
Categories
Uncategorized

236. Lowest Common Ancestor of a Binary Tree Leetcode Javascript Solution

The Problem:

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.

According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

Example 1:

Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
Output: 3
Explanation: The LCA of nodes 5 and 1 is 3.

Example 2:

Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
Output: 5
Explanation: The LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition.

Example 3:

Input: root = [1,2], p = 1, q = 2
Output: 1

Constraints:

  • The number of nodes in the tree is in the range [2, 105].
  • -109 <= Node.val <= 109
  • All Node.val are unique.
  • p != q
  • p and q will exist in the tree.

The Solution:

var lowestCommonAncestor = function(root, p, q) {
    if(!root || root== p || root == q) return root
    let left = lowestCommonAncestor(root.left,p,q)
    let right = lowestCommonAncestor(root.right,p,q)
    return (left && right) ? root : (left || right)
};
Categories
Uncategorized

47. Permutations II Leetcode Javascript Solution

The Problem:

Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.

Example 1:

Input: nums = [1,1,2]
Output:
[[1,1,2],
[1,2,1],
[2,1,1]]

Example 2:

Input: nums = [1,2,3]
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]

Constraints:

  • 1 <= nums.length <= 8
  • -10 <= nums[i] <= 10

The Solution:

For this kind of problem, we’ll need to use backtracking. We also implement a boolean array with the same length as that of the number array to keep track of visited elements (because the number array contains duplicates):

var permuteUnique = function(nums) {
let results = []
nums.sort((a,b) => a-b)
function backtrack(nums,results, temp,used){
if(temp.length == nums.length){
results.push([…temp])
}
for(let i = 0; i < nums.length; i++){
// console.log(used + “ “+ i + “ “ + temp)
if(used[i] || (i > 0 && nums[i] == nums[i-1] && used[i — 1]) ){continue}
used[i] = true
temp.push(nums[i])
backtrack(nums,results, temp, used)
used[i] = false
temp.pop()
}
}
backtrack(nums,results, new Array(), new Array(nums.length).fill(false))
return results
};
Categories
Uncategorized

46. Permutations Leetcode Javascript Solution

The Problem:

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

Example 1:

Input: nums = [1,2,3]
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]

Example 2:

Input: nums = [0,1]
Output: [[0,1],[1,0]]

Example 3:

Input: nums = [1]
Output: [[1]]

Constraints:

  • 1 <= nums.length <= 6
  • -10 <= nums[i] <= 10
  • All the integers of nums are unique.

The Solution:

We use backtracking:

var permute = function(nums) {
  let results = []
  function backtrack(nums, results, temp){
      if(temp.length == nums.length){
          results.push([...temp])
      }
      for(let i = 0 ; i < nums.length; i++){
          if(temp.includes(nums[i])){continue}
          temp.push(nums[i])
          backtrack(nums,results,temp)
          temp.pop()
      }
  }
    backtrack(nums,results, new Array())
    return results
};
Categories
Uncategorized

90. Subsets II Leetcode Javascript Solution

The Problem:

Given an integer array nums that may contain duplicates, return all possible subsets (the power set).

The solution set must not contain duplicate subsets. Return the solution in any order.

Example 1:

Input: nums = [1,2,2]
Output: [[],[1],[1,2],[1,2,2],[2],[2,2]]

Example 2:

Input: nums = [0]
Output: [[],[0]]

Constraints:

  • 1 <= nums.length <= 10
  • -10 <= nums[i] <= 10

The Solution:

var subsetsWithDup = function(nums) {
    let results = [],temp = []
    nums.sort((a,b) => a-b)
    console.log(nums)
    function backtrack(nums,start,results, temp){
        results.push([...temp])
       /* console.log("results " )
        for( rest of results){
            console.log(rest)
        }
        */
        for(let i = start; i < nums.length; i++){
               //console.log("i " + i)
               if(i == start || nums[i] != nums[i-1]){
//                 console.log("i after if" + i)
                temp.push(nums[i])
             //   console.log(temp)
                backtrack(nums,i+1,results,temp)
                temp.pop()
//                console.log("temp after pop " + temp)
                 }
        }
    }
    backtrack(nums,0,results,temp)
    return results
};
Categories
Uncategorized

78. Subsets Leetcode Javascript Solution

The Problem:

Given an integer array nums of unique elements, return all possible subsets (the power set).

The solution set must not contain duplicate subsets. Return the solution in any order.

Example 1:

Input: nums = [1,2,3]
Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]

Example 2:

Input: nums = [0]
Output: [[],[0]]

Constraints:

  • 1 <= nums.length <= 10
  • -10 <= nums[i] <= 10
  • All the numbers of nums are unique.

The Solution:

We use backtracking for this problem.

var subsets = function(nums) {
    let results = []
    nums.sort()
    backtrack(nums,0,results,new Array())
    function backtrack(nums, start, results, temp){
        results.push([...temp])
        for(let i = start; i < nums.length; i++){
            temp.push(nums[i])
            backtrack(nums,i+1,results,temp)
            temp.pop()
        }
    }
    return results
};