Rating: Empty Star Empty Star Empty Star Empty Star Empty Star
Help with sl/tp pls?
Previous 1 2 3 4 5 .. 7 Next
spotfx

Member Since Apr 13, 2011  16 posts Spotfx (spotfx) May 09 2011 at 13:23
Hi, looking for something that would allow me to auto set a fixed sl & tp on every trade. My entries are @ candle close instant and by time I set tp and sl price has moved on. Not a problem to edit if only one position taken but on a few different pairs simultaneously then its a pain ;)
I just want to be able to hit the buy or sell button and have an automatic 20pip stop loss and take profit attached at the same time. ie one click does it all.

I am new to MT4 so needs to be REALLY simple to set up ie idiot proof ;)

Any ideas appreciated, thanks :)

finstudio

Member Since Dec 08, 2010  35 posts FinStudio (finstudio) May 11 2011 at 06:52
Here is a script 'AutoAssignSlTp.mq4' that will do what you requested.



Set the Take Profit and the Stop Loss values in pips. (e.g. TakeProfit_Pips = 20 and StopLoss_Pips = 20).


If ApplyToAllOpenPositions is TRUE, then the script will automatically apply the T/P and S/L to all open positions. If set to FALSE, it will only apply to the open positions of the current symbol.

If either value is set is 0, it will ignore that value. E.g. if TakeProfit_Pips = 0, then it will not apply the TakeProfit_Pips and likewise for StopLoss_Pips.

This script will only apply S/L and T/P if they are not set (0). If an open trade has T/P or S/L, the script ignores that order.

Attachments: AutoAssignSlTp.mq4
finstudio

Member Since Dec 08, 2010  35 posts FinStudio (finstudio) May 11 2011 at 06:58
Here is the correct script.

Attachments: AutoAssignSlTp_W8.mq4
zzzero

Member Since Jan 26, 2011  1367 posts zzzero May 11 2011 at 22:26
spotfx posted: I am new to MT4 so needs to be REALLY simple to set up ie idiot proof ;)



n/a
spotfx

Member Since Apr 13, 2011  16 posts Spotfx (spotfx) May 11 2011 at 22:54

zzzero posted:
    spotfx posted: I am new to MT4 so needs to be REALLY simple to set up ie idiot proof ;)





The above says so much about u as a human being ...zzzero by name... and by brain.

spotfx

Member Since Apr 13, 2011  16 posts Spotfx (spotfx) May 11 2011 at 22:56

finstudio posted:
    Here is a script 'AutoAssignSlTp.mq4' that will do what you requested.



Set the Take Profit and the Stop Loss values in pips. (e.g. TakeProfit_Pips = 20 and StopLoss_Pips = 20).


If ApplyToAllOpenPositions is TRUE, then the script will automatically apply the T/P and S/L to all open positions. If set to FALSE, it will only apply to the open positions of the current symbol.

If either value is set is 0, it will ignore that value. E.g. if TakeProfit_Pips = 0, then it will not apply the TakeProfit_Pips and likewise for StopLoss_Pips.


This script will only apply S/L and T/P if they are not set (0). If an open trade has T/P or S/L, the script ignores that order.



Finstudio, thanks for your help, much appreciated. I will give this a try as soon as I have time. smiley

spotfx

Member Since Apr 13, 2011  16 posts Spotfx (spotfx) May 12 2011 at 13:56
Hi Finstudio, this is great ..exactly what I wanted! grin Thank u very much!!!

zzzero

Member Since Jan 26, 2011  1367 posts zzzero May 15 2011 at 20:07 (edited May 15 2011 at 20:12 )
spotfx posted:
    
zzzero posted:
    spotfx posted: I am new to MT4 so needs to be REALLY simple to set up ie idiot proof ;)





The above says so much about u as a human being ...zzzero by name... and by brain.


oh yes, i do so understand how you feel.

http://tesla.plunder.com/x/$65xDajVHzyESzxRcVDnSKr96URXNqZ3q/302214aed1/set_profits.txt

btw, the other guy that uploaded that code, might you ask him if he could complicate that bloated code any more than he did?

i do not believe it is possible.

int init(){}
int deinit(){}

int set_profits()
{
int total,pos;

total=OrdersTotal();

for(pos=0;pos<total;pos++)
{
if(OrderSelect(pos,SELECT_BY_POS)==false) continue;

/*
i left out this part, cuz you were so awesomely rude.

dink.

*/


OrderModify(TICKET,OPENPRICE,STOPLOSS,TAKEPROFIT,EXPIRATION,CLR_NONE);


}//for



return(0);
}//set_profits


int start()
{

set_profits();

}//start


n/a
zzzero

Member Since Jan 26, 2011  1367 posts zzzero May 16 2011 at 03:15
i cant fifnd the button or whatever here at myfxbook to include an attachment like the person did above.

anybody?


n/a
zzzero

Member Since Jan 26, 2011  1367 posts zzzero May 16 2011 at 03:16
my bad.

i found it.

z/,.

n/a
Attachments: set_profits.txt
Previous 1 2 3 4 5 .. 7 Next
Tools Community Reviews Platform Company Support
Economic Calendar Community Brokers Features About FAQ
Forex Broker Spreads Systems Expert Advisors API Blog Help
Streaming Forex News Strategies Signal Providers Translations Twitter Contact Us
Community Outlook Contests VPS Services Mobile Facebook Report A Bug!
Widgets EA Programming        
RSS          

Site Map  |   Terms & Conditions  |   Privacy Policy
©2011 Myfxbook Ltd. All Rights Reserved.
HIGH RISK WARNING: Foreign exchange trading carries a high level of risk that may not be suitable for all investors. Leverage creates additional risk and loss exposure. Before you decide to trade foreign exchange, carefully consider your investment objectives, experience level, and risk tolerance. You could lose some or all of your initial investment; do not invest money that you cannot afford to lose. Educate yourself on the risks associated with foreign exchange trading, and seek advice from an independent financial or tax advisor if you have any questions. Any data and information is provided 'as is' solely for informational purposes, and is not intended for trading purposes or advice.
*GFT is a sponsor of myfxbook.com for advertisement purposes only. GFT does not endorse any other products, services, or companies represented on myfxbook.com. The views of myfxbook.com and all other parties contained therein are not necessarily those of GFT, and GFT makes no warranty as to the accuracy of information provided.