Example of a Candlestick Plot

Your text-based plot should look something like this:

10 |                                                   
 9 |        |                                 |        
 8 |        |                                ---       
 7 |       +++                               ---       
 6 |       +++               |               ---       
 5 |       +++               |                |        
 4 |        |               ---               |        
 3 |        |               ---               |        
 2 |        |                |                |        
 1 |                         |                         
-------------------------------------------------------
        1980/01           1980/02          1980/03     

Basic logic to generate a text-based plot

Below are some examples of how you can manipulate the plot.

Let’s start with an empty main.cpp

#include <iostream>

int main(){
    std::cout << "Starting..." << std::endl;
    
    return 0;
}

Your output:

Starting...

Assuming you figure out a way to find out a yScale. Let’s print out the y-axis.

#include <iostream>

int main(){
    std::cout << "Starting..." << std::endl;
    int start = 5;
    int end = -5;

    for (int i=start; i>=end; --i){
        std::cout << i << "| " ;
        std::cout << std::endl;
    }
    return 0;
}

Your output:

Starting...
5| 
4| 
3| 
2| 
1| 
0| 
-1| 
-2| 
-3| 
-4| 
-5| 

Let’s print the x-axis also

#include <iostream>

int main(){
    std::cout << "Starting..." << std::endl;
    int start = 5;
    int end = -5;

    for (int i=start; i>=end; --i){
        std::cout << i << "|" ;

        std::cout << std::endl;
    }

    for (int i=0; i<=6; ++i) {
        std::cout << "---";
    }

    std::cout << std::endl;
    std::cout << "   ";

    for (int i=0; i<=5; ++i) {
        std::cout << " " << i << " ";
    }
    std::cout << std::endl;
    return 0;
}

Your output:

Starting...
5|
4|
3|
2|
1|
0|
-1|
-2|
-3|
-4|
-5|
---------------------
    0  1  2  3  4  5