Negative parameter

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #138689 quote
    Johann
    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
    Vonasi
    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
    Johann
    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
    Vonasi
    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
    Johann
    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
    Johann
    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
    Johann
    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.

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 Johann
5 years, 7 months ago.

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