Problem Open Order Moving Average - page 2

 
nikky:
i use the tradeallowed function : And trade is allowed between 9am to 20pm so yes actually it is true.
And you checked it is actually working by adding a Print or Comment ?  can you copy & paste the screen shot or log entry please ?  don't assume,  check !
 

OK,  it seems your position size calculations are not working properly, try 1% risk instead of 5% . . . 


This is a bad idea . . .

if(Point == 0.001 || Point == 0.00001) 

 Read this thread:  Can price != price ?

 

Ok! thank you very much, the problem lied in the size positions... not enought money...

but when you wrote :


         else
            {
            if(OrderSelect(iBuyTicket, SELECT_BY_POS))
               if(!OrderModify(OrderTicket(), OrderOpenPrice(), dSellWideStop, dSellWideLimite, 0, 0))
                  Print("Order Modify failed, error # ", GetLastError() );}                                         


does the ordermodify is realized when included in an "if" loop?

indeed do the 2 blocks are tantamount ?

if(!OrderModify(OrderTicket(), OrderOpenPrice(), dSellWideStop, dSellWideLimite, 0, 0))
                 { Print("Order Modify failed, error # ", GetLastError() );} 




OrderModify(OrderTicket(), OrderOpenPrice(), dSellWideStop, dSellWideLimite, 0, 0);
if(!OrderModify(OrderTicket(), OrderOpenPrice(), dSellWideStop, dSellWideLimite, 0, 0))
                  {Print("Order Modify failed, error # ", GetLastError() );} 
 
nikky:

does the ordermodify is realized when included in an "if" loop?

Yes, of course . . .   OrderModify() returns a bool . . .  my code says . . .

 

if(! bool)  // not bool, so . . .   if false

   Print("Order Modify failed, error # ", GetLastError() );  // the {} are not needed for a single line  (except in some else conditions)
 
nikky:


indeed do the 2 blocks are tantamount ?

In this code . . . .

OrderModify(OrderTicket(), OrderOpenPrice(), dSellWideStop, dSellWideLimite, 0, 0);
if(!OrderModify(OrderTicket(), OrderOpenPrice(), dSellWideStop, dSellWideLimite, 0, 0))
                  {Print("Order Modify failed, error # ", GetLastError() );} 

 . . .  you are calling OrderModify() twice .. .

 

ok! thank you :)

and last question, in the EA i wrote :

int start()
{
fTradeAllowed (iTimeDebut, iTimeFin);
fStopSuiveur (Symbol(), iStop, iMagic) ;

if (TradeAllowed)
        {
...
        }
Do i have to call the function fTradeAllowed before if (TradeAllowed)... or is it useless ?
 
RaptorUK:

The way you are using functions doesn't make a lot of sense . . .  if a function is designed to returns a value then you should use that return value . . .

TradeAllowed = fTradeAllowed (iTimeDebut, iTimeFin);



bool fTradeAllowed (int iTimeDebut, int iTimeFin)
   {
   iTimeSeconds = Hour()*3600 + Minute()*60 + Seconds(); // Conversion de l'heure actuelle en secondes ;
   if(iTimeSeconds >= iTimeDebut && iTimeSeconds < iTimeFin) // Vérification si l'heure est dans la plage horaire du filtre horaire
      return(true);

   else return(false);
   }

  . . .  you can also use local variables in the function instead of globally declared variables.

You could do this . . .
 
nikky:

ok! thank you :)

and last question, in the EA i wrote :

Do i have to call the function fTradeAllowed before if (TradeAllowed)... or is it useless ?
You have to call the function,  it sets the value of  TradeAllowed . . .  the way the function is currently written is not very logical and it makes no use of returning it's type.
 
RaptorUK:
You have to call the function,  it sets the value of  TradeAllowed . . .  the way the function is currently written is not very logical and it makes no use of returning it's type.


ok thank you :)
Reason: