Being a beginner, I'm still confused; too many questions, to many options, it's a labyrinth for me yet, sorry for perhaps blunt questions…
Here's the header:
strategy(title="Testing Strategy Testing", initial_capital = 100000, default_qty_type = strategy.percent_of_equity, default_qty_value = 1, pyramiding = 20, currency = 'USD', overlay=true)
And here's the strategy entry code part (it could be a long-type one):
if ShortItPlease and in_date_range and enable_short_strategy == true
strategy.entry("ShortItPlease", strategy.short, qty=1, when=ShortItPlease, alert_message="Open Short Position")
strategy.exit( "ShortItPlease", qty=1, from_entry="Short", loss=short_stoploss_percentage, profit=short_takeprofit_percentage, alert_message="Your Short SL/TP Limit As Been Triggered.")
strategy.close("ShortItPlease", when=when_specified, alert_message="Close Short Position")
So as you may see, default_qty_type = strategy.percent_of_equity
is specified in the header, so is the default_qty_value = 1
but
- in the
strategy.entry()
orstrategy.exit()
function (above), it seems we can only specifyquantity
, independently from thedefault_qty_value
variable (if I don't specifyqty
then it results an error message), - and there's not even such variables as
default_qty_type
ordefault_qty_value
, to re-use. These are not variables to be used in calculations, for example.
What to do different, to make these parameters affect the strategy's behavior? Perhaps I should use the following variables in the entry functions, adjusted properly? Goal is: set PT/SL based on percentage, order qty based on account balance percentage.
long_stoploss_price = strategy.position_avg_price * (1 - long_stoploss_value/100)
long_takeprofit_price = strategy.position_avg_price * (1 + long_takeprofit_value/100)
short_stoploss_price = strategy.position_avg_price * (1 + short_stoploss_value/100)
short_takeprofit_price = strategy.position_avg_price * (1 - short_takeprofit_value/100)