Wednesday 29 November 2023

How to Export HTML to Image in Angular Component


# How to Export HTML to Image in Angular Component

As a web developer, you may encounter scenarios where you need to export the content of an HTML element to an image. In this tutorial, we will explore how to achieve this using the `html2canvas` library in an Angular component.

## Step 1: Install the html2canvas Package

Firstly, install the `html2canvas` package using npm:

```bash
npm install html2canvas --save
```

## Step 2: Import Required Modules

In your Angular component file, import the necessary modules:

import { Component, OnInit, OnDestroy, ElementRef, ViewChild } from
"@angular/core";

import html2canvas from 'html2canvas';

## Step 3: Component Setup

Define the necessary elements in your component:

@ViewChild('screen') screen: ElementRef;
@ViewChild('canvas') canvas: ElementRef;
@ViewChild('downloadLink') downloadLink: ElementRef;

## Step 4: Implement Image Download Function

Add a function to download the HTML content as an image:

downloadImage(){
html2canvas(this.screen.nativeElement).then(canvas => {
this.canvas.nativeElement.src = canvas.toDataURL();
this.downloadLink.nativeElement.href = canvas.toDataURL('image/png');
this.downloadLink.nativeElement.download = 'full_page.png';
this.downloadLink.nativeElement.click();
});
}

## Step 5: HTML Setup

In your component's HTML file, set up the elements for exporting:

<div #screen>
<h1>Hello Test</h1>
</div>

<div id="download">
<img #canvas>
<a #downloadLink></a>
</div>

## Step 6: Invoking the Function

Call the `downloadImage` function from your component when you want to trigger the export.

Now you have a complete setup to export HTML content as an image in your Angular component using `html2canvas`. Feel free to customize the code according to your specific requirements.

Happy coding!


Tuesday 17 October 2023

get multiple group by sum in javascript


 



let jsonData = {
"status": true,
"data": [
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Global",
"esg_audited": "non-audited",
"size": "large",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Global",
"esg_audited": "audited",
"size": "large",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Global",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 5
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Global",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 5
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Global",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Global",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 7
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "non-audited",
"size": "large",
"invoice_count": 7
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "non-audited",
"size": "sme",
"invoice_count": 23
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "large",
"invoice_count": 3
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 13
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 5
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 2
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 4
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 4
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 1
},
{
"year": 2021,
"quarter": 4,
"month": 12,
"mthkey": 202112,
"supplier": "root",
"demography": "Local",
"esg_audited": "audited",
"size": "sme",
"invoice_count": 2
}
]
}
----------------------------------
Function
----------------------------------
groupByMultis(data, keys,count_property_name) {
const counts = {};
data.forEach(item => {
let currentLevel = counts;
keys.forEach((key, index) => {
const value = item[key];
if (!currentLevel[value]) {
currentLevel[value] = { count: 0 };
}
currentLevel[value].count += item[count_property_name];
let val = parseFloat(parseFloat(currentLevel[value].count).toFixed(2));
currentLevel[value].count = val;
currentLevel = currentLevel[value];
});
});
return counts;
}
----------------------------------
Use
----------------------------------
let groupByMultisResult = this.groupByMultis(jsonData.data,
['esg_audited','demography','size'],'invoice_count');
----------------------------------
Result
----------------------------------
{
"non-audited": {
"count": 101,
"Global": {
"count": 36,
"large": {
"count": 2
},
"sme": {
"count": 34
}
},
"Local": {
"count": 65,
"large": {
"count": 14
},
"sme": {
"count": 51
}
}
},
"audited": {
"count": 147,
"Global": {
"count": 36,
"large": {
"count": 2
},
"sme": {
"count": 34
}
},
"Local": {
"count": 111,
"large": {
"count": 28
},
"sme": {
"count": 83
}
}
}
}



loopThroughObjRecurs (obj, count,propExec) {
for (var k in obj) {
if (typeof obj[k] === 'object' && obj[k] !== null) {
let currentCount = obj[k].count;
let percentage:any = (currentCount*100/count);
let val = parseFloat(parseFloat(percentage).toFixed(2));
obj[k]['percentage'] = val;
this.loopThroughObjRecurs(obj[k], obj[k].count,propExec)
} else if (obj.hasOwnProperty(k)) {
propExec(k, obj[k])
}
}
}

