Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
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
  #1451 (permalink)  
Old 03-23-2009, 12:55 PM
Senior Member
 
Join Date: Feb 2006
Posts: 1,211
et_phonehome_2 is on a distinguished road
Thumbs up

Quote:
Originally Posted by luxinterior View Post
Look in the MetaEditor help for iopen and iclose

Lux
Thanks alot, its did the trick...

ET
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
  #1452 (permalink)  
Old 03-25-2009, 03:39 AM
Pip Pip is offline
Junior Member
 
Join Date: Dec 2005
Posts: 10
Pip is on a distinguished road
Code fix request

Hello,


I am trying to modify the attached indicator to perform the following:

1) make start date coincide with the color1, right now the indicator plots the second color (color2) of the series onto the start date and not the first

2) output the date, color, open, high, low, and close of each plotted line in the series. The file would be appended as new data becomes available.

Thank you for your help in advance.

Regards,
Attached Files
File Type: mq4 Moon Phases_with output.mq4 (4.1 KB, 15 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
  #1453 (permalink)  
Old 03-29-2009, 08:37 PM
Junior Member
 
Join Date: Jan 2009
Posts: 1
Beejay is on a distinguished road
Calc lowest low/use higher time frame trend/avoid spread problem

I'm trying to find some samples of coding that could provide for the following requirements:

In order to calculate placement of a stop I'd like to see coding that for any given time frame the EA could be told the LOWEST LOW (or highest high) during the last X number of bars...and then using THAT price less (or plus in the case of the highest high) X number of pips to set a stop level.

In order for any new short time frame order to be placed in the same direction as the trend of a larger time frame, I'd like to see coding that would allow new orders to be placed on the short time frame chart ONLY in the same direction as the trend of the larger time frame chart. As a simple example, assume an EA attached to a 15 minute chart wants to place a buy order on the crossing UP of MA1 over MA2 (with a stop placed as per the prior question at 5 pips below the lowest low of the last 5 bars) BUT I'm looking for coding that would only place that new order providing that on the one hour chart for that same pair, the current price is above (or below in the cases of a sell) an X period MA.

In order to avoid false openings/closings of orders due to unusual wide spreads, I'd like to see coding that would only trigger order action based on the CLOSE of the current (or even prior bar could be considered) rather than being triggered while a bar is still open. With IBFX for example I've seen spreads that were usually 5 pips often be as wide as 20 pips (and I once even saw 53 pips !). It seems that such wide spread action as often opened a new order because during the formation of the bar the MA's have temporarily crossed...but at the time the bar closed they had NOT crossed thereby leaving me with a buy order in place that was not wanted !

Any code samples to address of these things would be greatly appreciated.
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
  #1454 (permalink)  
Old 03-31-2009, 09:07 PM
bisecom's Avatar
Member
 
Join Date: Oct 2007
Location: Ukraine
Posts: 43
bisecom is on a distinguished road
EAs changing

Dear Coders' Guru and other Respected Coders,

Could you be so kind to help in the following, hope that it will not take a lot of your time and perhaps you will be able to use the files during your trading:
1. EA – YLA – originally it is Your Lucky 1a, I changed it a little bit to be “unknown” by brokers. Kindly add an option of hidden SL and fix a bug with time. Then I backtest it and set special time frame, it takes trades beyond the frame – what is incorrect.
2. E-trailing EA – help you to trail your orders. Its possible to set special TP value and then the EA trail your order thru “trailing step”. But it seams that trailing step is working starting from 5 pips. Is it possible to change the EA with purpose to set the trailing step starting from 1 pip?

Hope that you will be able to help,
Regards,

Bisecom.
Attached Files
File Type: mq4 e-Trailing_H_TP_SL.mq4 (15.5 KB, 10 views)
File Type: mq4 YLA.mq4 (22.7 KB, 17 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
  #1455 (permalink)  
Old 03-31-2009, 10:33 PM
Senior Member
 
Join Date: Nov 2008
Posts: 144
kawser is on a distinguished road
Dear coderguru,
It is may be the easiest work in coding to change the color.......I am unable to do it............

Just change the support in a color and resistance in different color of this code.......
Here resistance and support are in similar color.....................


And the objects do not deleted when the indicator is deleted.............

Thanx in advance.............
Attached Files
File Type: mq4 01support resistance.mq4 (8.5 KB, 18 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
  #1456 (permalink)  
Old 04-03-2009, 10:06 AM
Junior Member
 
Join Date: Aug 2008
Posts: 4
Howardcool is on a distinguished road
Help with Trailling Stop / 1 Risk or Position M

Hi all,

i have tried do search in the forum a solution for my Problem:

At the begin of my EA:
Code:
//---- buy conditions
      if(Ask > mybuyconditions) 
        {
         ticket=OrderSend(Symbol(),OP_BUY,LotsLong(),Ask,Spread,Bid-(Ask-lowestof10bars),((BBupper-BBlower)/(Ask-lowestof10bars))*1000,"Einstieg 1",magic+1,0,Green);         
        }
//---- sell conditions
      if(Bid < mysellconditions)
        {
         ticket=OrderSend(Symbol(),OP_SELL,LotsShort(),Bid,Spread,Ask+(highestof10bars-Bid),((BBupper-BBlower)/(highestof10bars-Bid))/100,"Einstieg -1",magic-1,0,Red);
        }
//----
Stopploss: its easy 10 bars hi/lo

Takeprofit: here i write my formula for my Trailingstop, and that is:

Take the differenz of BBupper - BBlower at the order open time. Then divide by StopLoss in Pips and you have an Factor. Then take the actual BB differenz and divide it by this Faktor. NOW WE HAVE OUR VOLA BB TRAILINGSTOPP!!!!!

SO, my big problem is now to save this FAKTOR!!!! I saved it in th Takeprofit of Ordersend, it works but it is not right!!!!!


And know the 2te Question:

Position Management:
so my order is open and i have my trailing stopp that trails : So and now if the trailingstop is > orderopenprice send next ORDER!!! It's logical because so i can always sicure to risk just my 1 R Risk.
.... if Trailingstopp is > orderopenprice of secondOrder send 3te order.


HERE MY EXAMPLES:

Code:
 for(int i = (OrdersTotal()-1); i >= 0; i--)

     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))       
         {
         if(OrderType()==OP_BUY && OrderMagicNumber() == magic+1)
          
          if(OrderStopLoss()< Bid-(oben-unten)/(OrderTakeProfit()/1000))
              {
               OrderModify(OrderTicket(),OrderOpenPrice(),High[iHighest(NULL, 0, MODE_HIGH,iBarShift(NULL, 0, OrderOpenTime()),0)]-(oben-unten)/(OrderTakeProfit()/1000),OrderTakeProfit(),0,Indigo);
               return;
              } 
          if(OrderStopLoss() > OrderOpenPrice() && CalculateCurrentOrders(Symbol()) == 1)
              {
               ticket1=OrderSend(Symbol(),OP_BUY,LotsLong(),Ask,Spread,Bid-(Ask-Low[iLowest(NULL, 0, MODE_LOW, StoppZrugg,0)]),((oben-unten)/(Ask-Low[iLowest(NULL, 0, MODE_LOW, StoppZrugg,0)]))*1000,"Einstieg 2",magic+2,0,Green);
               return;
              }
          
         }
          {
         if(OrderType()==OP_BUY && OrderMagicNumber() == magic+2 && CalculateCurrentAfterOrders(Symbol()) <= 1)
           {
          if(OrderStopLoss()<Bid-(oben-unten)/(OrderTakeProfit()/1000))
            {
             OrderModify(OrderTicket(),OrderOpenPrice(),High[iHighest(NULL, 0, MODE_HIGH,iBarShift(NULL, 0, OrderOpenTime()),0)]-(oben-unten)/(OrderTakeProfit()/1000),OrderTakeProfit(),0,Indigo);
             return;
            }
          if(OrderStopLoss() > OrderOpenPrice() && CalculateCurrentOrders(Symbol()) == 2)
             {
              ticket2=OrderSend(Symbol(),OP_BUY,LotsLong(),Ask,Spread,Bid-(Ask-Low[iLowest(NULL, 0, MODE_LOW, StoppZrugg,0)]),((oben-unten)/(Ask-Low[iLowest(NULL, 0, MODE_LOW, StoppZrugg,0)]))*1000,"Einstieg 3",magic+3,0,Green);
              return;
             } 
           }
         { 
         if(OrderType()==OP_BUY && OrderMagicNumber() == magic+3 && CalculateCurrentAfterOrders(Symbol()) <= 2) 
          {
             if(OrderStopLoss()< Bid-(oben-unten)/(OrderTakeProfit()/1000))
            {
             OrderModify(OrderTicket(),OrderOpenPrice(),High[iHighest(NULL, 0, MODE_HIGH,iBarShift(NULL, 0, OrderOpenTime()),0)]-(oben-unten)/(OrderTakeProfit()/1000),OrderTakeProfit(),0,Indigo);
             return;
            }
          }       
         }
        }

Code:
 if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))       
        { 
         if(OrderType()==OP_BUY && OrderMagicNumber() == magic+1)
          {
              {
               OrderModify(OrderTicket(),OrderOpenPrice(),High[iHighest(NULL, 0, MODE_HIGH,iBarShift(NULL, 0, OrderOpenTime()),0)]-(oben-unten)/(OrderTakeProfit()/1000),OrderTakeProfit(),0,Indigo);
               return;
              } 
           if(OrderStopLoss() >= OrderOpenPrice() && CalculateCurrentOrders(Symbol()) == 1)
              {
               ticket1=OrderSend(Symbol(),OP_BUY,LotsLong(),Ask,Spread,0,0,"Einstieg 2",magic+2,0,Green);
               return;
              }
           }
         if(OrderType()==OP_BUY && OrderMagicNumber() == magic+2)
          {
          if(OrderStopLoss() >= OrderOpenPrice() && CalculateCurrentOrders(Symbol()) == 2)
             {
              ticket2=OrderSend(Symbol(),OP_BUY,LotsLong(),Ask,Spread,0,0,"Einstieg 3",magic+3,0,Green);
              return;
             }
           }
         }
         {
         if(OrderType()==OP_BUY && OrderMagicNumber() == magic+2)  
          {
          if(CalculateCurrentOrders(Symbol()) == 0)  
             {
             OrderClose(ticket1,OrderLots(),Ask,Spread,Red); return;
             }
          }
          }         
          if(OrderType()==OP_BUY && OrderMagicNumber() == magic+3)
             {
             OrderClose(i,OrderLots(),Ask,Spread,Red); return;
             }

