Arrays, and previous arrays

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #173018 quote
    robert123
    Participant
    Master

    Hi,

    If I used an array to log the bar index and price of a pair of MAs if they were to cross, is it possible to use the array function to find the price of the previous crossing, if so, how would I write it?

    TIA

    RR

    #173019 quote
    robertogozzi
    Moderator
    Master

    Arrays are not historicized, so you cannot see the value retained the previous bar for element, say 5, of the array:

    a = $MyArray[5][1]  //not allowed
    x = $MyArray[5]
    a = x[1]            //allowed, but you need a variable for each element of the array

    You need to store each crossover in an array element:

    Once Count = 0
    If close CROSSES OVER average[20] then
        Count = Count + 1
        $CrossBar[Count] = barindex
    Endif

    Count will retain the number of crossovers and each $CrossBar[] element will retain the barindex of the crossover. You

    #173050 quote
    robert123
    Participant
    Master

    Thank you very much, Roberto.

    RR

    #173052 quote
    robertogozzi
    Moderator
    Master

    Sorry for the final YOU, I had nothing more to write.

    I must have have pressed some unwanted dictionary word on my mobile 🙂

    #173102 quote
    Vonasi
    Moderator
    Master

    If you only want to know the price and barindex of the last crossing then you don’t need to use array variables. However if you want to store the price or barindex of all historical crosses then you do need to use array variables.

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

Arrays, and previous arrays


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
robert123 @robert123 Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/02/2021
Status: Active
Attachments: No files
Logo Logo
Loading...