Trailingstop in Buy/Sell Script

 

Hi Coders

I search the forum and the web, but don't find what I use.

I see the other thread's but nothing that I can use.

Swiss Army Knife it's a great EA, but I have open a lot of trades I managed by myself.

And this EA needs to much time to specify all the differnt trades.

I use my script for " scalping ": open 5 orders and set TS and SL but no TP. It needs to much time

to set all the TS manually.

Primary Question: It's not possible to integrate a TS logic in a script ?

 

Hi Badguy,

As I remember - programmer KimIV coded his Universal EA as a transformer: 1 module for trailing stop (work with any EA), 1 module for money management (to work with any EA too), and so on.

The thread is here:

https://www.mql5.com/en/forum/173193

But I am sorry - I did not follow his development anymore ...

His idea is brilliant: create separatede module/EA/script for every mql4 function, and build any EA from those modules on the same way as transformer.

As I remember - he created few modules for trailing stop to be used with any EA.

I am bad coder so I can not help to adapt any of his module for your EA for example ... but you can look at this thread and can ask the programmers to help you ...

As I remember - I used his trailing stop module for few EAs and traded by it (every module came with the description about how to use it with any EA for example).

 

Thanks newdigital

I will try to adapt in my scripts, otherwise I will try to contact the programmer KimIV

PS. your tip for relogin with lastpass was excellent

newdigital:
Hi Badguy,

As I remember - programmer KimIV coded his Universal EA as a transformer: 1 module for trailing stop (work with any EA), 1 module for money management (to work with any EA too), and so on.

The thread is here:

https://www.mql5.com/en/forum/173193

But I am sorry - I did not follow his development anymore ...

His idea is brilliant: create separatede module/EA/script for every mql4 function, and build any EA from those modules on the same way as transformer.

As I remember - he created few modules for trailing stop to be used with any EA.

I am bad coder so I can not help to adapt any of his module for your EA for example ... but you can look at this thread and can ask the programmers to help you ...

As I remember - I used his trailing stop module for few EAs and traded by it (every module came with the description about how to use it with any EA for example).
 

I am not sure that KimIV is the member of our forum.

if it is some small fixing so you can ask for for any coder here to help.

because this kind of "transformering EA" is very interesting for anyone.

 

Hi newdigital

any suggestions which member I can ask ?

Or which threat I should place my request ?

Thread: how to Code ?

newdigital:
I am not sure that KimIV is the member of our forum.

if it is some small fixing so you can ask for for any coder here to help.

because this kind of "transformering EA" is very interesting for anyone.
 

I am not sure exactly but I think that MrTools can help.

This thread is fine.

 

Hi Badguy,

Are you looking for an Ea to handle your scrips(not sure I am understanding,sorry) also think I need to read KimIV's idea more for some reason haven't seen this thread before, but yeah will do it if I can.

 

hi mrtools

sorry for my late respond.

No, don't need an EA.

I works with modifed scripts for buy and sell ( open 5 orders with SL no TP )

The buy aand sell script works without .mqh file too.

Maybe it's possible to integrate the Trailingstop logic into the .mqh file ?

Something like this: ( snipped from MT4 EA MACD Sample )

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && // check for opened position

OrderSymbol()==Symbol()) // check for symbol

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

if(MacdCurrent>0 && MacdCurrentSignalPrevious &&

MacdCurrent>(MACDCloseLevel*Point))

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

else // go to short position

{

// should it be closed?

if(MacdCurrentSignalCurrent &&

MacdPrevious(MACDCloseLevel*Point))

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

return(0);

I have attached the original scripts and mqh file.

Maxbe it helps I'm not a coder

Thanks

mrtools:
Hi Badguy, Are you looking for an Ea to handle your scrips(not sure I am understanding,sorry) also think I need to read KimIV's idea more for some reason haven't seen this thread before, but yeah will do it if I can.
 
Files:
 

Hi Badguy,

Trying a script i modified to call an include file but not very optimistic because the script once it places an order it leaves the chart, but will see and post if it works.

Reason: