[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 232

 
DhP:

What is the difference between double tmp and NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0)?

Multiplying them will always be greater than zero.

I think so))

(-) * (-) = +

(+) * (+) = +


а.... you are absolutely right... NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0) - here we should put "i" instead of 0 - I changed it, but it still did not start making deals....

the code now looks like this:

 bool signal_MACD() 
  { 
    bool signal_MACD = false;
    double tmp = iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0); 
    for(int i=1;i<=5;i++) 
    { 
       if(NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,i)*tmp,4)<0.0) 
       { 
          signal_MACD = true; 
          break; 
       }        
    } 
    return(signal_MACD);
  } 

but it still doesn't work

 
CLAIN:


а.... you're absolutely right... NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0) - I changed it, but it never started making deals....

The code now looks like this:

but it still doesn't work.

Does this change true to false?

Does the function change the output value?

 
CLAIN:


а.... you are absolutely right... NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0) - here we should put "i" instead of 0 - I changed it, but it still did not start making deals....

the code now looks like this:

but it still doesn't work


Use "Print", read the logs and compare "what is" with "what is expected".
 

The function does not change values.... at least that's my judgement, because the trades never started to open.

how do you use print?

 bool signal_MACD() 
  { 
    bool signal_MACD = false;
    double tmp = iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0); 
    for(int i=1;i<=5;i++) 
    { 
       if(NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,i)*tmp,4)<0.0) 
       { 
          signal_MACD = true; 
          Print(NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,i)*tmp);
          break; 
       }        
    } 
    return(signal_MACD);
  } 

i only have this version, but something tells me it's wrong too....

 
CLAIN:

The function does not change values.... at least that's my judgement, because the trades never started to open.

how do you use print?

i only have this version, but something tells me it's wrong too....


Print("iMACD(",Symbol(),",",TF,",",fast_ema,",",slow_ema,",",signal_period,",",PRICE_CLOSE,",",MODE_MAIN,",",i,",",")*",tmp,"=",iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,i)*tmp);
 
MaxZ:

If all variables are declared, I don't see any errors in MQL4 syntax...

What's the problem?

Thank you.

Doing a rollback calculation for my EA. I saw that the calculations were inaccurate, so I went through the blocks that may contain errors.

 


Hi.

Help me understand
I am writing an EA and can't figure out the orders.
I am putting out orders:
OrderSend(Symbol(),OP_SELLLIMIT,lot,cena_sell,3,sl _sell,tp_sell,"",1,0,Red);
Alert (GetLastError());

OrderSend(Symbol(),OP_SELLLIMIT,lot_1,cena_sell_d_ 1,3,sl_sell,tp_sell_d_1,",2,0,Red);
Alert (GetLastError();

OrderSend(Symbol(),OP_SELLLIMIT,lot_2,cena_sell_d_ 2,3,sl_sell,tp_sell_d_2,"",3,0,Red);
Alert (GetLastError();

OrderSend(Symbol(),OP_SELLLIMIT,lot_3,cena_sell_d_3,3,sl_sell,tp_sell_d_3,"",4,0,Red);
Alert (GetLastError());

If the first take profit is triggered, delete the other orders.
If the first one has not triggered, and the second take profit has triggered, change lots_3 and lot_4 for the third and fourth take profit.

 
sergey_r:


Hi.

Help me out here.
I'm writing an EA and can't figure out the orders.
I'm putting orders:
OrderSend(Symbol(),OP_SELLLIMIT,lot,cena_sell,3,sl _sell,tp_sell,"",1,0,Red);
Alert (GetLastError());

OrderSend(Symbol(),OP_SELLLIMIT,lot_1,cena_sell_d_ 1,3,sl_sell,tp_sell_d_1,",2,0,Red);
Alert (GetLastError());

OrderSend(Symbol(),OP_SELLLIMIT,lot_2,cena_sell_d_ 2,3,sl_sell,tp_sell_d_2,"",3,0,Red);
Alert (GetLastError());

OrderSend(Symbol(),OP_SELLLIMIT,lot_3,cena_sell_d_3,3,sl_sell,tp_sell_d_3,"",4,0,Red);
Alert (GetLastError());
I need:
If the first take profit is triggered, delete the remaining orders.
If the first one has not triggered, and the second take profit has triggered, change lots_3 and lot_4 for the third and fourth ones.


What came first - use the function from this page of the forum - it returns the flag to close the order at take profit. Before that, depending on your (different) order volumes - you set each of them a different magic_number, i.e. lot - magic 1, lot1 - magic 2 etc. Then you check if the order with magic 1 was closed by the take order using this function and if so you "remove the others". And then by the code you also check the second order with magic number 2 - if it is Ok, then you modify the third and fourth orders (change their volumes)... and when setting pending orders and modifying them you better remember to check for min. tolerances and everything else... Like this...
 

I don't understand how to use the functions. Could you describe how to do it?

Here I have placed these orders. Then I insert the function from that page. Or how? Describe an example of how to do this. Please.

 
sergey_r:

I don't understand how to use the functions. Could you describe how to do it?

Here I have placed these orders. Then I insert the function from that page. Or how? Describe an example of how to do this. Please.



The order of working with f-mi - these are basic things, around which everything revolves... Take it apart, see examples of owls (in a competent code), they can be found in codebase - take apart this example of owl and use it as a basis for your own... It's a base, you can't do without it. I myself put the owl based on this example in codebase.

Take it easy, take your time - sort it out.

Reason: