How to sell same contract size when calculated from account equity

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #170823 quote
    novembrepleut
    Participant
    New

    Hi

     

    I was wondering if i could get some help

     

    i use variable position sizes based on the amount of money i have in my account.

     

    the thing is i have noticed that when i look to sell this amount, it changes, mostly because of the change in price when its calculated.

    startingcapital = 100
    cp=strategyprofit
    
    contractsize=(startingcapital+cp)/high
    
    if buyingcondition then
    buy contractsize on market
    end if
    
    if sellingcondition then
    sell contractsize on market
    endif

     

    This means i always have a little bit of left over in the market and I recently noticed, it affects the efficiency of my systems.

     

    is there anyway i can create an array which remembers the value of the contract size use in a trade.

     

    this is especially helpful when there are cumulative orders on the way.

     

    i wanted to try some loops with trade price then realised that trade price could also consider sells, which is not what i want, i want to arrays to purely pick up the number of contracts of each previous trade.

     

    If  the system will always close out the oldest code, then this shouldn’t be an issue to work out.

     

    any help would be greatly appreciated.

    #171297 quote
    Vonasi
    Moderator
    Master

    novembrepleut – Welcome to the forums. Please re-read the forum rules before posting again. Your topic has been moved to the correct place for strategy related questions.

    The following will just close everything that you have open:

    startingcapital = 100
    cp=strategyprofit
    
    contractsize=(startingcapital+cp)/high
    
    if buyingcondition then
    buy contractsize at market
    end if
    
    if sellingcondition then
    sell at market
    endif
    #171298 quote
    Vonasi
    Moderator
    Master

    If you want to store position sizes in an array then simply do this:

    startingcapital = 100
    cp=strategyprofit
    
    contractsize=(startingcapital+cp)/high
    
    if buyingcondition then
    buy contractsize at market
    a = a + 1
    $myposition[a] = contractsize
    endif
    

    ‘a’ will always be the latest position opened and ‘a’ minus 1 the previous and ‘a’ minus 2 the one before that and so on.

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

How to sell same contract size when calculated from account equity


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 1 voice, and was last updated by Vonasi
4 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/30/2021
Status: Active
Attachments: No files
Logo Logo
Loading...