Specification
Objective : to level the quantity required to compensate for the loss of previous trades evenly
initialqty=iqty=10;
profittarget=pt=.1;
stoploss==sl.1;
brokerage=.01;
profitmargin=pt-brokerage;
lossmargin=sl+brokerage;
lotsize=1000;
if trade hits stoploss
loss count should be incremented
loss should be calcualted and added to previous total loss to get the new total loss
find out the total qty required to compensate for loss.
then devide this by loss count.
totalloss=last value(loss)+(last value(qty)*lot size * loss margin)
newqty = iqty+(total loss/(profit margin*10000*loss count))
qty=newqty; this qty should be same until the loss count value becomes zero
if trade is open till 14:45
consider selling or covering the trade with the close value of last candle or open value the running candle
loss should be calcualted and added to previous total loss to get the new total loss
find out the total qty required to compensate for loss.
then devide this by loss count.
(here we are not changing the loss or profit count)
if trade hits profit while loss count >0
loss count should be decremented by 1 until loss count is equal to zero
profit count should be incremented by 1
total loss = lastvalue(total loss) - profit of the last trade
if loss count increases before reaching zero, recalculate the total loss and the new qty to compnesate.
total loss = lastvalue(total loss) - loss of the last trade
new qty = iqty+(total loss/(profit margin*10000*loss count))
when loss count reaches zero
reset below variables
total loss = 0
profit count =0
qty = iqty
profit count should be zero even if a trade hits profit unless loss count > 0