Candle Index

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17109 quote
    MDS
    Participant
    Junior

    Hi All,

    I’m trying to develope a TS.

    The TS enter at market when 3 conditions are accomplished.

    I need to know ho to get the index of a bar, because when a condition occurs, the other maybe not and I’d like to define a window of validity.

    Anyway I want a condition is valid for N candles.

    I tried to get the barindex and store into a variable… but this values follows the evolution of barindex

    How to can I achieve that?

    Best Regards,

    Mauro

    #17113 quote
    GraHal
    Participant
    Master

    Hello MDS

    It would be useful / helpful to you if your current code is shown on here then we can see better what you are trying to do / need?

    Cheers

    GraHal

    #17118 quote
    MDS
    Participant
    Junior

    Thanks, if needed I’ll translate in english.  The conditions have to be valid for N candles

    once divergenzaLongCondizione = 0
    once divergenzaShortCondizione = 0
    once divergenzaConditionIndex = 0
    divergenzaSeniority = window*1.1
    
    
    
    if (pHigh[window] - Chikou)*pipfactor>soglia then
    
    divergenzaLongCondizione = 1
    divergenzaConditionIndex = divergenzaConditionIndex+1 // tried barindex before, but it's variable
    endif
    
    if (Chikou - pLow[window])*pipfactor>soglia then
    divergenzaShortCondizione = 1
    divergenzaConditionIndex = divergenzaConditionIndex+1
    endif
    
    
    if barindex-divergenzaConditionIndex > divergenzaSeniority then
    divergenzaLongCondizione = 0
    divergenzaShortCondizione = 0
    divergenzaConditionIndex = 0
    endif
    
    if divergenzaLongCondizione then
    
    endif
    
    CONDIZIONILONG= divergenzaLongCondizione
    CONDIZIONISTOPLONG=0 and spana <> spanb
    CONDIZIONISHORT= divergenzaShortCondizione
    CONDIZIONISTOPSHORT=0
    
    
    
    // Condizioni per entrare su posizioni long
    IF NOT LongOnMarket AND CONDIZIONILONG THEN
    BUY 1 CONTRACTS AT MARKET
    SET TARGET PPROFIT TP
    SET STOP pLOSS SL
    ENDIF
    
    // Condizioni per uscire da posizioni long
    If LongOnMarket AND CONDIZIONISTOPLONG THEN
    SELL AT MARKET
    ENDIF
    
    // Condizioni per entrare su posizioni short
    IF NOT ShortOnMarket AND CONDIZIONISHORT THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    SET TARGET PPROFIT TP
    SET STOP pLOSS SL
    ENDIF
    
    // Condizioni per uscire da posizioni short
    IF ShortOnMarket AND CONDIZIONISTOPSHORT THEN
    EXITSHORT AT MARKET
    ENDIF
    #17446 quote
    MDS
    Participant
    Junior

    Hi all.

    I resolved in this way.

    I wanted that a condition was valid for n candles.

    So.

    Once index=0

    Condition =0

    If condition then

    Index=index+1

    Endif

     

    Then there is a reset policy.

     

    Regards,

     

    Mauro

    #17672 quote
    GraHal
    Participant
    Master

    Hey great MDS, you duid it all by yourself! 🙂

    Often happnes to me that … I ask a question, it makes me think about it more and I come up with the solution anyway.

    Good Work
    GraHal

    #18232 quote
    MDS
    Participant
    Junior

    Thx a lot…

    Aniway it could be achived using barindex. It’s the very same.

    Regards

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

Candle Index


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
MDS @mds Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by MDS
9 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/24/2016
Status: Active
Attachments: No files
Logo Logo
Loading...