Why does the code not provide a signal?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #39783 quote
    EB
    Participant
    Senior

    Hi,

    I a struggling with the fact that the stochastic does not always give a signal. I don’t understand why. Here is the simple code:

    atr2 = averagetruerange[14]
    
    IF NOT ONMARKET THEN
    
    c2 = Stochastic[5,3](close[1]) < 20
    
    IF (c2) THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP LOSS atr2*5.5
    SET TARGET PROFIT atr2*2.5
    
    ENDIF
    
    ENDIF
    
    signal = c2
    
    graph signal

    It says buy when the stochastic is below 20. The thing is that sometimes it provides this signal, but sometimes not. I don’t know why. See attachment. I should expect that at 10.35 hrs, 14.20 hrs and 16.45 hrs it would provide a buy signal.

    Can anybody tell me why this is not the case?

    Thank you,

    Edward

    #39785 quote
    Nicolas
    Keymaster
    Master

    Your attachment is empty. If you want to add picture, just upload them in any supported format such as .png .jpg, etc..

    The problem in your code is that your are only storing value of the stochastic condition into your c2 variable when you are not on market. You should test your condition outside the “onmarket” conditional block.

    #39794 quote
    EB
    Participant
    Senior

    Hi Nicolas,

    Thank you for your quick reply. Ok, so I should not use the onmarket conditional block. That indeed seems to be the issue here. And use DEFPARAM Cumulateorders = False.

    Edward

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

Why does the code not provide a signal?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
EB @eb Participant
Summary

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

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