Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


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
  #181 (permalink)  
Old 08-02-2007, 08:38 PM
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
Okay,
if I wanted to know what is the code for closing a ceratin order, not all of them, how would I find it?

Go to MQL4: automated forex trading, strategy tester and custom indicators with MetaTrader ? And type in "Closing a certain order"?

Thanks,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #182 (permalink)  
Old 08-02-2007, 09:52 PM
Member
 
Join Date: Feb 2007
Posts: 30
justize is on a distinguished road
Hello again ^^

for a MM-algorithm i need the following, maybe someone has an idea:

standardlotsize = 1
when the last trade was a winner (positive profit) : newlotsitze = 0.5*standardlotsize
when the last trade was a looser (negative profit) : newlotsize = 2*standardlotsize

Is there any command to get the profitinformation of the last trade? With it would be simple to generate this algorithm.

Thanks readers

PS: Attachment was a mistake...
Attached Images
File Type: jpg failure.JPG (52.4 KB, 76 views)

Last edited by justize; 08-02-2007 at 10:00 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #183 (permalink)  
Old 08-02-2007, 10:25 PM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Lastorder profit

The only way of getting the last orders profit is by going through the complete orderhistory like the example below.
After the loop exit, Lastorderprofit will contain the value you need to make the Lotsize decision.

Code:
   datetime LastTradeTime   = 0;
   double   LastOrderProfit = 0;

   for (int cnt=0; cnt<OrdersHistoryTotal(); cnt++)   // Do an inventory on history trades status
   { 
      if (OrderSelect(cnt, SELECT_BY_POS,MODE_HISTORY))
      {
         if (OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber)
         {
            if (OrderOpenTime() > LastTradeTime)
            {
               LastTradeTime   = OrderOpenTime();
               LastOrderProfit = OrderProfit();
            }     
         }
      }
   }
Good luck.
__________________
Better being out wishing to be in, than being in wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #184 (permalink)  
Old 08-03-2007, 01:55 AM
Junior Member
 
Join Date: Aug 2007
Posts: 2
Fandango is on a distinguished road
Hi,
MQL4 user just sent me a PM.
I see that there are too many questions around here. Why won't someone just make an EA for MQL4 user? I checked all his posts, and I think i got what he wants:

-StopLoss=10
-Limit=500
-Lots=AccountBalance/120(the result should be rounded, ie., 8.9 should be 8

-At 22:30:00, he wants a buystop set 10 pips above the current price, and a sellstop set 10 pips below the current price.

-If the market goes 1 PIP up, he wants the buystop and sellstop to go up 1 PIP too. Converesly, if the market goes 1 PIP down, he wants the buystop and sellstop to go 1 PIP down. He wants this to keep on modifying the pending orders like this until the Expert Advisor is diabled.

-He wants the Expert Advisor to be automatically disabled at 23:30:00, and automatically enabled at 17:00:00.

-Then, he wants to exit any pending orders/cancel any open positions at the open of the bar at 16:30:00. Not the time, but when the market recognizes the open of the bar of 16:30:00.

-He also wants the Expert Advisor to be spread calulated.

-He also wants to trade this forever. He wants everything that needs to be in the Expert Advisor to be traded forever, or for at least a very long time. Like Daylight savings time would be good, and more stuff.


I took the time to put this all together, and now it's time for someone else to just code this, and get it over with! He'll keep on asking questions like this on and on! He'll stop when he has his Expert Advisor. Also, he would like some explanations of each line of the code..like using this,

PHP Code:
//Write explanations on each line of codes 
Then, I gurantee, he'll stop asking questions.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #185 (permalink)  
Old 08-03-2007, 02:02 AM
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+10*Point,3,A sk-StopLoss*Point+10*Point,Ask+

Why this buy stop pending order after making buy, closed after some seconds
I could not find syntax in the help menu

OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+10*Point,3,A sk-StopLoss*Point+10*Point,Ask+
Profit*Point+10*Point," EA",12345,0,Blue);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #186 (permalink)  
Old 08-03-2007, 04:02 AM
Senior Member
 
Join Date: Feb 2006
Posts: 558
Michel is on a distinguished road
Quote:
If the market goes 1 PIP up, he wants the buystop and sellstop to go up 1 PIP too. Converesly, if the market goes 1 PIP down, he wants the buystop and sellstop to go 1 PIP down
How the StopOrders will ever be triggered ? on a 10 pips gap ?
Seeing his posts and the PMs I also received, Mql4 is not able to write a simple EA nor even to understand several simple trading concepts.
But while his strategy seems simple nonsense, it should be better for him to first discuss here about his strategy with more experienced traders.
BTW, the 1 pip move does remind me the last Dan's grail... Should it be possible that Mql4 == Dan ?

