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

Monday, 20 March 2023

mocker data generator using nodejs

 fake data generator using node.js

 synthetic data generation using nodejs

Help link

https://www.npmjs.com/package/mocker-data-generator

https://chancejs.com/


https://phaker.js.org/


https://fakerjs.dev/



test_data_generator.js

var mocker = require('mocker-data-generator').default // (vanilla way)
const { faker } = require('@faker-js/faker');

var users = {
firstName: {
faker: 'name.firstName()'
},
lastName: {
faker: 'name.lastName()'
},
country: {
faker: 'address.country()'
},
city: {
faker: 'address.city()'
},
// description: {
// faker: 'lorem.paragraph()'
// },
createdAt: {
faker: 'date.past()'
},
id: {
incrementalId: 0
},
age: {
faker: 'datatype.number({"min": 18, "max": 30})'
//faker: 'random.numeric(2,{"min": 1, "max": 17})'
},
birthdate:{
faker:'date.birthdate({ "min": 10, "max": 20, "mode": "age" })'
},
user_group:{
values:
['Primary Owner', 'Owner', 'Admin','Editor','Contributor','Viewer','Billing']
},
emails:
{
faker: 'internet.email()'
}
,
// emails: [
// {
// faker: 'internet.email()',
// length: 1
// }
// ],
username: {
function: function () {
return (
this.object.lastName.substring(0, 5) +
this.object.firstName.substring(0, 3) +
Math.floor(Math.random() * 10)
)
}
},
phone_number:{
faker:"phone.number('+91 97 ### ### ##')"
},
account_balance:{
faker:"finance.amount()"
},
currencyCode:{
faker:'finance.currencyCode()'
},
account_number:{
faker:'finance.account()'
},
accountName:{
faker:'finance.accountName()'
},
creditCardCVV:{
faker:'finance.creditCardCVV()'
},
creditCardIssuer:{
faker:'finance.creditCardIssuer()'
},
creditCardNumber:{
faker:"finance.creditCardNumber('63[7-9]#-####-####-####')"
},
last_login_ip4:{
faker:"internet.ipv4()"
},
last_login_ip6:{
faker:"internet.ipv6()"
},
get: {
function() {
return this.object.emails[0]
}
}
}


var house = {
id: {
incrementalId: 0
},
address: {
faker: 'address.streetAddress'
},
householder: {
hasOne: 'users'
},
// mateIds: {
// hasMany: 'users',
// max: 2,
// min: 2,
// unique: true
// }
};

console.time('bench')
mocker()
.addGenerator('faker', faker)
.schema('users', users, 10)
.schema('cat2', users, { uniqueField: 'user_group' })
.schema('houses', house, 5)
.build(function (err, data) {
console.log(err)
console.timeEnd('bench')
console.log(JSON.stringify(data));
})


package.json
{
"name": "mocker-data-generator",
"version": "1.0.0",
"dependencies": {
"ava": "^5.1.0",
"casual-browserify": "^1.5.19",
"chance": "^1.1.7",
"codecov": "^3.8.2",
"conventional-github-releaser": "^3.1.5",
"gh-pages": "^4.0.0",
"http-server": "^14.1.1",
"mocker-data-generator": "^3.0.1",
"multiview": "^3.0.1",
"npm-scripts-info": "^0.3.9",
"nyc": "^15.1.0",
"opn-cli": "^5.0.0",
"phaker.js": "^6.0.0-rc.1",
"prettier": "^2.8.1",
"randexp": "^0.5.3",
"standard-version": "^9.5.0",
"trash-cli": "^5.0.0",
"ts-node": "^10.9.1",
"tslib": "^2.4.1",
"tslint": "^6.1.3",
"tslint-config-standard": "^9.0.0",
"typedoc": "^0.23.23",
"typescript": "^4.9.4"
},
"devDependencies": {
"@faker-js/faker": "^7.6.0"
}
}

Tuesday, 14 February 2023

इस्लामिक आतंकवाद अफ्रीका में अपने अबतक के सबसे ऊपरी स्तरों पर हे

