alarm possible when any horizontal line is touched?

 

hi coders,

for my trading i mainly use pivot points and support/resist. the pivots are made by an indicator and the support/resist lines are drawn by myself. i only want to look at the charts when price approaches or touches ANY horizontal line. is it possible to program that? or is it necessary that the indicator must "know" the names of the horizontal lines?

unfortunately i am not a coder but maybe some has this kind of indicator?

thanks for all help!!

 
  1. If you want to trigger on specific lines, it must know the name of the line or the pattern of the name.
  2. If you want to trigger on all horizontal lines, easy
    int start(){
        static datetime Time0;
        if (Time0 == Time[0]) return;   // One alert per bar.
        double H = High[0], L = Low[0];
        for(int iObj = ObjectsTotal() - 1; iObj >= 0; iObj--){
            string name = ObjectName(iObj);
            if (ObjectType(name) != OBJ_HLINE)  continue;
            double line = ObjectGet(name, OBJPROP_PRICE1);
            if (H >= line && line >= L){
                Alert("Price has touched ", name);
                Time0 = Time[0];        // No more alerts.
            }
        }
    }
  3. unfortunately i am not a coder
    No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
 

thank you soooo much!!! that helps me a lot!!!!!

just one question: i see that this indicator gives an alert on each horizontal line i draw myself. but i also use the allpivots-indicator. when prices touches these pivot-lines there is no alert. is it because the names are not like "horizontal line xxx" ? does your indicator only recognized lines i draw myself?

thanks again for that great work!!!!!!

ps. i am trying to learn to code and it's also ok for me to pay for the work.

 
mar:
just one question: i see that this indicator gives an alert on each horizontal line i draw myself. but i also use the allpivots-indicator. when prices touches these pivot-lines there is no alert. is it because the names are not like "horizontal line xxx" ?
  1. Do you really expect me to know exactly what indicator you're talking about by just saying "alllpivots-indicator"?
  2. If it's some variation of ZMFX all pivot levels - MQL4 Code Base, that indicator is NOT creating horizontal lines. It creates trend lines. Horizontal lines go ALL the way accross the chart. Trendlines can be shorter and not necessary horizontal.

  3. int start(){
        static datetime Time0;
        if (Time0 == Time[0]) return;   // One alert per bar.
        double H = High[0], L = Low[0];
        for(int iObj = ObjectsTotal() - 1; iObj >= 0; iObj--){
            string name = ObjectName(iObj);
            if (ObjectType(name) == OBJ_HLINE){
                double line = ObjectGet(name, OBJPROP_PRICE1);
            }
            else if (ObjectType(name) == OBJ_TREND){
                if (ObjectGet(name, OBJPROP_TIME1) >= Time[0])
                    line = ObjectGet(name, OBJPROP_PRICE1);
                else if (ObjectGet(name, OBJPROP_TIME2) >= Time[0])
                    line = ObjectGet(name, OBJPROP_PRICE2);
                else    continue;   // Line stops before current candle
            }
            else    continue;   // Not HLINE or TREND
            if (H >= line && line >= L){
                Alert("Price has touched ", name);
                Time0 = Time[0];        // No more alerts.
            }
        }
    }




 

of course i didn't know if you know that specific indicator. but my main question was if the horizontal lines have to be named like "horizontal line xxx" because the indicator uses different names like "pivot", "r1" etc.

but i replaced your former code by this new code and it works more than perfect!!!! this new indicator detects also the lines drawn by that pivot-indicator. my problem is solved 100%. thank you very much for your great work... that makes trading much easier for me!

Reason: