Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 01-06-2006, 08:39 PM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
how does one post code

Hi

Please tell me how to post code - so that it goes into a box that others can easily copy.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 01-06-2006, 08:49 PM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 14,365
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Quote:
Originally Posted by cardio
Hi

Please tell me how to post code - so that it goes into a box that others can easily copy.

Thanks
You may post the code as simple text.

But better is to post it betweet this sign # like this:

Code:
This is the code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 01-06-2006, 08:53 PM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
testing

hi

some code:
Code:
void MoneyManagement() 
{

   
   
	int i,hstTotal=HistoryTotal();
	int losses;
    static double val1;
	
	for(i=hstTotal-1;i>=0;i--)  

	{
	 //---- check selection result
	 if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==fals  e)
	   {
		Print("Access to history failed with error (",GetLastError(),")");
		break;
	   }
	   if(OrderProfit()>0){
        val1 = 0;
        break;
        }
	   if(OrderProfit()<0) {
       losses++; 
       val1 = val1 + orderProfit();
       }
	   if(losses==2) {
	   
	   
	   lotMM = MathCeil(AccountFreeMargin() * 50 / 10000) / 10;  // 50 risk :)

	  if (lotMM < 0.1) lotMM = Lots;
	  if (lotMM > 1.0) lotMM = MathCeil(lotMM);
	  if  (lotMM > 100) lotMM = 100;
	   
	   }
	}

Got it - thanks - were would one find the different html tags one can use on this forum?

Last edited by cardio : 01-06-2006 at 09:21 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 01-06-2006, 09:58 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 986
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow vB code

Quote:
Originally Posted by cardio
were would one find the different html tags one can use on this forum?
Follow this link vB code
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 01-07-2006, 10:09 AM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
Thanks

Thanks codesguru
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 02-03-2006, 01:51 PM
cucurucu's Avatar
cucurucu cucurucu is offline
Senior Member
 
Join Date: Jan 2006
Posts: 315
cucurucu is on a distinguished road
Question Zero Loss Code?

Hi,
Please help a newbie here!

Can anyone write the code (MQL4) to modify the StopLoss of an Order after the profit has reached X pips? I want to include this code into an EA. I would like to raise the StopLoss to the level of 0 profit in order to not lose anything if the market goes against my position. This way the position will close at 0 P/L. This is very useful when your position is making only few pips (not enough to trigger the trailing stop) and after that, the prices go to the oposite direction, making you lose.



Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 02-04-2006, 11:08 AM
sunwest's Avatar
sunwest sunwest is offline
Member
 
Join Date: Jan 2006
Location: London
Posts: 93
sunwest is on a distinguished road
Hello,

I am not sure if this could be integrated into your EA, but I put a separate fonction that you can put at the end of the code and call during the main loop.

Make sure you have a global variable "Magic" that you are using when placing order:

----
int Magic;
-----

Also you need to set the number of pips in profit "ProfitModifySL" before you would like to set your stopLoss to the actual opening price:

----
extern double ProfitModifySL=15; // After being in 15 pips Profit Stoploss is adjusted to the opening price of the order
-----

//+------------------------------------------------------------------+
//| Scan through Order and if in profit by PrmSL Modify SL |
//+------------------------------------------------------------------+
void fModifySLWhenInProfit()
{
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if (OrderType()==OP_BUY && Bid-OrderOpenPrice()>=ProfitModifySL*Point)
fModifyStopLoss(OrderOpenPrice());

if (OrderType()==OP_SELL && OrderOpenPrice()-Ask>=ProfitModifySL*Point)
fModifyStopLoss(OrderOpenPrice());
}
}
}
}
//+------------------------------------------------------------------+
//| Modify Stop Loss |
//+------------------------------------------------------------------+
void fModifyStopLoss(double tStopLoss)
{
bool result = OrderModify(OrderTicket(),OrderOpenPrice(),tStopLo ss,OrderTakeProfit(),0,NULL);
}

Otherwise I attached to the post a simple EA that does it.
Hope this help

Cheers
Attached Files
File Type: mq4 Sample-v1.mq4 (3.3 KB, 77 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 02-05-2006, 02:18 PM
cucurucu's Avatar
cucurucu cucurucu is offline
Senior Member
 
Join Date: Jan 2006
Posts: 315
cucurucu is on a distinguished road
Smile

Thank You sunwest!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 02-05-2006, 02:40 PM
sunwest's Avatar
sunwest sunwest is offline
Member
 
Join Date: Jan 2006
Location: London
Posts: 93
sunwest is on a distinguished road
You are welcome, also to avoid to modify your orders all the time and do it once you could change:

if (OrderType()==OP_BUY && Bid-OrderOpenPrice()>=ProfitModifySL*Point)
fModifyStopLoss(OrderOpenPrice());

if (OrderType()==OP_SELL && OrderOpenPrice()-Ask>=ProfitModifySL*Point)
fModifyStopLoss(OrderOpenPrice());

to

if (OrderType()==OP_BUY && Bid-OrderOpenPrice()>=ProfitModifySL*Point)
if (OrderStopLoss()<OrderOpenPrice()) fModifyStopLoss(OrderOpenPrice());

if (OrderType()==OP_SELL && OrderOpenPrice()-Ask>=ProfitModifySL*Point)
if (OrderStopLoss()>OrderOpenPrice()) fModifyStopLoss(OrderOpenPrice());

S.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 02-17-2006, 12:22 AM
fairwind's Avatar
fairwind fairwind is offline
Member
 
Join Date: Nov 2005
Posts: 54
fairwind is on a distinguished road
Vertical line production in mql code

Hi folks,

I am interested in an mql code set that can produce a vertical line on a chart at a selectable time. Does anything like this exist or can it be coded??

My understanding of mql codes are very minimal and I cannot code anything. The best I can do is change the colour of 'objects' and their density.

My appreciation to any and all who respond and to this wonderful forum...

Good trading to all.......................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 04:22 PM


All times are GMT. The time now is 09:54 PM.