फ्रांसीसी आतंकवाद विरोधी दबाव में कमी ने सलाफी-जिहादी उग्रवादियों को आंदोलन की अधिक स्वतंत्रता दी है। माली में फ्रांसीसी आतंकवाद विरोधी अभियान अंततः साहेल में सलाफी-जिहादी विद्रोह को समाप्त करने में विफल रहा। यह मुख्य रूप से इसलिए है क्योंकि फ़्रांस और  अमरीका इस वख्त रिसेशन से गुजर रहे हे और उक्रेन युद्ध में भी काफी संसाधन खर्च कररहा हे  फिर भी, फ्रांसीसी और यूरोपीय आतंकवाद विरोधी बलों ने कई आतंकवादी नेताओं को खत्म करने, उत्तरी मालियन शहरों की रक्षा करने में मदद करने और क्षेत्र में इस्लामिक स्टेट से संबद्ध होने के लिए पर्याप्त सैन्य दबाव डाला। मिशन के अंत ने जेएनआईएम और इस्लामिक स्टेट की साहेल शाखा दोनों का हौसला बढ़ाया है। इस्लामिक स्टेट के साहेल प्रांत के सदस्य—जिन्हें इस्लामिक स्टेट इन द ग्रेटर सहारा (आईएसजीएस) के रूप में भी जाना जाता है—दिसंबर 2022 में नए आईएस अमीर के प्रति वचनबद्ध होने पर बल के एक प्रदर्शन में पूर्वोत्तर माली में बड़ी संख्या में एकत्रित हुए। जेएनआईएम के अमीर, इयाद अग घाली ने 2023 में पूरे उत्तरी माली की यात्रा की और जनवरी में दो वर्षों में अपनी पहली सार्वजनिक उपस्थिति दर्ज की। 








वर्ल्ड में कई कंट्री और न्यूज़ एनालिस्ट जब भी अमरीका या कोई भी कंट्री इस्लामिक टेरोरिस्ट को मरने जाता हे तो पहले उसका विरोध करता हे। अमरीका और  फ्रांस जैसे कंट्री अपने पैसे और ससाधन इन कंट्री और को और भविष्य में आने वाली समस्या के लिए अभी से लड़ रहेहे। इस्लामी टेररिस्ट केवल लोगो को ही माररहे हे ऐसा नहीं हे बल्कि ये पर्यावरण और पशु समाज को भी नष्ट कर रहे हे। जब भी अमरीका और फ़्रांस या और कोईभी कंट्री इस्लामिक कंट्री या वॉर जोन से विथड्रो करती हे तब लोग उसका विरोध करते हे और उसे फेलियर कहते हे (जब की ये लोग जहा रहते हे वह का नातो इतिहास जानते हे और वर्तमान को समाज सकतेहै और भविष्य की तो इन्हे चिंता नहीं हे इस बात का अहंकार तो इन्हे पहलेसे ही हे और यह बात वो खुद ही जोर शोर से बताते हे )

फ्रांस की वापसी और इसके बाद के झटकों ने जेएनआईएम से जुड़े अन्य उत्तरी मालियन अभिनेताओं को भी प्रभावित किया है। उत्तरी माली में कई सशस्त्र तुआरेग समूह हैं, जिनमें से अधिकांश तीन सामान्य शिविरों में आते हैं: सलाफी-जिहादी उग्रवादी, पूर्व अलगाववादी विद्रोही और संघ समर्थक सशस्त्र समूह। इनमें से कई समूहों और उनके नेताओं का साझा मानव नेटवर्क का दशकों पुराना इतिहास है।  सलाफी-जिहादी समूहों और समर्थक अलगाववादी समूहों ने शुरू में 2012 में उत्तरी माली विद्रोह के एक ही पक्ष में लड़ाई लड़ी, इससे पहले कि 2013 में फ्रांसीसी नेतृत्व वाले हस्तक्षेप ने गैर-जिहादी विद्रोहियों को अग गली के अंसार अल दीन समूह से अलग करने में मदद की। अंतर्राष्ट्रीय समुदाय ने 2015 में विभिन्न तुआरेग विद्रोहियों और मालियन सरकार के बीच एक समझौते की सुविधा प्रदान की, जो काफी हद तक लागू नहीं हुआ है। हालांकि, औपचारिक दूरी के बावजूद अग घाली ने पूर्व विद्रोही नेटवर्क के साथ संपर्क बनाए रखा है।

