Trading times impossible to set

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #72248 quote
    Lorenzo47Lorenzo47
    Participant
    Average

    Hi everyone,

    I’m today facing a problem I can’t explain… In order to set trading times with ProBuilder, I usually use this code which works for me:

    // x is a value returned at the end
    
    MyCondition = Time < 090000 AND Time > 190000
     
    IF MyCondition THEN
     x = 0
    ENDIF

    Right here, I believe we’ll all agree, but in my code I can’t set these  “time preferences” (not before 090000 and not after 190000).  I can let it run during the night very easily (from 190000 to 090000), or if I set the values I want, then it seems to ignore them.. There’s a mistake somewhere and if anyone could help me it would be amazing!

    Here’s my code “not caring” about my time preferences :

    TradingTimes = 190000 < Time AND Time < 090000
    
    // Allowing trading
    IF VolatilityConditions THEN
    allows = 1
    ELSE
    allows = 0
    ENDIF
    
    // Long loop
    IF (x <> 0) AND (High < (x + 0.0012)) THEN
    y = 0
    ELSE
    x = 0
    ENDIF
    
    // Short loop
    IF (y <> 0) AND (Low > (y - 0.0012)) THEN
    x = 0
    ELSE
    y = 0
    ENDIF
    
    IF TradingTimes THEN
    x = 0
    y = 0
    ELSE
    IF allows THEN
    
    // Long opening
    c1 = (pSAR[1] > High[1])
    c2 = (High > pSAR[1])
    
    IF c1 AND c2 THEN
    x = pSAR[1]
    ENDIF
    
    // Short opening
    c3 = (pSAR[1] < Low[1])
    c4 = (Low < pSAR[1])
    
    IF c3 AND c4 THEN
    y = pSAR[1]
    ENDIF
    ENDIF
    ENDIF
    
    RETURN x, y

    PS : I’m trying to build a strategy with this code as indicator, that’s why it might seem totally useless so far but I can’t start backtesting to improve it before fixing this time issue… (it’s obviously messing up all the startegy).

    Thank you by advance for helping 🙂

    #72252 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    The first part of line 1 should read TIME > 190000.

    #72255 quote
    Lorenzo47Lorenzo47
    Participant
    Average

    Hi Roberto,

    Thank for your answer, it wouldn’t change anything. I don’t know why I wrote it like that in my post but in my code it’s written your way :

    TradingTimes = Time > 190000 AND Time < 090000

    Sorry for this mistake. I’ll be still waiting for your ideas 🙂

    #72257 quote
    JC_BywanJC_Bywan
    Moderator
    Master

    A variable can’t be simultaneously lower than 90000 and higher than 190000, even if in your mind it’s a continuous clock time ending at 240000 with continuity at 0, in the space of real numbers what your really want for night trading times is a subset made of 2 distinct intervals [0;090000] [190000;240000], so try replacing your “and” with “or”:

    TradingTimes = Time > 190000 OR Time < 090000
    Lorenzo47 thanked this post
    #72261 quote
    Lorenzo47Lorenzo47
    Participant
    Average

    Hello NoobyWan,

    Thank you so much! It works perfectly! I think I’ve been working on it for too long, and I couldn’t see anything anymore. Thank you so much once again.

    Btw, really nice username 😉

    JC_Bywan thanked this post
Viewing 5 posts - 1 through 5 (of 5 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

Trading times impossible to set


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Lorenzo47 @lorenzo47 Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Lorenzo47Lorenzo47
8 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/04/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...