Buy x contracts if strategyprofit > y

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5880 quote
    Adolfo
    Participant
    Senior

    Hi everyone!

    I find a way to join the market with the exact risk that I wanna take in each trade, and wanted to share it with you.

    capitalinicial = 10000 //Capital
    riesgo = 0.07 // risk per operation
    
    REM Money management
    equity = capitalinicial+strategyprofit
    maxriesgo = round(equity*riesgo)
    
    REM Stop distance
    pipstop = //your stop variable or number
    
    REM Calculate contracts
    myLOT = abs(((maxriesgo/pipstop)/PointValue)*pipsize)

     

    MyLOT will be the number of contracts in next operation:

    if myconditions then
    buy myLOT contracts at market
    endif

     

    Seems that it’s working ok for me. Enjoy it!

    #5882 quote
    Nicolas
    Keymaster
    Master

    Thanks a lot Adolfo! Much appreciated to share this code snippet with the community. It makes me think that we could create some kind of “perfect” codes examples for usual needs like money management, grid orders, stop trailing, etc.. What do you think?

    #5897 quote
    Adolfo
    Participant
    Senior

    Exactly what i was looking for! I will contribute on this as much as i can!

    Cheers!

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

Buy x contracts if strategyprofit > y


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Adolfo @adolfo_onrubia Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Adolfo
9 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/24/2016
Status: Active
Attachments: No files
Logo Logo
Loading...