My Strategy arguments:
strategy("Name ABC",
shorttitle="ABC",
overlay=true,
initial_capital=135,
currency=currency.USD,
default_qty_value=25,
margin_long=0,
default_qty_type= strategy.percent_of_equity,
commission_value=0.075)
And I am creating order on certain condition:
strategy.order("Buy", strategy.long, comment="Entry")
And on certain condition I close all order.
strategy.close("Buy", comment="Exit")
What I want:
- Each order quantity should be derived from 25 % of available equity.
What I am getting:
What's in image:
Multiple order
And all order has been closed on
2021-07-16 21:15
Suppose 1st Order
Available Equity 135
25% of equity is 135*25/100 = 33.75
Market Price On 1st order is 12.14
So Contracts = 33.75 / 12.14 = 2.78
So Contracts is 2 on 1st orderOn 2nd Order
Available Equity 135-33.75 = 101.25
25% of equity is 101.25*25/100 = 25.3125
Market Price On 1st order is 11.99
So Contracts = 25.3125 / 11.99 = 2.11
So Contracts is 2 on 2nd orderBut On 3rd Order
Available Equity 101.25-25.3125 = 75.9375
25% of equity is 75.9375*25/100 = 18.98
Market Price On 3rd order is 12.02
So Contracts = 18.98 / 12.02 = 1.57
So Contracts should be 1 on 3rd order
My Question:
- How this can be possible to create multiple order if you have only $135 and you are using 25% of equity on each order.
- Please guide me where I am wrong and what should be the right solution.
- And One last: In above image how exactly tradingview creating order.