Download MetaTrader 5

Delay Entry EA Help

To add comments, please log in or register
mk731
31
mk731  

Hi,

I'm editing MACD Sample, using H4 AUDUSD,

I want to use the entry conditions supplied, but i want to delay it by looking for a correction in the trend then enter.

I used an input called 'Lookback', created a for loop that loops for i=0 to Lookback.

The Problem

I set the Lookback to 5,

it will only enter the trade if the 5th candle back has the entry signal, NOT anything between 0 and 5 candles back.

Could you please help
THX

Files:
whroeder1
17097
whroeder1  

Your "delay it by looking for a correction" is too vague. Until you come up with concrete definitions, you will never succeed, and no one can help you.

Perhaps start with something like:

static bool upTrend=false, dnTrend=false; 
if(MACD > 70) upTrend=true; dnTrend=false;
if(MACD < 30) upTrend=false; dnTrend=true;

bool retrace=MACD(2) < 70;
bool continuation = MACD(1) > MACD(2)
if(upTrend && retrace && continuation) Buy();

:
mk731
31
mk731  

entry signal is made, but i want to delay entry so that a bar moves counter trend to enter trade.

i.e. for a buy,

conditions met, bar is green

wait till, a bar goes red, ('Lookback' varibale is the limit on how long it waits),

then at close or open on next bar, enter a buy trade

for sell, visa versa.


so i've written,

for the waiting loop,

for (i=0; i<Lookback;i++) //Lookback is a variable

if (entry condtions)

{buy0=true;}

else buy0=flase;


for entry,

if(buy0==true && Close0<Open0)

{ ticket=OrderSend(.....)}


so how come this only works if it's exactly 'Lookback' the period set, not 0 to "Lookback'

whroeder1
17097
whroeder1  
mk731: so how come this only works if it's exactly 'Lookback' the period set, not 0 to "Lookback'

Zero the loop exits. Stop looping! Return and wait for the next tick. On the next bar, test for your "bar goes red."

To add comments, please log in or register