How can I code to find the highest since ma crossover

Viewed 26

How can I code to return the highest price since the Moving Average Crossover, and so do the lowest price since the moving average crossunder?

1 Answers

Use a var variable to keep track of the price. Reset this when there is a crossover or crossunder.

var float highest_high = na

if (sma_crossover)            // Check for crossover
    highest_high := high      // Reset your variable
else
    if (high > highest_high)
        highest_high := high  // Update the highest high
Related