let rootCount = _.sumBy(jsonData.data,'invoice_count');
let withPercentage = loopThroughObjRecurs(groupByMultisResult,rootCount,
function(k, prop) {
//console.log(k + ': ' + prop);
});





Saturday 7 October 2023

Microservices patterns

 here is a list of some common microservices patterns


1. **API Gateway Pattern**:

   - **Description**: A single entry point for client requests that routes them to the appropriate microservices. It can handle tasks like authentication, load balancing, and caching.


2. **Service Discovery Pattern**:

   - **Description**: Microservices need to locate and communicate with each other dynamically. Service discovery patterns use tools like Consul, etcd, or DNS for automatic service registration and discovery.


3. **Circuit Breaker Pattern**:

   - **Description**: A fault-tolerant pattern that prevents a microservice from repeatedly trying to invoke a failing service. It "opens" the circuit when failures occur and "closes" it when the service becomes available.


4. **Retry Pattern**:

   - **Description**: In cases of transient failures, this pattern retries failed requests to a microservice. It helps ensure that occasional network glitches or temporary service unavailability doesn't lead to failures.


5. **Event Sourcing Pattern**:

   - **Description**: Instead of storing the current state of data, this pattern maintains a log of all changes (events) that have occurred. It can be useful for building event-driven architectures.


6. **Saga Pattern**:

   - **Description**: A way to manage distributed transactions across multiple microservices. Sagas break complex transactions into a series of smaller, individual steps with compensating actions in case of failure.


7. **Bulkhead Pattern**:

   - **Description**: Inspired by ship design, this pattern isolates failures in one microservice from affecting others. It involves using separate resources or processes for different parts of the application.


8. **Database per Service Pattern**:

   - **Description**: Each microservice has its own database. This pattern ensures loose coupling but may require mechanisms for data consistency and synchronization.


9. **Shared Database Pattern**:

   - **Description**: Some microservices share a single database. While it simplifies data access, it can lead to tight coupling and potential issues with data consistency.


10. **Backends for Frontends (BFF) Pattern**:

    - **Description**: Tailoring microservices for specific client applications. It helps optimize performance and reduces over-fetching of data for various client types.


11. **Asynchronous Messaging Pattern**:

    - **Description**: Communication between microservices through message queues (e.g., Kafka, RabbitMQ) for decoupling and scalability.


12. **Materialized View Pattern**:

    - **Description**: Creating precomputed views of data to improve query performance in read-heavy microservices.


13. **Choreography vs. Orchestration**:

    - **Description**: Deciding whether to use an event-driven choreography approach where microservices communicate directly or an orchestration approach with a central controller managing interactions.


14. **API Composition Pattern**:

    - **Description**: Aggregating data from multiple microservices to serve a client request in a single response, reducing the number of client-server interactions.


15. **Sidecar Pattern**:

    - **Description**: An auxiliary service that runs alongside a microservice to provide additional capabilities like logging, monitoring, or security.


16. **Gateway Aggregation Pattern**:

    - **Description**: Aggregating multiple microservices into a single, unified API gateway for clients, simplifying client interactions.


These patterns can be combined and tailored to meet the specific requirements of your microservices architecture. The choice of patterns will depend on factors like the nature of your application, scalability needs, and team expertise.


17. **External Configuration Pattern**:

    - **Description**: Managing configuration settings for microservices externally, allowing for dynamic updates without redeploying the services.


18. **Leader Election Pattern**:

    - **Description**: Used in scenarios where one microservice needs to be designated as the leader to perform certain tasks (e.g., in distributed systems).


19. **Fan-Out on Read Pattern**:

    - **Description**: When a microservice receives a read request, it fetches data from multiple other microservices in parallel to fulfill the request.


20. **Priority Queue Pattern**:

    - **Description**: Assigning priorities to tasks or messages in a microservices system to ensure high-priority tasks are processed before lower-priority ones.


21. **Stateless vs. Stateful Microservices**:

    - **Description**: Deciding whether microservices should be stateless (no local state) or stateful (maintaining some form of local state) based on application requirements.


22. **Bulkhead Isolation Pattern**:

    - **Description**: Isolating microservices into separate pools of resources (e.g., threads, processes, or containers) to prevent resource exhaustion from impacting other services.


