Experts: 1 MINUTE SCALPER - page 2

 
Bahman Askerov:
//--- should it be closed?
            if(((Bid<OrderOpenPrice()-iATR(NULL,0,14,0)) || ((MacdMAIN>0 && MacdMAIN<MacdSIGNAL) || (MacdMAIN<0 && MathAbs(MacdMAIN<MacdSIGNAL)))
               || Close[1]==upperBB)) //--- close order and exit

              {if(!OrderClose(OrderTicket(),OrderClosePrice(),Bid,3,Violet)) Print("OrderClose error ",GetLastError()); return;}


Here... in last condition.... || (MacdMAIN<0 && MathAbs(MacdMAIN<MacdSIGNAL))

in the second part ....

&& MathAbs(MacdMAIN<MacdSIGNAL)

I cant see what it means - MathAbs is not a logical function, right?

Then how can it work in the code, without a syntax error?

... I try to see if it closes the order timely... to avoid unnecessary losses...


Here ... && MathAbs(MacdMAIN<MacdSIGNAL) .. it looks as if the brackets are either missing or not in their place..

Please correct me if you can.


Regards

Bahman


MathAbs The function returns the absolute value (modulus) of the specified numeric value.

This is the right way to use the MACD indicator.

If you do not understand any of the orders/functions in the code, you can highlight the order / function with the mouse and click F1 on MetaEditor.

 

Hi Aharon, 


there is no need for F1)


I ask about this part:

MathAbs(MacdMAIN<MacdSIGNAL)


y say it calculates Absolute value of its parameter inside of the parenthesis

and this is not numeric value....

MacdMAIN<MacdSIGNAL - is not numeric value to calculate the absolute value out of it...

It looks logical 

numeric < numeric - gives logical result... and .. then from logical value .. it calculates absolute value....

This is something unusual I have never seen before. I wonder if everything is in order here..

How is it possible to calculate absolute value of logical value?

I am asking about it.. F1 - will never answer it)


Regards

Bahman

 
Bahman Askerov:

Hi Aharon, 


there is no need for F1)


I ask about this part:

MathAbs(MacdMAIN<MacdSIGNAL)


y say it calculates Absolute value of its parameter inside of the parenthesis

and this is not numeric value....

MacdMAIN<MacdSIGNAL - is not numeric value to calculate the absolute value out of it...

It looks logical 

numeric < numeric - gives logical result... and .. then from logical value .. it calculates absolute value....

This is something unusual I have never seen before. I wonder if everything is in order here..

How is it possible to calculate absolute value of logical value?

I am asking about it.. F1 - will never answer it)


Regards

Bahman

See line 124-127 in code on MetaEditor:

//+------------------------------------------------------------------+                                        

   double  MacdMAIN=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);

   double  MacdSIGNAL=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);

//+------------------------------------------------------------------+   

***Real Types (double, float) -Real types (or floating-point types) represent values with a fractional part.***

you can highlight the technical indicator "iMACD" with the mouse and click F1 on MetaEditor.

This is what you will see:

iMACD

Calculates the Moving Averages Convergence/Divergence indicator and returns its value.

double  iMACD(
   string       symbol,           // symbol
   int          timeframe,        // timeframe
   int          fast_ema_period,  // Fast EMA period
   int          slow_ema_period,  // Slow EMA period
   int          signal_period,    // Signal line period
   int          applied_price,    // applied price
   int          mode,             // line index
   int          shift             // shift
   );

Parameters

symbol

[in]  Symbol name on the data of which the indicator will be calculated. NULL means the current symbol.

timeframe

[in]  Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.

fast_ema_period

[in]  Fast EMA averaging period.

slow_ema_period

[in]  Slow EMA averaging period.

signal_period

[in]  Signal line averaging period.

applied_price

[in]  Applied price. It can be any of ENUM_APPLIED_PRICE enumeration values.

mode

[in]  Indicator line index. It can be one of the Indicators line identifiers enumeration values (0-MODE_MAIN, 1-MODE_SIGNAL).

shift

[in]  Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Returned value

Numerical value of the Moving Average of Oscillator indicator.