एक जेएनआईएम-नियंत्रित उत्तरी माली भी अंतरराष्ट्रीय आतंकी हमलों की साजिश रचने वाली कोशिकाओं का अड्डा बन सकता है। दीर्घकालिक सबसे खराब स्थिति में, जेएनआईएम इन पनाहगाहों का उपयोग अंतरराष्ट्रीय हमले की क्षमताओं को विकसित करने के लिए कर सकता है। पिछले पैटर्न से पता चलता है कि समूह तेजी से स्थानीय से अंतरराष्ट्रीय लक्ष्यों की ओर बढ़ सकते हैं और यह कि कई कारक स्थानीय समूहों को अंतरराष्ट्रीय हमलों का पीछा करने या समर्थन करने के लिए प्रेरित करते हैं। जेएनआईएम संभवत: अल्पावधि में अंतरराष्ट्रीय हमलों का पीछा नहीं करेगा, लेकिन समूह ने वैश्विक हमलों को प्रोत्साहित करना जारी रखा है और कभी भी बाहरी आतंकी हमले की साजिश रचने से इनकार नहीं किया है।

























Thursday, 24 November 2022

angular v15 directive ngFor handling empty list

 


// hello.component.ts


import { Component, Input } from '@angular/core';
import { NgForEmpty } from './ng-of-empty';

@Component({
selector: 'hello',
template: `<h1>Hello {{name}}!</h1>
<ul>
<li *ngFor="let p of persons; empty: emptyTmpl">{{p}}</li>
</ul>
<ng-template #emptyTmpl>Empty list</ng-template>
`,
styles: [`h1 { font-family: Lato; }`],
standalone: true,
imports: [NgForEmpty],
})
export class HelloComponent {
@Input() name: string;
persons = ['Dignāga','Dharmakīrti','Kamalaśīla','Śāntarakṣita',
             'Asanga','Vasubandhu'];
}


// ng-of-empty.ts



import { NgFor, NgIf } from '@angular/common';
import { Directive, inject, Input } from '@angular/core';

@Directive({
selector: '[ngFor]',
standalone: true,
hostDirectives: [
{ directive: NgFor, inputs: ['ngForOf'] },
{ directive: NgIf, inputs: ['ngIfElse: ngForEmpty'] },
],
})
export class NgForEmpty<T> {
private readonly ngIf = inject(NgIf, { host: true });

@Input() set ngForOf(ngFor: T[] | undefined) {
this.ngIf.ngIf = ngFor && ngFor.length > 0;
}
}




Sunday, 20 November 2022

Angular functional guard to check on the user role to guard your routes

functional guard to check on the user role  to guard your routes. 


The functional guard accepts a param for the user role 


Less verbose than a class based guard



    use canMatch to skip a route dynamically in combination with functional guards. 

  👍 Super handy when a path should lead to different comp depending on some logic 

  👋 canLoad is going to be deprecated in favor of canMatch


    


Saturday, 19 November 2022

Directive composition API in Angular 15

our directive stand alone by adding standalone property inside directive declaration 

import { Directive } from '@angular/core';

@Directive({
  selector: '[appRedColor]',
  host:{'style': 'color:red;'},
  standalone: true
})
export class RedColorDirective {

  constructor() { }

}

Now the text inside testdirective component will be displayed in red color.

<app-testdirective></app-testdirective>

And our code looks simple without adding an extra directive in component tag.

We can add more than one directive inside hostDirectives property.


@Component({
  selector: 'app-testdirective',
  templateUrl: './testdirective.component.html',
  styleUrls: ['./testdirective.component.scss'],
  hostDirectives:[RedColorDirective,HeightDirective,FontStyleDirective,......]
})
export class TestdirectiveComponent {
}

We can add hostDirectives inside an another directive as well.

Saturday, 15 October 2022

Reusable ng-template with parameters




<ng-template #loading let-overlayHeight="overlayHeight"
let-loaderLeft="loaderLeft" let-marginTop="marginTop">
<div class="overlay" [style.marginTop]="marginTop || ''"
[style.height]="overlayHeight || '100%'" style="position:relative;">
<div class="loader" [style.left]="loaderLeft || '40%'"
        style="position:relative;top:35%">
<svg viewBox="0 0 86 80">
<polygon points="43 8 79 72 7 72"></polygon>
</svg>
</div>
</div>
</ng-template>


Use

<ng-template *ngIf="paretoProductCategoriesChartLoading"
[ngTemplateOutlet]="loading"
[ngTemplateOutletContext]="{overlayHeight: '280px',marginTop:'20px'}">
</ng-template>

Create a common Html element within angular template.

Sunday, 17 July 2022

change label css when checkbox checked

 

<form>
<label>
<input type="checkbox">
Make this red when checked
</label>
</form>
<button>Make this red too!</button>

<style>
body:has([type="checkbox"]:checked) label,
body:has([type="checkbox"]:checked) button {
color: red;
}
</style>


change label css when checkbox checked