23. **Shared Cache Pattern**:

    - **Description**: Storing commonly accessed data in a shared cache (e.g., Redis) to reduce redundant database calls and improve performance.


24. **API Versioning Pattern**:

    - **Description**: Managing changes to APIs by versioning them to ensure backward compatibility for existing clients while allowing for updates.


25. **Health Check Pattern**:

    - **Description**: Regularly checking the health and status of microservices to determine if they are available and responsive.


26. **Compensating Transaction Pattern**:

    - **Description**: Handling failures in distributed transactions by executing a compensating action to undo the effects of a failed transaction.


27. **Cross-Functional Teams Pattern**:

    - **Description**: Organizing development teams around microservices, where each team is responsible for one or more services, to promote ownership and accountability.


28. **Database Replication Pattern**:

    - **Description**: Replicating data across multiple databases or data centers to ensure data availability and fault tolerance.


29. **Service Mesh Pattern**:

    - **Description**: Implementing a service mesh (e.g., Istio, Linkerd) to manage communication, security, and observability between microservices.


30. **Concurrency Control Pattern**:

    - **Description**: Managing concurrent access to resources, such as databases or shared caches, to prevent conflicts and ensure data consistency.


Remember that not all of these patterns will be relevant to every microservices project. The choice of patterns should align with your specific architectural needs, scalability requirements, and the characteristics of your application. Understanding these patterns can help you design and implement microservices architectures more effectively.

Tuesday 1 August 2023

How to analyze a balance sheet



1️⃣ Working Capital


This measures a company's ability to meet its short-term obligations. A positive working capital indicates that the company has enough assets to cover its liabilities.


2️⃣ Current Ratio


This measures a company's ability to pay its current liabilities with its current assets. A ratio of 1:1 is considered ideal.


3️⃣ Quick Ratio


This is a more stringent measure of a company's liquidity, as it only includes highly liquid assets in the calculation.


4️⃣ Debt to Equity Ratio


The proportion of a company's financing that comes from debt versus equity. A high ratio may indicate that a company is taking on too much debt.


5️⃣ Debt to Assets Ratio


The proportion of a company's assets that are financed through debt. A high ratio may indicate that a company is taking on too much debt.


6️⃣ Asset Turnover Ratio


This measures a company's ability to generate revenue from its assets. A higher ratio indicates more efficient use of assets.


7️⃣ Return on Assets (ROA)


The efficiency with which a company generates profits from its assets. A higher ROA indicates that the company uses its assets more effectively.


8️⃣Return on Equity (ROE)


The profitability of a company in relation to the equity invested in it. A higher ROE indicates that the company generates more profits for its shareholders.


9️⃣ Days Sales Outstanding (DSO)


The average number of days a company takes to collect payment from its customers. A lower DSO indicates a more efficient collection of accounts receivable.


🔟 Inventory Turnover Ratio


The speed at which a company sells its inventory. A higher ratio indicates that the company is efficiently managing its inventory and generating sales.

Thursday 27 July 2023

SMART MONEY CONCEPTS GLOSSARY

 SMART MONEY CONCEPTS GLOSSARY


Break Of Structure (BOS) (CONTINUATION)

A BOS is when the price breaks above or below, and continues in the direction of the trend. (CONTINUATION).


Break Of Structure Down

When the price breaks and closes BELOW the wick of the previous LOW in a DOWNTREND.


Break Of Structure Up

When the price breaks and closes ABOVE the wick of the previous HIGH in an UPTREND.

Buy Side Liquidity (Smart Money SELLS)


Where an Order Block forms where Smart Money SELLS into retailers (dumb money) BUYING orders – Pushing the price DOWN.


Change of Character (CHoCH) (REVERSAL)

Refers to a much larger shift in the underlying market trend, dynamic or sentiment.

This is where the price moves to the point where there is a change in the overall trend. (REVERSAL)


Change of Character Down

When the price breaks and closes below the previous uptrend.


Change of Character Up

When the price breaks and closes above the previous downtrend.


Daily bias

Tells us which direction, trend and environment the market is in and what we are looking to trade.


Daily bias Bearish

When the market environment is DOWN and the trend is DOWN – we look for shorts (sells) in the market.


Daily bias Bullish