Note

In some systems it is called MACD Histogram and plotted as two lines. In MetaTrader 4 client terminal MACD is plotted as histogram.

Example:

  if(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0)) return(0);

 

Please note the Returned value:

Returned value

Numerical value of the Moving Average of Oscillator indicator.

 
lowfly:

Thanks for Your Code, but don't work for me. I set same settings of Your image and show errorsWhat I do wrong?

I use MT 4

(big image for details)

Hello

Please help me help you, check the  default EA named "MACD Sample" that you have in your Meta Trader platform and tell me if you get the same error.

waiting for your answer.

Also try to increase the values of stop levels:

         WHENTOMOVETOBE=10;      //When to move break even
         PIPSTOMOVESL=5;         //How much pips to move sl

         TrailingStop=40;        //TrailingStop 
          Stop_Loss=20;           //Stop Loss

 
Fernando Carreiro:

Never use the Volume to check for a new bar. Do it properly by using the open time of the latest bar:

Thanks for the educated comment, I'll see how it works and try to change all the EA's accordingly.

 
Aharon Tzadik:

Hello

Please help me help you, check the  default EA named "MACD Sample" that you have in your Meta Trader platform and tell me if you get the same error.

waiting for your answer.

Also try to increase the values of stop levels:

         WHENTOMOVETOBE=10;      //When to move break even
         PIPSTOMOVESL=5;         //How much pips to move sl

         TrailingStop=40;        //TrailingStop 
          Stop_Loss=20;           //Stop Loss

Ok,

MACD sample @ 1min TF have few errors too

BUT! now ,Your Scalper with your new suggested settings:  errors gone and have few profit :)

What was I doing wrong?


(MACD @1 TF & Strategy // 1M Scalper @1 TF & Strategy; images)

 
lowfly:

Ok,

MACD sample @ 1min TF have few errors too

BUT! now ,Your Scalper with your new suggested settings:  errors gone and have few profit :)

What was I doing wrong?


(MACD @1 TF & Strategy // 1M Scalper @1 TF & Strategy; images)

Your broker does not allow low values to stop levels,then use higher values,like i told you.

OrderModify Error 130 means that You can't move stops closer to the market than MODE_STOPLEVEL. Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial

Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
  • book.mql4.com
Tables below show calculation values that limit the conduction of trades when opening, closing, placing, deleting or modifying orders. To get the minimum distance to StopLevel and freezing distance FreezeLevel the MarketInfo() function should be called. Requirements. Correct prices used when performing trade operations. Order Type Open Price...
 
Aharon Tzadik:

Your broker does not allow low values to stop levels,then use higher values,like i told you.

OrderModify Error 130 means that You can't move stops closer to the market than MODE_STOPLEVEL. Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial

Ok ok , I will exercise more in Tester to find best values

 Thanks very much for your time, EA, and directives! 

Best Regards

(I keep looking this thread)

 
Aharon Tzadik:

MathAbs The function returns the absolute value (modulus) of the specified numeric value.

This is the right way to use the MACD indicator.

If you do not understand any of the orders/functions in the code, you can highlight the order / function with the mouse and click F1 on MetaEditor.

No, that is not the correct way to do it! You are applying the MathAbs to a boolean condition and not a real number:

MathAbs( MacdMAIN < MacdSIGNAL ) // ( MacdMAIN < MacdSIGNAL )is a boolean condition that will return either true or false.

MathAbs( true )  // This is what your code is equivalent to when it ( MacdMAIN < MacdSIGNAL ) == true

MathAbs( false ) // This is what your code is equivalent to when it ( MacdMAIN < MacdSIGNAL ) == false

That part of the code is just "nonsense" code. You need to fix it!

 
Fernando Carreiro:

No, that is not the correct way to do it! You are applying the MathAbs to a boolean condition and not a real number:

That part of the code is just "nonsense" code. You need to fix it!

You're right and also Bahman Askerov is right ,it should be MathAbs(MacdMAIN) < MathAbs( MacdSIGNAL) ) 

I thank both of you for your comments and thanks to you the EA's will work better,

I will fix it.