Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #121 (permalink)  
Old 06-25-2006, 03:14 AM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
PHP Code:
if(AccountEquity()<AccountBalance()) { 
{
  
int ttotal OrdersTotal();
  for(
int i=ttotal-1;i>=0;i--)
  {
    
OrderSelect(iSELECT_BY_POS);
    
int type   OrderType();

    
bool result false;
    
    switch(
type)
    {
      
//Close opened long positions
      
case OP_BUY       result OrderCloseOrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5Red );
                          break;
      
      
//Close opened short positions
      
case OP_SELL      result OrderCloseOrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5Red );
                          
    }
    
    if(
result == false)
    {
      
Alert("Order " OrderTicket() , " failed to close. Error:" GetLastError() );
      
Sleep(3000);
    }  
  }
  
  return(
0);
}
}

ok this is what I tried ..it's mostly copied from another code someone else here made...but it's just closing everything as fast as they open and not paying any attention to the 'if' condition before executing closes....oy I'm not good at this....I obviously don't have the part that is doing the closing of orders sufficiently attached to the conditional line that compares the account equity to the account balance. Could someone please help me with this?

Last edited by Aaragorn; 06-25-2006 at 04:42 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #122 (permalink)  
Old 06-25-2006, 06:35 AM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
upon closer inspection it appears that what I have IS working and behaving exactly like a stop loss.

when I add this to it...

if(AccountEquity()+8<AccountBalance())

it behaves exactly like a stop loss at 8


so at least I've done the code right for once eh? Sadlly it's not producing the effect I wanted in the EA. It's messing with the winners who need the stop loss wider to work too. victory and defeat all at the same time...ok so be it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #123 (permalink)  
Old 06-25-2006, 11:16 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Code debugging issue...trailing stop trigger..coders wanted

PHP Code:
for(cnt=0;cnt<total;cnt++) {
OrderSelect(cntSELECT_BY_POSMODE_TRADES);
if(
OrderType()<=OP_SELL && OrderSymbol()==Symbol()) {
if(
OrderType()==OP_BUY){
if(
TrailingStop>0) {
if(
Bid-OrderOpenPrice()>Point*TrailingStopTrigger) {
if(
OrderStopLoss()<Bid-Point*TrailingStop) {
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(
0);
}
}
}
}else{
if(
TrailingStop>0) {
if((
OrderOpenPrice()-Ask)>(Point*TrailingStopTrigger)) {
if((
OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) {
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(
0); 
I'm still learning code. This is supposed to trigger a trailing stop to engage as a specified level. I can see from some test results that it didn't trigger when it should have.

I'm wondering if this is written correctly as 'Point*TrailingStopTrigger' is it supposed to multiply or simply add the value of the TrailingStopTrigger to Point for sell positions and subtract if for buy positions. Is that why it's not triggering like it's supposed to? Or is there something else?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #124 (permalink)  
Old 06-25-2006, 11:59 PM
BluePearl's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 206
BluePearl is on a distinguished road
do you have an fxdd demo? if so change the color to 0.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #125 (permalink)  
Old 06-26-2006, 12:31 AM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Quote:
Originally Posted by BluePearl
do you have an fxdd demo? if so change the color to 0.
i'm using interbankFX demo. would the color thing prevent it from triggering?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #126 (permalink)  
Old 06-26-2006, 01:09 AM
BluePearl's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 206
BluePearl is on a distinguished road
try it with ibfx. i know it's an issue with fxdd if you use the color name in a modify order command.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #127 (permalink)  
Old 06-26-2006, 04:06 AM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
It doesn't seem to change the results. I may have been mistaken in assuming that it should have triggered.

I have 4 reports attached. The only difference between them is the size of the stop loss. This tells me that alot of retracement is going on. That doesn't mean that I want to allow losers to play out to the full stop loss if I can shut them down based on some additional rule that doesn't disproportionally detract from the winners.

Looking at the results from the 186 stop loss report, and looking back at the charts of these 5 losers at their entries. 4 out of 5 of them the bar immediately after opening the position the next bar closed against the position. I don't know if some sort of rule like that could be added like a stop loss to close positions if the very next bar after the position opens goes against it to close the position would work or not. It would have stopped 4 of 5 losers that remained but I don't know how many of the winners it would have also shut down.

I don't know how that kind of rule would be programmed. I just manually walked thru the first 20 trades and it would have shut down 15 of 20 so that won't help.

I'm open for suggestions.
Attached Files
File Type: htm whatever@.4SL186.htm (117.5 KB, 91 views)
File Type: htm whatever@.4SL125.htm (110.5 KB, 28 views)
File Type: htm whatever@.4SL50.htm (79.7 KB, 29 views)
File Type: htm whatever@.4SL20.htm (51.2 KB, 32 views)

Last edited by Aaragorn; 06-26-2006 at 04:44 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #128 (permalink)  
Old 06-28-2006, 02:26 AM
Senior Member
 
Join Date: Apr 2006
Posts: 201
scott TTM is on a distinguished road
Someone PLEASE code these from TS for me...

Hi,

Can anyone please code the following indicators for me? They are written in TradeStation's (not)Easylanguage.

if you have trouble then PM/email me

i know it's a LOT of work but will be well worth it once whomever codes it knows what method it is...

SB
Attached Files
File Type: zip Indicators and Functions.zip (28.6 KB, 124 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #129 (permalink)  
Old 06-28-2006, 03:44 AM
Senior Member
 
Join Date: Mar 2006
Posts: 793
Maji is on a distinguished road
Before any one takes up that task, can you explain what the strategies are and give some details, url references for them. If it is an winning strategy, then someone will take up the challenge. Otherwise, why would anyone spend their time translating.

Thanks,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #130 (permalink)  
Old 07-13-2006, 05:27 PM
Senior Member
 
Join Date: Nov 2005
Posts: 105
fxd01 is on a distinguished road
Angry Why doesn't this code work?

I'm trying to write a piece of code that will modify the TP of allexisting trades. When I attach the code to a chart, it works only for the currency where the expert is attached. It does not modify other trades from other currency pairs. Please note that I'm not checking the OrderSymbol()==Symbol() in my code. Where is the mistake? Do I have to add a "return(0)" after each OrderModify()? Can you help me?

Does the expert allow me to open/close/modify trades of a different currency pair while the expert is attached only to a single chart? I'm trying to write a universal code that will process (ie, either modify or close) all existing trades regardless of the chart where the EA is attached to. Can someone please confirm if this is possible at all? If yes, then what is wrong with the following code?



int mTrades=OrdersTotal();
if (mTrades>0)
{
for (i=0;i<mTrades;i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUY)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), Ask+100*Point, White);
}
if (OrderType() == OP_SELL)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), Bid-100*Point, White);
}
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 05:22 PM


All times are GMT. The time now is 08:22 AM.



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