barindex trouble

Viewing 15 posts - 1 through 15 (of 17 total)
  • #54821

    Im not understanding the barindex command. What am i doing wrong here?

    Just want to learn to i figured i would buy if:

    Close > moving average 10

    +

    Close > highest high past 20 candles

     

     

    #54824

    What do you want to achieve with this “barindex if-loop”? Take it away otherwise you won’t get any trades.

    #54827

    Lines 11-12 assign boolean values (0-1) to variables, then at lines 13 and 15 you compare them with prices. That would yield really odd trades, if any (see what Despair said)!

    Anyway BARINDEX is zero when you first launch your strategy, then it is incremented by 1 at each new bar/candlestick.

    Roberto

     

    #54848

    What do you want to achieve with this “barindex if-loop”? Take it away otherwise you won’t get any trades.

    Lol, i tried to look at what other systems where doing, i have no clue man!

     

    If im asking for “high[7]” (or “highest[20]”?) will it check for the highest point in the last 7 candles, or only the high from the 7th candle? 

     

    Sorry for being such a noob

    #54861

    It will check for the highest value of the last 7 or 20 candles. Sounds like you should read the manual. 😉 

    #54870

    Sounds like you should read the manual. 😉

    yea that was my last chance, figured id ask here first though. Not everything in that manual is written for newbs like me 😀 (meaning i dont always understand what it says in the manual 😛  ) 

    #54888
    Leo

    if barindex = 0 then ?????

    So your code is only working at the first candle… after that your code is not doing anything

    I learn to code just by reading the Manuals since the firs page and practizing chapter by chapter… so Keep Calm and Keep reading!

     

    #54893

     If ther’s room for some more questions here: 

    if intradaybarindex=0 then
    trading=1

    What exactly does that mean? I dont understand the barindex command at all.

     
    In general the “If barindex = 0 then…” command, what does it mean? i dont get why so many people use it. Would love to understand 🙂

    how would you rewrite my code in post 1, to make it actually trade if the close[0] > highest high in past 20 candles?

    #54897

    BARINDEX is the number of bars elapsed since your strategy has been launched.

    TRADEINDEX is the number of bars elapsed since your trade was opened.

    INTRADAYBARINDEX is the number of intraday bars elapsed since the beginning of the day and is reset daily to zero.

    To reset some variables at the beginning of each day you may want to write:

    To check how many bars have elapsed since your trade was opend you may write:

    I also suggest that you use the search box to find all occurrences of keywords you don’t feel at ease with. You’ll find documentation and plenty of examples to study.

    #54929

    TRADEINDEX is the number of bars elapsed since your trade was opened.

    Sorry robertogozzi but I think you got this bit wrong?

    An Index is an Index! Everything is given a number so that you can find it again. The first bar on a chart is 1, the second bar is 2 and so on. If you want to use information from the 29th bar then look at Barindex[29]. TradeIndex is the number of the bar on the chart when the last trade was opened. So it could be Barindex 29 and Trade Index 25 which means that you have 29 bars on the chart and opened a trade on the 25th bar. So BarIndex – TradeIndex  = 4… so you opened the last trade four bars ago..

    #54932

    Sorry Vonasi, you are absolutely right! I wrote the wrong explanation using a correc example.

    #54973
    Leo

    I think the barindex=1 is the first data loaded since we use DEFPARAM preloadbars=1000

    then the first BARINDEX when your System was activated is 1001.

    Anyway…

    I use a lot BARINDEX in my codes because I use it to Figur out symmetries, triangles, etc.

     

     

    #54974
    Leo

    if intradaybarindex=0 then trading=1 What exactly does that mean? I dont understand the barindex command at all.

    BARINDEX and INTRADAYBARINDEX are different, in your example as robertogozzi says is for reseting variables

    but in your code you have use: totally different

    // Conditions to enter long positions

    if barindex = 0 then

    buy1 = highest[20](close)

     

    #54975

    Sorry for my incorrect example, it should read:

    #54976
    Leo

    i dont get why so many people use it

    Then simple: do not use it until !!! you copy things to your code without knowing… that dangerous.

    have look, test it and tell us your results:

     

     

     

     

     

Viewing 15 posts - 1 through 15 (of 17 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login