Strategy.entry quantity (fixed or percent)

Viewed 1186

I have this strategy in tradingview:

strategy("NAME", "SHORT_NAME", overlay=true, default_qty_type=strategy.percent_of_equity, initial_capital=100, default_qty_value=20, precision=4, currency = currency.USD, pyramiding =5, commission_value = 0.075)

I've tryed different options with different results:

if (buy)
    strategy.entry(id="BUY", long=true)

It works but ignores the default_qty_value and uses all the capital configures in the bot.

if (buy)
    strategy.entry(id="BUY", long=true, qty = 20)

Doesn't give any errors in Pine Script but the bot (from Quadency) don't receive the alert

if (buy)
    strategy.entry("BUY", strategy.long, 10)

This is how is written in the Quadency tutorial. Does not work and Pine script give syntax errors

I want the bot to place an order of the 20% of the initial_capital so I can run it with pyramiding 5 orders at a time.

How should I write the strategy.entry?

1 Answers

This code

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © adolgov

//@version=4
strategy("My Strategy", overlay=true, initial_capital=100, currency = currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=20)

longCondition = crossover(sma(close, 14), sma(close, 28))
if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)

shortCondition = crossunder(sma(close, 14), sma(close, 28))
if (shortCondition)
    strategy.entry("My Short Entry Id", strategy.short)

Gives next results: enter image description here

Related