I hope someone can help me with this problem!!!!! Thanks to all.
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
  #1457 (permalink)  
Old 04-03-2009, 01:19 PM
Senior Member
 
Join Date: Sep 2008
Posts: 106
Fx Referee is on a distinguished road
Need help

Dear Coderguru and other respected coders,

Please, can you kindly help me to develop an alert on this indicator ( levelstop-Reverse-vB0-4). That is at the arrow(s) point. I'm sorry for any inconvience.

Thank a million
Attached Files
File Type: mq4 MT4-LevelStop-Reverse-vB0-4.mq4 (11.7 KB, 13 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
  #1458 (permalink)  
Old 04-03-2009, 02:38 PM
bershk's Avatar
Junior Member
 
Join Date: Oct 2008
Posts: 3
bershk is on a distinguished road
Library cglib.mq4

Dear coderguru,
Sonetime ago you developed library cglib.mq4 which contains some useful functions particularly shell functions which allows to generate phone call using skype. And I can't find it published anywhere. Could you please make it available?

Thank you
Victor
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
  #1459 (permalink)  
Old 04-07-2009, 01:35 AM
Junior Member
 
Join Date: Sep 2008
Location: US
Posts: 10
AceFX is on a distinguished road
In need of a little help - Close then open on same candle

Hello!

I have been working on a new expert and have been learning a lot and making pretty good progress with what I am trying to accomplish but have been stuck with this one major problem for the last few days and can not for the life of me get it right. I know you all get a lot of requests and do your best to help people out and I can not tell you how much I appreciate this!

Anyway, none of the EA's that I program using the Expert Advisor Builder (not to the point where I can write the code myself..) seem to want to open a reverse position after closing another on the same candle even when all conditions are met. I made a simple MA cross EA just to make sure this problem was not with my Buy or Sell conditions for my expert but was the default setting for the coding program. I do not want to add a stop and revese function because the Close (buy) and Close (sell) conditions are not exactly the same as the Sell or Buy, though they are very similar.

For simplicity sake I have attached a simple MA cross EA here that is written using the same source and has the same basic template as the one I am actually trying to fix but is less cluttered and an easier read. If there is anybody who could give me a hand or point me in the right direction by fixing this to be able to open a new trade immediately after closing the prior trade I can not describe how thankful I would be!!

Thanks!!
Attached Files
File Type: mq4 MA TEST EA.mq4 (10.6 KB, 15 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
  #1460 (permalink)  
Old 04-07-2009, 01:56 AM
Junior Member
 
Join Date: Feb 2006
Posts: 4
wyobenjamin is on a distinguished road
Same Candle Error

AceFX-

I think your trade logic is waiting for a new bar to execute a trade because of this piece of code in the entry conditions:

Bars != BarCount

The Exit conditions update the BarCount so, for in order for Bars!=BarCount to be true, a new bar has to be painted.

You could add something to the Exit logic to track the Type of trade that was just closed and then use that to override your Bars!=BarCount restriction.

For instance after the OrderClose() function to close an OP_BUY order you could add:
int LastType=1;

Then in the Entry Logic for the Sell Order you could add:
Code:
(Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount || LastType==1))))
Just a thought....
-Ben
__________________
FX Robot Man - Live Demo Statements
http://www.fxrobotman.com
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
forex, histogram, JMASlope, ToR 1.20, ZUP_v1.mq4


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


All times are GMT. The time now is 06:56 AM.



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