Hold maximum Ordersize

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #89524 quote
    superborstigsuperborstig
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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.
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

Hold maximum Ordersize


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
7 years, 9 months ago.

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