Pine Script TradingView Query - automation

I'm quite new to PINE and I'm hoping for some assistance, or to be pointed in the right direction. My goal is to script BUY/SELL signals which will use a PERCENTAGE of an available sum for use with a trading bot via TradingView.
For example, starting capital $100, buy signal comes through, which triggers buy of of 25% ($25) worth of X coin.
I have been unable to find the code to setup the more complicated percentage-based buy/sell orders. Perhaps I'm blind, if so, tell me! :) The below code provided by TradingView would use all available capital in the account to make 1 x buy trade... which is not ideal.
{
"action": "BUY",
"botId": "1234"
}
I have tried this to add % but to no avail:
{
"action": "BUY" percent_of_equity 25,
"botId": "1234"
}
Any suggestions? Am I missing anything obvious?
Related Articles:
Quadency
TradingView

The code above is not related to pine-script, but is part of alarm/webhook action.
If you want to declare equity in your (back)order, inside pine-script, you have to use strategy like something this:
strategy(title = "example",
shorttitle = "myscript",
overlay = true,
pyramiding = 1,
default_qty_type = strategy.percent_of_equity,
default_qty_value = 50,
initial_capital = 1000)
This get the type as percent of equity, which is 50% declared on qty_value

Related

Expo Calendar - Using the recurrenceRule for createEventAsync()

I'm struggling with some of the formatting for parameters inside the recurrenceRule when trying to create a new event with Expo Calendar. I can't seem to find any robust recurrence examples in the docs or anywhere else for that matter. One specific thing I'm struggling is daysOfTheWeek, where I'm trying to pass multiple days but I'm not even sure if you can.
Does anyone have a good working example of the recurrenceRule in action?
After struggling with this myself I found that if you look up types in your Calendar.d.ts file it should give you the required structure of the recurrenceRule.
export declare type RecurrenceRule = {
frequency: string
interval?: number // #default 1
endDate?: string | Date
occurrence?: number
daysOfTheWeek?: DaysOfTheWeek[]
daysOfTheMonth?: number[]
monthsOfTheYear?: MonthOfTheYear[]
weeksOfTheYear?: number[]
daysOfTheYear?: number[]
setPositions?: number[]
};
So if your use case is like mine and you just want the event to occur only once something like this will work: recurrenceRule: {frequency: 'DAILY', occurrence: 1} I think. Expo-documentation says recurrence rule can be set to null, but this throws an error. Hope this helps!

Using Prebid's price granularity high