When the market environment is UP and the trend is UP – we look for long positions (buys) in the market.


Discount market <50%

The market is at a discount when the price trades BELOW the equilibrium level. We say the price is at a discount (low price).


Equilibrium

Equilibrium is a state of the market where the demand and supply are in balance with the price. We say the price of the market is at fair value.


Fair Value Gap (FVG)

A 3 candle structure with an up or down impulse candle that indicates and creates an imbalance or an inefficiency in the market.


Fair Value Gap Bearish

A 3 candle structure with a DOWN impulse candle that indicates and creates an imbalance or an inefficiency in the market.


Between candle 1 and 3, do NOT show common prices. The price needs to move back up to rebalance and fill the gap.


Fair Value Gap Bullish

A 3 candle structure with an UP impulse candle that indicates and creates an imbalance or an inefficiency in the market.


Between candle 1 and 3, do NOT show common prices. The price needs to come back down to rebalance and fill the gap.


Levels of liquidity

The area of prices where smart money players, identify and choose to BUY or SELL large quantities.


E.g. Supports, resistances, highs, lows, key levels, trend lines, volume, indicators, psychological levels.


Liquidity

The degree, rate and ability for an asset or security to be easily bought (flow in) or sold (flow out) in the market at a specific price.


Liquidity sweep (Liquidity grab)

Smart money buys or sells (and sweeps or grabs liquidity) from traders who enter, exit or get stopped.


Market down structure

When the price makes lower lows and lower highs.


Market structure

Indicates what a market is doing, which direction it’s in and where it is more likely to go.

Market Structure Shift (MSS)


MSS shows you when the price is breaking a structure or changing the direction in the market.


Market up structure

When the price makes higher lows and higher highs.


Order block

Large market orders (big block of orders) where smart money buys or sells from different levels of liquidity.


Order Block Bearish

A strong selling or a supply zone for smart money.


Order Block Bullish

A strong buying or a demand zone for smart money.


Order block events

Large market orders where smart money buys or sells from certain events i.e. High volume, supports, resistances, highs, lows, key levels, Break Of Structure, Change of Character, News or economic event.


Point Of Interest (POI)

POI is an area or level in the market where there is expected to be a large amount of buying or selling activity i.e. Order blocks.


Premium market >50%

The market is at a premium when the price trades ABOVE the equilibrium level.

We say the price is at a premium (high price).

Sunday 25 June 2023

Supertrend + CM_EMA Trend Bars + NSDT Auto Support / Resistance Levels



//@version=4
study("Supertrend", overlay = true, format=format.price, precision=2, resolution="")

Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1,
defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool,
defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool,
defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool,
defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend",
style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins",
location=location.absolute, style=shape.circle, size=size.tiny,
color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy",
text="Buy", location=location.absolute, style=shape.labelup,
size=size.tiny, color=color.green, textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend",
style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins",
location=location.absolute, style=shape.circle, size=size.tiny,
color=color.red, transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell",
text="Sell", location=location.absolute, style=shape.labeldown,
size=size.tiny, color=color.red, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change",
message="SuperTrend has changed direction!")

lookback1 = input(defval=5, title='# of Candles to Look Back')
lookback2 = input(defval=10, title='# of Candles to Look Back')
lookback3 = input(defval=20, title='# of Candles to Look Back')
src2 = 'Close'

pivothigh_1 = pivothigh(high, lookback1, lookback1)
pivothigh_2 = pivothigh(high, lookback1, lookback1)
pivot_high1 = src2 == 'Close' ? pivothigh_1 : pivothigh_2
pivotlow_1 = pivotlow(low, lookback1, lookback1)
pivotlow_2 = pivotlow(low, lookback1, lookback1)
pivot_low1 = src2 == 'Close' ? pivotlow_1 : pivotlow_2
pivothigh_3 = pivothigh(high, lookback2, lookback2)
pivothigh_4 = pivothigh(high, lookback2, lookback2)
pivot_high2 = src2 == 'Close' ? pivothigh_3 : pivothigh_4
pivotlow_3 = pivotlow(low, lookback2, lookback2)
pivotlow_4 = pivotlow(low, lookback2, lookback2)
pivot_low2 = src2 == 'Close' ? pivotlow_3 : pivotlow_4
pivothigh_5 = pivothigh(high, lookback3, lookback3)
pivothigh_6 = pivothigh(high, lookback3, lookback3)
pivot_high3 = src2 == 'Close' ? pivothigh_5 : pivothigh_6
pivotlow_5 = pivotlow(low, lookback3, lookback3)
pivotlow_6 = pivotlow(low, lookback3, lookback3)
pivot_low3 = src2 == 'Close' ? pivotlow_5 : pivotlow_6

