Cumulate Orders

  • This topic has 14 replies, 3 voices, and was last updated 6 years ago by avatarquo.
Viewing 15 posts - 1 through 15 (of 15 total)
  • #25597
    quo

    Hi All, i have a system with this logic:

    1.-When conditions are set, buy 1000 eur.

    2.-Once in, if the close is lower than the previous buy, buy again 2000.

    3.-If the close is again below the second buy, buy 3000.

    4.-And if the close is below the third buy, buy 4000.

    No more than 4 buys is admited.

    I have coded this but everytime i try to put the third buy gives me an error.

    Any help?

    thanks

    #25598

    What is the error? No more cash? 🙂

    #25629
    quo

    Hi Nicolas, there is no error in the code. It is the way i use it, but i want to improve it with the changes stated before.

    I dont know how to limit operations to 4. Also i can´t find how to tell the system for the third buy: the close must be lower the second buy (not the first one).

    If you can tell me if this is discused before in the forum or the command i have to use i appreciated.

    thanks

     

    #25633

    I’m not sure it will work like the way you want, please make your tests to see how it goes..Thanks.

     

    #30590
    quo

    Hi Nicolas, i am afaid is not what i want. You gave me a clue and i have been trying to find out if there is a way to get what i want but unfortunatelly not.

    I give you the code again and i explain what happen:

    It works as i want but i have unlimited orders and i want a maximum of 4.

    Also it buys 1000 in the first order and 2000 in the rest and i want only four entries (1000 eur, 2000 eur, 3000 eur, 4000 eur)( i mean 4 entries if the price goes lower but a trade can be 1,2,3 or 4 buys)

    It is a kind of pyramiding buying more when you get lower prices.

    i have read this

    https://www.prorealcode.com/blog/trading/averaging-techniques-automated-trading/

    but i trade cash no contracts and i want to increase the cuantity every time i buy (limited to 4) and was no possible to adapt it.

    I also studied this advice

    https://www.prorealcode.com/reply/25833/

    but doesn´t work, maybe because this for intraday and in shares.

    I also reached this code. It increase the quantity as i want but it does it in the same day!!


    I dont want to use positionprice as you suggest, it is not important the midprice. Other thing: What happen with countofposition? if i skip it in the last code remains the same! can not be used with cash?

    thanks for your help

     

    #30591
    quo

    i am sorry i used “insert PRT code” but it did not work

     

    #30600

    Did you look at the documentation? This should make it clear what you need to change in your code:

    https://www.prorealcode.com/documentation/countofposition/

    #30610
    quo

    Thank you, its true, it is very clear but it seems countofposition works well with contract and shares buy not with cash.

    This code with shares works as i want

     

     

    but… as i trade stocks and they have different price i need to use cash.

    i have tried dividing cash into price in order to know the number of shares but does not work, (maybe because it takes different close price every time?)

     

    i almost got it. Any idea?

     

    #30622

     

    1 user thanked author for this post.
    avatar quo
    #30623

    *Comment should read ‘transactions’.

    And Insert PRT code is losing the indentation.

    #30626
    quo

    good idea. I though was the solution but unfortunatelly not. We have the same problem. It buys several times the same day. It does not understand it must wait until next lower close happen.

    thanks anyway.

    #30629

    What timeframe chart are you using?

    #30630
    quo

    I use end of date data.

    It depends of the system but in this case weekly and daily charts.

    #30645

    Ah ok I re-used your code without checking it thoroughly enough, when onmarket it needs to do only one purchase per bar so needs to use an elsif.

     

    1 user thanked author for this post.
    #30753
    quo

    Great!

    thank you so much

Viewing 15 posts - 1 through 15 (of 15 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login