Making my first EA questons

 


I'm in the process of making my first EA. I have gotten most of it down even with my very limited programming experience but I still have a few questions.

1. I need a way to make an If condition trigger when price moves a certain amount of pips in one direction without moving at all in the opposite direction. In other words, if the certain amount was 2 and price where to move 1->2->3 then it would trigger but wouldn’t if price were to go 1->2->1->3. I need this to work for both up and down trends.

2. I need a different If condition to change depending on if my first questions uninterrupted trend is up or down.

Thanks to all who try to help.



 
Thank you very much. I knew I would have to use tick data already so your coding will work great.
 

For some reason the answer that was there is now gone. If the person who put it up (sorry I forgot your name) could put it up again that would be great or if somebody else knows how to do it could post it up would be great as well.

 
Act3297:

For some reason the answer that was there is now gone. If the person who put it up (sorry I forgot your name) could put it up again that would be great or if somebody else knows how to do it could post it up would be great as well.


Last time I used a loop. This time only if(). Compile this as EA and test on live chart.

extern int Continuous_Moves=3;
int Trigger,i=0;
double Old_Price, New_Price,Point2Pip;
string Str_Np, Str_Op;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~Init-Function:
int init(){
//~~~~~~~~~~
    Old_Price=NormalizeDouble((Ask+Bid)/2,5);
    New_Price=NormalizeDouble((Ask+Bid)/2,5);
    //~~~~~~~~~~Point2Pip:
    Point2Pip=Point;
    if(Digits==3){Point2Pip=0.01;}
    if(Digits==5){Point2Pip=0.0001;}
//~~~~~~~~~~
return(0);}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~Start-Function:
int start(){
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    New_Price=NormalizeDouble((Ask+Bid)/2,5);
    
    Str_Np=DoubleToStr(New_Price,5);
    Str_Op=DoubleToStr(Old_Price,5);
    
    if(MathAbs(i)<Continuous_Moves){
        if(Ask>Old_Price+1*Point2Pip){
            i++;Alert("I Moved Up One-Pip :) from "+Str_Op+" to "+Str_Np);}
        else{
            i--;Alert("I Moved Dn One-Pip :( from "+Str_Op+" to "+Str_Np);}
            
        Old_Price=New_Price;
        
        if(MathAbs(i)==Continuous_Moves){
            if(i>0){Trigger=1;}else{Trigger=-1;}
            i=0;
        }
    }
    
    if(Trigger==  1){Alert("Im Moving Up Fast :)");Trigger=0;}
    if(Trigger== -1){Alert("Im Moving Dn Fast :(");Trigger=0;}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
return(0);}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

Thanks!

Reason: