How to draw more than one Vline?

 

I need to to draw a vline in some points of my candle graph,but i'm having some problems...

I'm trying this:


if((Open[0]>Open[1] || Close[0]>Close[1] || Close[0]>Open[0]) && Volume[0] > Volume[1]){
b++;
if(!ObjectCreate("fundo",OBJ_VLINE,0,Time[0],Close[0])){
if(GetLastError() == 4200)
ObjectCreate("fundo["+b+"]",OBJ_VLINE,0,Time[0],Close[0]);
if(GetLastError()>0){
Print("Erro N°:"+GetLastError());
}else{
if(!ObjectSet("Fundo",OBJPROP_COLOR,Red))
Print("Ocorreu o erro"+GetLastError());
}
}


This script is executed each time the EA makes his loop, but it doesn't draw more than one line. Someone can explain me what's happening?

 
DanSoah:

I need to to draw a vline in some points of my candle graph,but i'm having some problems...

I'm trying this:


if((Open[0]>Open[1] || Close[0]>Close[1] || Close[0]>Open[0]) && Volume[0] > Volume[1]){
b++;
if(!ObjectCreate("fundo",OBJ_VLINE,0,Time[0],Close[0])){
if(GetLastError() == 4200)
ObjectCreate("fundo["+b+"]",OBJ_VLINE,0,Time[0],Close[0]);
if(GetLastError()>0){
Print("Erro N°:"+GetLastError());
}else{
if(!ObjectSet("Fundo",OBJPROP_COLOR,Red))
Print("Ocorreu o erro"+GetLastError());
}
}


This script is executed each time the EA makes his loop, but it doesn't draw more than one line. Someone can explain me what's happening?


ObjectFind() ... and you are shure about error 4200 ?

i use this function for hline, work without problem

void DrawHLine(string LineName,double LinePrice,color LineColor,int LineStyle)
{
if(ObjectFind(LineName)==-1)
{
    ObjectCreate(LineName,OBJ_HLINE,0,Time[0],LinePrice);
    ObjectSet(LineName,OBJPROP_COLOR,LineColor);
    ObjectSet(LineName,OBJPROP_STYLE,LineStyle);
    ObjectSet(LineName,OBJPROP_WIDTH,1);
}

    ObjectSet(LineName,OBJPROP_PRICE1,LinePrice);
}


DrawHLine("Hline",Close[0],Orange,STYLE_SOLID);
 

First of all GetLAstError immediately resets last error to 0, so your code would tell you that you have an error, then inform you that the error is 0. Save the error to a variable, then make as many calls to it as you want.

Secondly I don't see a for loop here. Is "b" a global variable and incremented by EA ticks? Are you sure you really increment it every cycle, or does your code make it go 0-> 1, 0->1 all the time?

So much for now :)

 

can someone help me edit sar ohlc to use heiken ashi ohlc

Hi, I have an MTF indicator that uses sar, however I'd like the sar to calculate heiken ashi ohlc, and not the normal type

Can you tell me how I can do this, my mtf indicator calls to the sar indicator to calculate sar formula, I think it is calling to the internal indicator in mt4 that can not edit

you can skype or email if you can assist and like to talk about it

skype sty671

email sty671@gmail.com

I can also supply the original file that I'm trying to use heiken ashi ohlc for

 

EADeveloper:


Thanks! this function helped me a lot. and yes, i was sure about error 4200.


forexCoder:


Yeah, it increments every cycle, and "b" is a global variable that another function changes the "b" value

 
EADeveloper:


ObjectFind() ... and you are shure about error 4200 ?

i use this function for hline, work without problem

void HLine(string name, double P0, color clr){          #define WINDOW_MAIN 0
    if (!Show.Objects)  return;
    /**/ if (ObjectMove( name, 0, Time[0], P0 )){}
    else if(!ObjectCreate( name, OBJ_HLINE, WINDOW_MAIN, Time[0], P0 ))
        Alert("ObjectCreate(",name,",HLINE) failed: ", GetLastError() );
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [1] failed: ", GetLastError() );
    if (!ObjectSetText(name, PriceToStr(P0), 10))
        Alert("ObjectSetText(",name,") [1] failed: ", GetLastError());
}
void TLine( string name, datetime T0, double P0, datetime T1, double P1
          , color clr, bool ray=false ){
    if (!Show.Objects)  return;
    /**/ if(ObjectMove( name, 0, T0, P0 ))      ObjectMove(name, 1, T1, P1);
    else if(!ObjectCreate( name, OBJ_TREND, WINDOW_MAIN, T0, P0, T1, P1 ))
        Alert("ObjectCreate(",name,",TREND) failed: ", GetLastError() );
    else if (!ObjectSet( name, OBJPROP_RAY, ray ))
        Alert("ObjectSet(", name, ",Ray) failed: ", GetLastError());
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [2] failed: ", GetLastError());
    string  P0t = PriceToStr(P0);           if (MathAbs(P0 - P1) >= Point)
            P0t = StringConcatenate(P0t, " to ", PriceToStr(P1));
    if (!ObjectSetText(name, P0t, 10))
        Alert("ObjectSetText(",name,") [2] failed: ", GetLastError());
}
string  PriceToStr(double p){ return(DoubleToStr(p, Digits)); }
int init(){     
    if (IsTesting() && !IsVisualMode()){    Show.Comments   = false;
                                            Show.Objects    = false;    }