Variable for purchasing power?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #189994 quote
    Nassim
    Participant
    New

    I would like to create a variable that shows the available cash on hand for purchasing shares. Meaning, if the initial capital is $100 then that variable should be equal to 100. If $50 worth of shares are purchased with a trade commission of $2 then this variable should become 48.

    I am trying to create a “counter” variable like this: v = v – positionprice * countofposition – 2 within the BUY if-loop but it’s not working. The idea is to use this variable to create a condition for buying (long positions) whereby if there is not enough cash on hand to buy to not buy. Otherwise the code is selling at market price to avail cash for executing buys. This is driving me nuts…

    #189996 quote
    JS
    Participant
    Senior

    Hi @Nassim

    Something like this…

    Equity = StartCapital + StrategyProfit

    PositionSize = Equity / Close  (Close of share)

    If PositionSize > 1 then
    Buy PositionSize Contracts at Market
    Else
    Sell at Market
    EndIf

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Variable for purchasing power?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Nassim @nassim Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by JS
3 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/15/2022
Status: Active
Attachments: No files
Logo Logo
Loading...