【问题标题】:Inside Bar coloring as long as inside the range of mother bar Amibroker AFL内条着色只要在母条 Amibroker AFL 范围内
【发布时间】:2020-03-14 04:39:20
【问题描述】:

n= -1; Color = IIf((High < Ref(High,n) & Low > Ref(Low,n)), colorRed , colorWhite); Plot( Close, "Colored Price", Color, styleBar );

红色箭头指向条是母条,蓝色箭头指向白色条是母条范围内的内部条。 所以我正在尝试将当前栏与母栏进行比较,如果当前栏在母栏的范围内,则直接比较前一个栏,但如果代码条件为真但它不工作不知道为什么,我尝试添加递减 n 值。请参考图片以获得更好的清晰度

n= -1; Color = IIf((High < Ref(High,n) & Low > Ref(Low,n)), colorRed && n= n--, colorWhite); Plot( Close, "Colored Price", Color, styleBar );

【问题讨论】:

    标签: for-loop amibroker


    【解决方案1】:

    我发现写出 for 循环更容易

    function InsideBarColor() {
    
        local state;
        local isInsideBar;
        local index;
        
        local insideHigh;
        local insideLow;
        local priceColor;
        
        state = 0;
        isInsideBar = Inside();
        priceColor = colorDefault;
        
        for(index = 1; index < BarCount; index += 1) {
        
            if (state == 0 && isInsideBar[index] == True) {
            
                // Record the High/Low of the first inside bar.
                insideHigh = High[index-1];
                insideLow = Low[index-1];
                state = 1;
                priceColor[index] = colorRed;
            
            } else if(state == 1) {
            
                if (High[index] > insideHigh || Low[index] < insideLow) {
                    // Price broke out of range
                    priceColor[index] = colorWhite;
                    state = 0;
                } else {
                    // Price still inside range
                    priceColor[index] = colorBlue;
                }
            
            } else {
                priceColor[index] = priceColor[index -1]; 
            }
        
        }
        
        return priceColor;
    
    }
    
    colors = InsideBarColor();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-19
      • 1970-01-01
      • 1970-01-01
      • 2017-09-22
      • 2015-12-26
      相关资源
      最近更新 更多