@ Fandago :
Quote:
MQL4 user just sent me a PM.
It's your first post ! How Mql4 did you send a PM before you write your first post ???
Mql4 == Dan == Fandago ???

Quote:
Then, I gurantee, he'll stop asking questions.
Yeap, a classic Dan's promise ...

Last edited by Michel; 08-03-2007 at 04:20 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #187 (permalink)  
Old 08-03-2007, 04:52 AM
Junior Member
 
Join Date: Aug 2007
Posts: 2
Fandango is on a distinguished road
what? what r u takin 'bout?
who's dan?
i just came to this site, and your already think'n that i'm someone i'm not.
do u do this for every1 that is new to this sitee?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #188 (permalink)  
Old 08-03-2007, 04:56 AM
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
Michel,
You are not helping anyone.
Why won't You just stop complaining and just help???
This is what happens when people have nothing to do!!!
They just complain, and complain!!!

Why can't You just answer the simple questions, for a simple MQL4 coder beginner. I bet You were just as desperate as me when You were a beginner.

You know, it's very hard!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #189 (permalink)  
Old 08-03-2007, 09:27 PM
Iva Iva is offline
Junior Member
 
Join Date: Aug 2007
Posts: 6
Iva is on a distinguished road
Pending Orders Adjustment

Hello, felow programmers,
I just start participation in the forum.
Years ago I learned C++ programming in the college.
The time passed and some things I forgot.
It is look like MQL language.
I have here a code that have a bug, I spent half a day.
This code is moving only BUY STOP order downwards only.
I need both BUY STOP and SELL STOP moving up and down in unison with
the bid line.
Also, when I run my program, sometimes only BUY STOP pops up, sometimes
only SELL STOP, and sometimes both. I guess this is because of slippage limit or too high market volatility.
Will somebody please help me.
Thanks a lot.



PHP Code:
void AdjustingPendingOrders()
{
Print (
"Adjusting the MT pending orders");
   
bool   signal;
   
double price,MarketInformation;
   
int    type,totalexpiration;
   
total=OrdersTotal();
   
MarketInformation=MarketInfo(Symbol(),MODE_POINT);
   for(
int N=0N<totalN++)
     {
       if(
OrderSelect(N,SELECT_BY_POS,MODE_TRADES))
         {
           
type=OrderType();
           
//---- working with pending orders only
           
if(type!=OP_BUY && type!=OP_SELL)
             {
              
//---- modifying
              
price =OrderOpenPrice()-1*MarketInformation;
              
signal=OrderModify(OrderTicket(),price,Bid Point StopLoss,OrderTakeProfit(),0,CLR_NONE);
             
//price =OrderOpenPrice()+1*MarketInformation;
              
signal=OrderModify(OrderTicket(),price,Bid Point StopLoss,OrderTakeProfit(),0,CLR_NONE);
              
//Print ("Total is =  ", total," MarketInformation = ",MarketInformation," type = ", type,
              //" price = ", price, " signal = ", signal );///*" OrderSelect = ", OrderSelect()*/
              //break;
             
}
          }
       }

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #190 (permalink)  
Old 08-04-2007, 12:13 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
The main problems with the code, I think, were that it didn't take spread and stop level into account, and then that the stop-loss for the SELL was placed below the open price. The following is a rehash of the code resolving those problems.

PHP Code:
void AdjustingPendingOrders()
{
    Print ( 
"Adjusting the MT pending orders" );
    
double spread MarketInfoSymbol(), MODE_SPREAD );
    
double level MarketInfoSymbol(), MODE_STOPLEVEL );
    
double offset MathMaxspreadlevel );
    
double price Bid offset Point;
    
double SL;
    for ( 
int N OrdersTotal() - 1>= 0N-- ) {
        if ( ! 
OrderSelectNSELECT_BY_POSMODE_TRADES ) )
            continue;
        if ( 
OrderType() != OP_BUYSTOP && OrderType() != OP_SELLSTOP )
            continue;
        
//---- working with pending orders only
        //---- modifying
        
if ( OrderType() == OP_BUYSTOP ) {
            
SL price StopLoss Point;
        } else {
            
SL price StopLoss Point;
        }
        
OrderModifyOrderTicket(), priceSLOrderTakeProfit(), 0CLR_NONE );
    }

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

Bookmarks

Tags
automated close order, close, eas, forex, learn mql4, learn mql4 video, mql4 learning, OrderCloseBy, profit, reach, secure profit function, T101_v1.11_orest_IBFXm.mq4

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Cycles For New Traders Dan7974 General Discussion 350 01-18-2008 07:04 PM
Learning to code for autotrading GoatT Metatrader Programming 8 01-10-2007 09:55 PM
Self learning expert mrtools Expert Advisors - Metatrader 4 32 10-22-2006 06:29 PM


All times are GMT. The time now is 08:05 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.