valuewhen_1 = valuewhen(pivot_high1, high[lookback1], 0)
valuewhen_2 = valuewhen(pivot_high1, high[lookback1], 0)
plot_high1 = src2 == 'Close' ? valuewhen_1 : valuewhen_2
valuewhen_3 = valuewhen(pivot_low1, low[lookback1], 0)
valuewhen_4 = valuewhen(pivot_low1, low[lookback1], 0)
plot_low1 = src2 == 'Close' ? valuewhen_3 : valuewhen_4
valuewhen_5 = valuewhen(pivot_high2, high[lookback2], 0)
valuewhen_6 = valuewhen(pivot_high2, high[lookback2], 0)
plot_high2 = src2 == 'Close' ? valuewhen_5 : valuewhen_6
valuewhen_7 = valuewhen(pivot_low2, low[lookback2], 0)
valuewhen_8 = valuewhen(pivot_low2, low[lookback2], 0)
plot_low2 = src2 == 'Close' ? valuewhen_7 : valuewhen_8
valuewhen_9 = valuewhen(pivot_high3, high[lookback3], 0)
valuewhen_10 = valuewhen(pivot_high3, high[lookback3], 0)
plot_high3 = src2 == 'Close' ? valuewhen_9 : valuewhen_10
valuewhen_11 = valuewhen(pivot_low3, low[lookback3], 0)
valuewhen_12 = valuewhen(pivot_low3, low[lookback3], 0)
plot_low3 = src2 == 'Close' ? valuewhen_11 : valuewhen_12

resistance1 = plot(plot_high1, style=plot.style_line, title='R1',
color=color.new(color.white, 0), show_last=1, linewidth=1, trackprice=true)
support1 = plot(plot_low1, style=plot.style_line, title='S1',
color=color.new(color.white, 0), show_last=1, linewidth=1, trackprice=true)
resistance2 = plot(plot_high2, style=plot.style_line, title='R2',
color=color.new(color.yellow, 0), show_last=1, linewidth=2, trackprice=true)
support2 = plot(plot_low2, style=plot.style_line, title='S2',
color=color.new(color.yellow, 0), show_last=1, linewidth=2, trackprice=true)
resistance3 = plot(plot_high3, style=plot.style_line, title='R3',
color=color.new(color.orange, 0), show_last=1, linewidth=3, trackprice=true)
support3 = plot(plot_low3, style=plot.style_line, title='S3',
color=color.new(color.orange, 0), show_last=1, linewidth=3, trackprice=true)

alertcondition(close > plot_high1, title='Price Over Resistance 1',
message='Price Over Resistance 1')
alertcondition(close < plot_low1, title='Price Under Support 1',
message='Price Under Support 1')
alertcondition(close > plot_high2, title='Price Over Resistance 2',
message='Price Over Resistance 2')
alertcondition(close < plot_low2, title='Price Under Support 2',
message='Price Under Support 2')
alertcondition(close > plot_high3, title='Price Over Resistance 3',
message='Price Over Resistance 3')
alertcondition(close < plot_low3, title='Price Under Support 3',
message='Price Under Support 3')





ema1 = input(34, minval=1, maxval=300, title="EMA UpTrend")
shema = input(true, title="Show EMA Trend is Based On?")

usedEma = ema(close, ema1)

emaUpColor() => hlc3 >= usedEma
emaDownColor() => hlc3 < usedEma

col = hlc3 >= usedEma ? color.lime : hlc3 < usedEma ? color.red : color.white

barcolor(emaUpColor() ? color.lime: emaDownColor() ? color.red : na)
plot(shema and usedEma ? usedEma : na, title="EMA",linewidth=3, color=col)

    //More important indicator list
//Smart Money Concepts [LuxAlgo]
//Nadaraya-Watson Envelope [LuxAlgo]
//RSI Primed [ChartPrime]
//Volume