Intraday – Code to detect lack of bar

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #122951 quote
    Dunlop
    Participant
    New

    Good evening everyone,
    as in the attached screenshot (1 minute timeframe), I would like to insert in the code not to go in a long position if a price has not been formalized / there is no bar in the frames prior to the purchase (frames indicated in the red circle).
    How can the sw take over that there is no slash?

    Thanks a lot for those who want to give me a tip!

    scrrenshot-PB.jpg scrrenshot-PB.jpg
    #122953 quote
    Francesco
    Participant
    Veteran

    I don’t know if i well understood your question, but i try to make a guess.

    EntryOnlyIf1= close>close-1
    EntryOnlyIf2= close<close-1
    
    if yourconditions and EntryOnlyIf1 and EntryOnlyIf2
    then buy\sellshort n contracts at market
    endif
    
    #122960 quote
    robertogozzi
    Moderator
    Master

    Please do not double post.

    I will delete the other one.

    If markets are closed then no bar will appear. If they are open you can tell if there is a bar or not if close=open and there are no shadows. Open, High, Low and Close will all have the same price.

    #123321 quote
    Dunlop
    Participant
    New

    I would like that in case of lack of slash (candle), the sw did not go long. I tried to write the following code but nevertheless the sw continues to go long. Where am I wrong?

    In attachment I send the screenshot of the functioning of my code. Where there is the vertical red line, in that minute, there is no candle and therefore I would not want it to go long (as it does instead)

    Thank you very much!

    // Definition of code parameters
    MyRange = Range
    Dojistretta = (Open=Close)
    Assenzadicandela = (High = Low)
    
    REM Vai LONG se:
    // - se non c'è una doji ristretta o con range nullo nella posizione precedente all'acquisto
    // - non siamo oltre le 17.20
    // allora vai long
    IF NOT LONGONMARKET AND MyConditions AND NOT MyRange = 0 AND NOT DOjistretta AND NOT Assenzadicandela THEN
    BUY 1000 SHARES AT MARKET
    ENDIF
    screenshot-no-candle.jpg screenshot-no-candle.jpg
    #123332 quote
    robertogozzi
    Moderator
    Master

    As from your pic it seems there are no empty bars, just there are NO bars, so the entry bar (the red one) is simply the next one following the green bar.

    The attached pic shows empty bars (the one you want to skip) circled, while NO bars (which you cannot detect since they are NOT bars) in a rectangle. In your case your bars were like those in the rectangle, simply there was none!

    You should always let us know:

    • instrument traded (FX pair, Indices, stocks….)
    • TF used
    • date & time of involved candlesticks

    to be able to check and replicate your trades.

    x-7.jpg x-7.jpg
    #123336 quote
    Dunlop
    Participant
    New

    Exactly, that was what I was trying to explain to you.

    I don’t want to go long when there are no bars (rectangles in your image) in the previous minutes, is that possible?

    What does TS mean?

    #123341 quote
    robertogozzi
    Moderator
    Master

    TF  = Time Frame (1 minute, 4 hours, Daily, ec…).

    Indeed it does not enter on a NON-existing candle, it enters the next candle, as usual.

    If your conditions are met on the last candle on Friday,  a trade will be opened on Monday (or Sunday) when the markets re-open.

    #123364 quote
    Nicolas
    Keymaster
    Master

    Code is read at Close of your big green candle and order is launch at next bar Open. At Close of the green bar, there is no way to know what happen next, so the order is logically opened at next opening bar.

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

Intraday – Code to detect lack of bar


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Dunlop @dunlop Participant
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by Nicolas
5 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/22/2020
Status: Active
Attachments: 3 files
Logo Logo
Loading...