Negative parameter

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #138689 quote
    JohannJohann
    Participant
    Average

    Hi Support Team

    Hope you can help. I have a code which from time to time have a negative value which stop my strategy in Pro Order.

    The one code is:

    indicator1=(close-average[10](close))
    indicator2=(average[10](close-average[10](close))
    c1=(indicator1>indicator2)
    c2=(indicator1<indicator2)

     

    The problem is when the close/price is below the average then the indicator1 returns a negative value which also means indicator2 will be negative, crossing the zero line. I use it as a bearish or bullish indicator the same as a using close>average[10](close) as bullish.
    What can I do for the builder to accept the > or < even if the are negative for example if:
    indicator1 = -5 and indicator2 = -10 then c1 remains true even if the values are negative without pro order stopping the strategy?

    The second code is:

    indicator1=volume
    indicator2=(high-low)
    c1=(indicator1/indicator2)

     

    So when the volume = 0 then Pro Order stops. So what I did is:

    If indicator1 < 1 Then
    indicator1 = 1
    Else
    indicator1 = volume
    endif

     

    So that the calculation continues even when volume = 0. This do not seem to work. Works fine in backtest and demo but not live. Hope you can help?

    #138691 quote
    VonasiVonasi
    Moderator
    Master

    Johann – Please re-read the forum rules before posting again and always use the ‘Insert PRT Code’ button when ever you are putting any code in your posts. I have tidied up your post for you – we like a tidy forum! 🙂

    #138692 quote
    JohannJohann
    Participant
    Average

    Hi Vonasi

    Apologies did not even know how to use the insert function, but i will find out and use it in future. Thank you. Also do you have a potential solution to my problem?

    #138693 quote
    VonasiVonasi
    Moderator
    Master

    My suggestion would be to only allow the code to run if volume <> 0

    if volume <> 0 then
    //your entry conditions and orders here
    endif
    #138702 quote
    JohannJohann
    Participant
    Average

    Thank you Vonasi will try, and any suggestion on the the first code, I try to do the insert code but it does not look the same as yours, sorry!

    indicator1=(close-average[10](close))
    indicator2=(average[10](close-average[10](close))
    c1=(indicator1>indicator2)
    c2=(indicator1<indicator2)
    #138707 quote
    JohannJohann
    Participant
    Average

    I presume that when the close is below the average[10] or when it crosses over, the value returned is either zero or a negative value which is probably why it stops?

    #138709 quote
    JohannJohann
    Participant
    Average

    Hi Vonasi, just realized I could try the same suggestion you gave:

    If indicator <> 0 Then
Viewing 7 posts - 1 through 7 (of 7 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

Negative parameter


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Johann @johann Participant
Summary

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

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