Help write an expert - page 12

 

i'm really new to forex.

I'm quite new to forex and i would like to ask if there is any way i can add trailinstop to the latest EA. If so, i would be very grateful for your suggestions. thanks in advance!

 

Dear people!

I have three questions:)

1) Expert Advisor closes a position by profit or loss. Sometimes the bar at which the position is closed by a loss corresponds in parameters to the opening of a new position, which I do not want at all! How and where do I draw up an order so that if I catch a loss on this candle, it does not open on it!

2) Moving Shift=6 in the stated variables - Is this a shift of the average horizontal (in time) by 6 bars ?

3) Is it technically possible and how to specify it correctly in the Expert Advisor code?

- the (1) ROC(14)-EURUSD(M15) and (2) ROC(14)- GBPUSD(M15) indicators should be used in the body of one EA

- this Expert Advisor should work on EURGBP(M15) cross only

- entry conditions (1)>(2)open_buy; (1)<(2)open_sell

- I am thinking about close :)))

For now! :)

It's hot now and no one wants to bother, but if I at least "send" in the right direction - I'll be grateful! :))

If anyone has good indicators of ROC, momentum, other speeds and accelerations - send references, plz!

 
obla4ko:

Dear people!

I have three questions:)

1) Expert Advisor closes a position by profit or loss. Sometimes the bar at which the position is closed by a loss corresponds in parameters to the opening of a new position, which I do not want at all! How and where do I draw up an order so that if I catch a loss on this candle, it does not open on it!

if (buy  && oldtrend !=1 ) {oldtrend = 1; price = Bid;}
if (sell && oldtrend !=-1) {oldtrend = -1;price = Bid;}
if (buy){
       if (virtualTrail(price,trailing_price,+1)>price)
            OpenBuyOrder();
    }
   
   if (sell){
        if (virtualTrail(price,trailing_price,-1)<price)
         OpenSellOrder();
    }
//............
//.............
double virtualTrail(double pr,double tr_price, int com=0)
{
    if (com==1)
         if (Bid - pr > tr_price*Point) return (Bid);
    if (com==-1)
         if (pr -Bid > tr_price*Point) return (Bid);
return(pr);
}


in the order placing code price = Bid; int oldtrend;

The logic: If the signal switches from buy to sell, then remember the price and wait for the price to deviate by trailing_price points

maybe the code is not quite correct - I am just testing it in my EA

 
IgorM:


in the order placing code price = Bid; int oldtrend;

logic: if the signal switches from buy to sell, then remember the price and wait for the price to move by trailing_price points

maybe the code is not quite correct - I am just testing it in my EA

i.e. use your logic by substituting your variables?
 
TONY_TRADER:

Hello

Apologize for posting off-topic.... but it doesn't make sense to post it in a branch I'm interested in, because no one goes there for a week... I need your help....... I don't really know MQL4 yet... but I really want to start.... Can you please tell me if you can use an editor to get some practice in writing simple programs... like mathematical problems for example... since I'm unlikely to start specialized programming immediately... if anyone knows, please tell me)))

i also have a question how can i check for errors in code ... and whether the program works or not))))


thanks)))) sorry again


I've already replied in one. This post is being deleted
 
obla4ko:

Dear people!

I have three questions:)


1) Download Kim's library - http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&func=fileinfo&id=63

There function isCloseLastPosByStop - Flag to close last position by stop.

Check this flag before opening a new order.

2)Yes.

3) maybe

 
Roger:

1) Download Kim's library - http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&func=fileinfo&id=63

There isCloseLastPosByStop function - Flag to close the last position by stop.

Check this flag before opening a new order.

2)Yes.

3) Maybe

How good you are!

Brevity is the sister of talent, or rather, the mother!!! Got it all - THANK YOU so much!