Orders size problem with fixed straetegyprofitwinnings, pls give a hand

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #138655 quote
    JohnScherJohnScher
    Participant
    Veteran

    I would like to arrange the following

    With an initial capital of 100%, the 1.Trade should make 1% profit to 101% of the initial capital.
    If the first trade is negative, the 2nd trade should make a profit of 101% of the initial capital
    If the second trade goes into the red, the 3rd trade should make a profit of 101% of the initial capital.
    and so on to
    until is 101% achieved.
    Then it starts all over again, with a target of 102% of the starting capital.

    From what I can see, it’s a ordersize problem.
    How do I program it best?

    #138671 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Try this one (I tested it just for syntax errors):

    DEFPARAM CumulateOrders = false
    ONCE BasePerCent = 101     //101% initial target
    ONCE MyCapital   = 10000   //initial capital
    ONCE MinLot      = 1       //Minimum lot size
    ONCE LotSize     = MinLot  //initially set to Minimun Lot Size (it will increase later)
    IF Not OnMarket THEN
       MyEquity = MyCapital + STRATEGYPROFIT
       IF MyEquity > MyCapital THEN
          IF MyEquity >= (MyCapital * BasePerCent / 100) THEN
             BasePerCent = BasePerCent + 1
             LotSize     = MinLot
          ENDIF
       ELSIF MyEquity < MyEquity[1] THEN
          Difference =  MyEquity[1] / MyEquity
          IF MyEquity < MyCapital THEN
             LotSize = Lotsize * Difference
          ENDIF
       ENDIF
    ELSE
       IF (PositionPerf * 100) >= 1 THEN      //when 1% is reached while at market, add 1% to the initial target
          BasePerCent = BasePerCent + 1
       ENDIF
    ENDIF
    IF close CROSSES OVER  average[200] then
       buy LotSize Contracts AT Market
    ENDIF
    IF close CROSSES UNDER average[200] then
       sellshort LotSize Contracts AT Market
    ENDIF
    set target pprofit 300
    set stop   ploss   100
    //
    //graph StrategyProfit
    //graph MyEquity
    //graph Difference
    //graph LotSize
    //graph BasePerCent
    #138676 quote
    VonasiVonasi
    Moderator
    Master

    JohnScher – Topic moved to ProOrder forum as it is a strategy question and not a general discussion. Please try to follow the forum rules and post in the correct place with future posts.

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Orders size problem with fixed straetegyprofitwinnings, pls give a hand


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
JohnScher @johnscher Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by VonasiVonasi
6 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/07/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...