TradingView
deimosaffair
Oct 9, 2016 9:16 PM

Understanding order sizes 

Ether / United States DollarCoinbase

描述

type: properties manipulation, no programming needed
time required: 15minutes, at least
level: medium (need to know contracts, trading pairs)

A strategy can "appear" to work or be broken depending on the pile of cash that is working on. This amount is defined in the strat properties, under "order size".

For noobs (like me) this is very confusing at first :)

A strat opens/closes positions using units, a generic measure for the chart being operated on. Thes "units" can be a fixed amount of cash, a fixed amount of contracts, or a floating amount based on the last profits made. I recommend checking my previous strat to figure the case of contracts .

So, any trading price is the amount of "things" you get for some "cash". The things are the first unit, the "cash" is the second. Some examples:
XAU/USD - 1 xau oz is worth x dollars
BTC/USD - 1 bitcoin is worth x dollars
GBP/EUR - 1 pound is worth x euros

To add to confusion, a lot of markets the "unit size" is different from what the strat thinks it is. An options contract is 100 shares(the unit), 1 xau contract is 10 oz(units), 1 eur/usd contract is 100k euros and so on... so, after figuring out how the sizes work in a strat, then the sizes must be adapted for the specific market in question.

The choice os using the ETHUSD pair is because:
1 - you can buy 1eth, unlike a gold contract for example, so 1 "unit" = 1 eth, easier to get
2 - ETH is around 12 bucks, wich gives round numbers on the math, easier to wrap the brains around :)
3- is an unusual pair, so the regular contract sizes don't apply, and the brain is not conditioned to work inside the box ;)

You will have to access the script properties, to change the values. As these values are changed you will see exactly the differences in the values of the strat.

Text is too long, check the comments for all the cases
评论
deimosaffair

FIRST CASE: contracts
Open the script properties popup. Set "initial capital" to 1000. In this case means 1000$, in this pair the dollar is the cash. If it was ETHCNY, it would mean 1000 yuan. Set pyramiding to 3. Set order size to 2 "contracts". This means the strat will open positions of 2 "units", which here means exactly 2 ETH. Again, this basic example is covered here
In short, the strat will always trade 2 units/contracts/ETH long or short forever. Simple :)

deimosaffair
this basic example is covered here = comments cannot have links, crap. use the link in the main description, please.
deimosaffair
THIRD CASE: % of equity
Here, set the order size to 10 "% of equity". The strat looks at the initial capital, in this case 1000$, and uses 10%, so 100. And trades positions doing the calculus for the units required for 100. In this case with ETH at 11.5, it would be 8. Pretty much the same as second case, but with a twist: when the position closes, the strat figures how much was won, and uses 10% of the new value. Suppose you made 200$ on the trade, the strat will now use 10% of 1200 = 120. And with ETH at 12, it can trade 10 "units", not just 8 as before. Same thing if the position is closed at loss. So, in this case, the little numbers under the arrows will not be the usual +2,+2,-2,-2, but more something like +11,+14,+14,-11,-9....
This is the strat adjusting the trade sizes to the earnings/losses. In the "strategy tester" tab -> "list of trades", you can follow all positions, and the numbers of the "contracts" column will start to make sense, hopefully :)

That's it. Keep playing with the values in a trading pair that you know well, and the sense of the values will show itself.
deimosaffair
SECOND CASE: CURRENCY
Set the "order size" to 20 "USD". The second option is USD because the strat "recognizes" USD as a coin. Again, if this was ETHBTC for example, the option would be "NONE", since the tradingView platform does not handle cryptos yet. But it makes no difference, the math works the same, it's just that you don't get to see the dollar or euro symbols.
This option means that the strat will try to open positions of X units that have the maximun value of 20USD. Since the value is around 11-12$, only one "unit" of ETH can be traded with 20 bucks. So, the little arrows in the chart will be +1,+1,-1,-1...
Now, increase the order to 25 USD, the strat will update all the moves, and you will see now +2,+2,-2,-2... With pyramiding=3, the strat is allowed to open up to 3 positions long, or short, and each position cannot pass the value of 25 dollars.
In this case, the strat will never trade more than 25 dollars on a position. Wich means that if ETH goes up from 25$, the strat stops working. It's not broken, you just ordered it not to move more than 25 bucks, and strats don't work with fractional units. If you by chance(or not) put a value that is "on the ege" of the unit value, say 12$ for an ETH unit, the strat sometimes can trade, sometimes not, and starts showing crazy behaviour :)

mmhogsett
I don't understand what contracts means exactly- mind helping explain or sending me some links to read?
pcoughlin
The code shown here is the same as your BarUpDn-time-limited code in another post ... is that what you intended or was there supposed to be other code on this example?
deimosaffair
@pcoughlin, Hi, the point is to have any strat to play with, and this one is as simple as it gets. actually, using the 25$ limit is a great example of the second case, since with eth around 200$ now, this strat is "broken".

so, i just used the same code because it's irrelevant. actually it's better for the tutorials, since you remove from the table unimportant details, such as code or strat "success", and focus on grokking each lesson.

if you want to play with a real strat, go here: tradingview.com/script/bqxhBRTn-cooltoyz-The-Turtle-Surfer/
更多