Hold maximum Ordersize

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #89524 quote
    superborstig
    Participant
    Junior

    Hallo Forum,

    I need your help.

    I want to programm the following code below, but if I reached for example an Ordersize of 3,  I want to hold the Ordersize until the strategyprofit is >0 or  the loss is higher and I have to increase the Ordersize. If the strategyprofit reduce I want to hold the maximum reached Ordersize until the strategyprofit is > 0.

    I hope you can help me.

     

    If strategyprofit >= 0 Then

    OrderSize = 1

    Elsif strategyprofit <= -200 Then

    OrderSize = 5

    Elsif strategyprofit <= -150 Then

    OrderSize = 4

    Elsif strategyprofit <= -100 Then

    OrderSize = 3

    Elsif strategyprofit <= -50 Then

    OrderSize = 2

    Endif

    #89549 quote
    robertogozzi
    Moderator
    Master

    Try this (not tested):

    If OrderSize = 3 Then
       If strategyprofit >= 0 Then
          OrderSize = 1
       Endif
    Else
       If strategyprofit >= 0 Then
          OrderSize = 1
       Elsif strategyprofit <= -200 Then
          OrderSize = 5
       Elsif strategyprofit <= -150 Then
          OrderSize = 4
       Elsif strategyprofit <= -100 Then
          OrderSize = 3
       Elsif strategyprofit <= -50 Then
          OrderSize = 2
    Endif

    But your, and mine, code will never reach OrderSize = 2.

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

Hold maximum Ordersize


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
7 years, 1 month ago.

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