Work in Progress

 

Hi Guys

I have an EA i have been building over a few months

but i have come to a halt on a part of it

so I am looking for some help please


if you go to the function marked check signal you will see i am using the int iRetVal to give me signals

however it no longer give me anything but a 0


if you run the EA you will see it prints to screen the hig the low and "fibuy" and Fibsell"


i am trying to write code that will either make a signal to buy or sell when the price comes in between these two points

any help or guidance would be,most appreciated

i have spent many hours trying to get something usefull



// this is the code that geneates a signal to trade or not
int CheckSignal(){
int iRetVal = 0;
double Fib1_1 = iHigh(NULL,PERIOD_W1,1);
Print ("last-high-W1",Fib1_1);
double FibHiLast = iHigh(NULL,PERIOD_H4,1);
Print ("last-high-H4",FibHiLast);
double Fib1_2 = iLow(NULL,PERIOD_W1,1);
Print ("last-LOW-W1",Fib1_2);
double FibLast = iLow (NULL,PERIOD_H4,1);
Print ("last-LOW-H4",FibLast);
if (Fib1_2 > FibLast )Fib1_2 = FibLast ;
if (Fib1_1 < FibHiLast )Fib1_1 = FibHiLast ;
//Print ("FibLOW-Last",FibLast);
//Print ("fib2=",Fib1_2);
//Print ("FibHiLast",FibHiLast);
//Print ("fib1=",Fib1_1);
double LtFastEMA = iMA(NULL,exTimeFrame,34,0,MODE_EMA,PRICE_MEDIAN,0);//purple
double LtSlowEMA = iMA(NULL,exTimeFrame,55,0,MODE_EMA,PRICE_MEDIAN,0);//purple
double FibSell = (((Fib1_1-Fib1_2)*(FibHigh))+Fib1_2);//FibHigh is the 50% fib set by us
double FibBuy = (((Fib1_1-Fib1_2)*(FibHigh))-Fib1_1);// modify to +
double FibSell2 = (((Fib1_1-Fib1_2)*(FibLow))+Fib1_2);
double FibBuy2 = (((Fib1_1-Fib1_2)*(FibLow))-Fib1_1);
double buyone = Ask; Print ("ask=",buyone);
// double difference = FibBuy+0.001;Print ("difference=",difference);
double sellone = Bid; Print("bid=",sellone);
double SellPoint = FibSell;
double BuyPoint = FibBuy;

//if (Buy1_1 < Buy1_2) Order = SIGNAL_BUY;
if (buyone < FibBuy ) iRetVal = 3;

// if (dTFastEMA > dTSlowEMA ) iRetTrend = 4;

//Print ("FibBuy=",FibBuy);
//if (Sell1_1 > Sell1_2) Order = SIGNAL_SELL;
//if (FibSell < sellone && FibBuy > sellone && LtFastEMA < LtSlowEMA ) iRetVal = 2;
//Print ("fibsell=",FibSell);



Comment ( "buyone= ",buyone," iRetVal= ",iRetVal," fibsell= ",FibSell," FibBuy= ",FibBuy," fib1high= ",Fib1_1," fib2low= ",Fib1_2);
//Print("Order failed with error#", GetLastError());
return(iRetVal);
}

Files:
 

It is because this condition is not true . . .

if (buyone < FibBuy ) iRetVal = 3;


//if (FibSell < sellone && FibBuy > sellone && LtFastEMA < LtSlowEMA ) iRetVal = 2;   //  <---  commented out
 

I am not sure I understand what you mean


if "buyone " is less than "fibbuy"


for example

buyone on my chart = 1.3608


fibbuy = 1.387


therefore it is true and should print iretval = 3


when it is not true it prints iretval = 0

is this correct thinking ?

thanks

 

  1. Put Print statements after each time you change iretval and before the return so you find out which. Then print out values so you find out why.
  2. however it no longer give me anything but a 0
    Either you changed something or the problem lies elsewhere.
 
Tradingjunky:

therefore it is true and should print iretval = 3


when it is not true it prints iretval = 0

is this correct thinking ?

You said . . . "however it no longer give me anything but a 0"

From the code you have shown the only logical conclusion is what I have stated . . .

Change your Comment to a Print and copy and paste the line from the Journal/Log showing what you have said is true, i.e. buyone on my chart = 1.3608 fibbuy = 1.387 iretval = 0

Print( "buyone= ",buyone," iRetVal= ",iRetVal," fibsell= ",FibSell," FibBuy= ",FibBuy," fib1high= ",Fib1_1," fib2low= ",Fib1_2); 


 
Tradingjunky:

Hi Guys

I have an EA i have been building over a few months

but i have come to a halt on a part of it

so I am looking for some help please


if you go to the function marked check signal you will see i am using the int iRetVal to give me signals

however it no longer give me anything but a 0


if you run the EA you will see it prints to screen the hig the low and "fibuy" and Fibsell"


i am trying to write code that will either make a signal to buy or sell when the price comes in between these two points

any help or guidance would be,most appreciated

i have spent many hours trying to get something usefull



