Pine Script Strategy Algo Update

Job ID: 38176465

Budget: $10 – $30 USD

I need the current Tradingview strategy to be updated to do the following:

1)Begin with a single contract for the initial trade.
2)Adjust Contracts Based on Trade Outcome:
3)After a winning trade, increase the number of contracts by 1, up to a maximum of 5 contracts.
4)After a losing trade, reset to 1 contract.

Examples:

Example 1 (Winning Trade, Initial Contract):
Initial Contracts: 1
Total Profit: $20.16

New Contracts for Next Trade: 2 (since it's a winning trade)

(Winning Trade, Increased Contracts):
Contracts: 2
Profit: $40.16

New Contracts for Next Trade: 3 (since it's a winning trade)

Example 3 (Losing Trade, Reset Contracts):
Contracts: 3
Loss per Contract: -$136.56

Example 4(Contracts reset to 1 Because its a Losing Trade)
Contracts: 1

Keep repeating -

If we had 5 winners in a row then reset to 1 contract
If we have a losing trade then reset to 1
If we have a winning trade we increase next trade by 1 contract up until 5 contracts then we reset
Related categories: Python Algorithm Metatrader Pine Script