We have our Price Granularity for Prebid set to high. However, since it's capped at $20, if we get a bid for $30 or $40 we're unable to accept it.
How can we stick with Price Granularity high with Prebid, but in instances we have a bid north of $20, automatically round down to $20 so that we can accept the bid.
Thank you..
According to Prebid documentation is should already be rounded down, but you can explicitly control it by adding the following code.
Assuming you're using the standard Prebid targeting keys
pbjs.bidderSettings.standard = {
adserverTargeting: [{
key: 'hb_bidder',
val: function val(bidResponse) {
return bidResponse.bidderCode;
}
}, {
key: 'hb_adid',
val: function val(bidResponse) {
return bidResponse.adId;
}
}, {
key: 'hb_pb',
val: function val(bidResponse) {
var cpm = bidResponse.cpm;
if (cpm > 20.00) {
return 20.00;
}
return (Math.floor(cpm * 100) / 100).toFixed(2);
}
}]
};
Add this after pbjs.addAdUnits( ad_units )
You’ll want to use the custom setting instead of using high to get what you want
See an example here: http://prebid.org/dev-docs/publisher-api-reference.html#customCPMObject
For the JSON youll want to redefine the same granularity settings for high in that JSON object and then add upon it to get additional granularity > $20.
Pro tips:
if you do not define values between $0-$x.xx that can act as a floor if you never want bids lower than x going to DFP
DFP caps the number of line items in an order at 450, so you may need an additional order(s) for your new granularity
always overlap the settings. Eg. Bucket 1 = $0-$3.00. Bucket 2 should start at $3.00-x (if you dont, a $3.009 bid wont be passed in to DFP

Vue.js root variable

I am working on my own directory for my purchases of cryptocurrencies.
I am getting prices of BTC, ETH, and LTC via API, then I created a component for each of my punched coin, so then I want to calculate current price (ownedCoins * currentPrice).
So in my $root I have { eth: 324.233, btc: 2211.43, ltc: 41.341 }
Here is where I want to calculate it:
self.eur = response.data.sum[0].quantity * this.$root.ltc;
But I want to make this dynamic, so what I want to do is to create a dynamic variable. Something like that: self.eur = response.data.sum[0].quantity * this.$root.{this.coinName};
How would I do that?
I would read the State Management part of the VueJS docs then checkout the Vuex docs. Once your data store get even mildly more complex your method of managing it with your sample code will become overwhelming.
Your question doesn't have anything to do with vue, but just plain javascript. To access object variables in javascript you have 2 ways, using the dot notation or bracket notation (I call it array notation):
const car = { wheels: 4, seats: 5, horsepower: 145 };
console.log(car.wheels);
console.log(car['wheels']); //same result
So
this.$root[this.coinName];
will give you the result you are looking for.

options for questions in Watson conversation api

I need to get the available options for a certain question in Watson conversation api?
For example I have a conversation app and in some cases Y need to give the users a list to select an option from it.
So I am searching for a way to get the available reply options for a certain question.
I can't answer to the NPM part, but you can get a list of the top 10 possible answers by setting alternate_intents to true. For example.
{
"context":{
"conversation_id":"cbbea7b5-6971-4437-99e0-a82927607079",
"system":{
"dialog_stack":["root"
],
"dialog_turn_counter":1,
"dialog_request_counter":1
}
},
"alternate_intents":true,
"input":{
"text":"Is it hot outside?"
}
}
This will return at most the top ten answers. If there is a limited number of intents it will only show them.
Part of your JSON response will have something like this:
"intents":[{
"intent":"temperature",
"confidence":0.9822100598134365
},
{
"intent":"conditions",
"confidence":0.017789940186563623
}
This won't get you the output text though from the node. So you will need to have your answer store elsewhere to cross reference.
Also be aware that just because it is in the list, doesn't mean it's a valid answer to give the end user. The confidence level needs to be taken into account.
The confidence level also does not work like a normal confidence. You need to determine your upper and lower bounds. I detail this briefly here.
Unlike earlier versions of WEA, the confidence is relative to the
number of intents you have. So the quickest way to find the lowest
confidence is to send a really ambiguous word.
These are the results I get for determining temperature or conditions.
treehouse = conditions / 0.5940327076534431
goldfish = conditions / 0.5940327076534431
music = conditions / 0.5940327076534431
See a pattern?🙂 So the low confidence level I will set at 0.6. Next
is to determine the higher confidence range. You can do this by mixing
intents within the same question text. It may take a few goes to get a
reasonable result.
These are results from trying this (C = Conditions, T = Temperature).
hot rain = T/0.7710267712183176, C/0.22897322878168241
windy desert = C/0.8597747113239446, T/0.14022528867605547
ice wind = C/0.5940327076534431, T/0.405967292346557
I purposely left out high confidence ones. In this I am going to go
with 0.8 as the high confidence level.

simplecart js setting column widths

I've used this site for assistance many times but never had to ask a question so finally joined...anyway, trying to set up simplecart checkout and having some trouble formatting cart output. I have my cart set to table and by default the simpleCart_items class displays the table and it's cells only as wide as they need be to fit the data. I can change this by specifying all cells(columns) as a percentage of the whole table. Unfortunately with 7 columns each only gets about 14% and this is way to much for a 1 or 2 digit quantity and not near big enough for all the characters in the item name without wrapping. What I want is a way to define a different width for each column. I have not found a way to do this even with colgroup but maybe just not doing it right. Any and all help would be appreciated!
Okay, so this may or may not help. This line is located in the simpleCart.js file. I changed it to something simple.
cartColumns : [
{ view: function(item, column){
return"<img src='"+item.get('image')+"' width='250px' height='250px'><br /><center><h3 ><span>"+item.get('name')+"</span></h3><p><a href='javascript:;' class='simpleCart_decrement'><button>-</button></a> "+item.get('quantity')+" <a href='javascript:;' class='simpleCart_increment'><button>+</button></a></p><p>$"+item.get('price')+"</p><p><a href='javascript:;' class='simpleCart_remove remove_icon'><img src='images/icon_x.png' /></a></p></center>";
},
}
],
You can change it to your own html
cartColumns : [
{ view: function(item, column){
return" YOUR HTML HERE ";
},
}
],
It MUST all be in ONE (1) LINE or else it may not work.
here are some values that are used
image = item.get('image')
name = item.get('name')
quantity = item.get('quantity')
price = item.get('price')
you can look at all the values here
http://simplecartjs.org/documentation/displaying_cart_data
but the point is that you can make a cart and display it how you want; with you own html and css. I hope this helped.