// this is the code that geneates a signal to trade or not
int CheckSignal(){
int iRetVal = 0;
double Fib1_1 = iHigh(NULL,PERIOD_W1,1);
Print ("last-high-W1",Fib1_1);
double FibHiLast = iHigh(NULL,PERIOD_H4,1);
Print ("last-high-H4",FibHiLast);
double Fib1_2 = iLow(NULL,PERIOD_W1,1);
Print ("last-LOW-W1",Fib1_2);
double FibLast = iLow (NULL,PERIOD_H4,1);
Print ("last-LOW-H4",FibLast);
if (Fib1_2 > FibLast )Fib1_2 = FibLast ;
if (Fib1_1 < FibHiLast )Fib1_1 = FibHiLast ;
//Print ("FibLOW-Last",FibLast);
//Print ("fib2=",Fib1_2);
//Print ("FibHiLast",FibHiLast);
//Print ("fib1=",Fib1_1);
double LtFastEMA = iMA(NULL,exTimeFrame,34,0,MODE_EMA,PRICE_MEDIAN,0);//purple
double LtSlowEMA = iMA(NULL,exTimeFrame,55,0,MODE_EMA,PRICE_MEDIAN,0);//purple
double FibSell = (((Fib1_1-Fib1_2)*(FibHigh))+Fib1_2);//FibHigh is the 50% fib set by us
double FibBuy = (((Fib1_1-Fib1_2)*(FibHigh))-Fib1_1);// modify to +
double FibSell2 = (((Fib1_1-Fib1_2)*(FibLow))+Fib1_2);
double FibBuy2 = (((Fib1_1-Fib1_2)*(FibLow))-Fib1_1);
double buyone = Ask; Print ("ask=",buyone);
// double difference = FibBuy+0.001;Print ("difference=",difference);
double sellone = Bid; Print("bid=",sellone);
double SellPoint = FibSell;
double BuyPoint = FibBuy;

//if (Buy1_1 < Buy1_2) Order = SIGNAL_BUY;
if (buyone < FibBuy ) iRetVal = 3;

// if (dTFastEMA > dTSlowEMA ) iRetTrend = 4;

//Print ("FibBuy=",FibBuy);
//if (Sell1_1 > Sell1_2) Order = SIGNAL_SELL;
//if (FibSell < sellone && FibBuy > sellone && LtFastEMA < LtSlowEMA ) iRetVal = 2;
//Print ("fibsell=",FibSell);



Comment ( "buyone= ",buyone," iRetVal= ",iRetVal," fibsell= ",FibSell," FibBuy= ",FibBuy," fib1high= ",Fib1_1," fib2low= ",Fib1_2);
//Print("Order failed with error#", GetLastError());
return(iRetVal);
}



The condition is false. Try this:

if (buyone < MathAbs(FibBuy) )

Then go back and figure out why this works.

 

I looked at this Mathabs thing the other day ( my education is form3 maths in 1963 ) so a lot of the maths stuff i never learned or have forgotten

i have added the line you suggest and yes it works

I have no idea why

i do not understand the description about Mathabs when i press F1

my next problem is

can i now make my statement to is equal to i wil try it shortly

if (buyone == MathAbs(FibBuy) )
 
Tradingjunky:

I looked at this Mathabs thing the other day ( my education is form3 maths in 1963 ) so a lot of the maths stuff i never learned or have forgotten

i have added the line you suggest and yes it works

I have no idea why

i do not understand the description about Mathabs when i press F1

my next problem is

can i now make my statement to is equal to i wil try it shortly

The condition is always false because FibBuy is always a negative number. MathAbs() returns the absolute value of a number. Look at the sample in the documentation and you will understand the function. I'm not saying MathAbs() is the solution to your problem, I'm only showing you what the problem is. Try this:

   
   Print(" buyone = " , buyone);
   Print(" FibBuy = " , FibBuy);

   if (buyone < MathAbs(FibBuy) )
 

i found it


my number is negative

mathabs converts it to positive for some reason

so my equation is wrong


cool

thankyou guys

 
danjp:

The condition is always false because FibBuy is always a negative number. MathAbs() returns the absolute value of a number. Look at the sample in the documentation and you will understand the function. I'm not saying MathAbs() is the solution to your problem, I'm only showing you what the problem is. Try this:


I am happy to say i figured it out before i read your post


but thank you anyway

 

further on this

I only figured it out after reading the Print statement and this little negative sign was in front of the fibbuy

and reading the mathabs thing again showed me what was wrong

I didnt have a clue before that

which is why i made this post

i can now proceed with what i was doing instead of trying figure out why my equation wasnt working


the reason I ended up with the negative result was i I was trying to take my fibuy from the high and my fibsell from the low


but both the high and the low are calculated the same way but in reverse

and if the fib point was set to .50 they ere both equal

so now to get 2 different points I am using the fibsell2 for the low point

and i can control the spot at which the iretval=3 appears now


well back to the grind see if i can get this to where I am happy before the open


lol


thanks to everyone for their posts

Reason: