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
  #1871 (permalink)  
Old 06-30-2009, 11:34 AM
mladen's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,270
mladen is on a distinguished road
To smb1970 - this is it :
PHP Code:
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1  Red
#property indicator_maximum 100
#property indicator_minimum   0

//
//
//
//
//

extern int    OscPeriod  8;
extern int    OscPrice   PRICE_CLOSE;

double oscBuffer[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   
SetIndexBuffer(0,oscBuffer);
   
IndicatorShortName("Osc ("+OscPeriod+")");
   return(
0);
}
int deinit() { return(0); }
int start()
{
   
int counted_bars=IndicatorCounted();
   
int i,limit;
   
   if(
counted_bars<0) return(-1);
   if(
counted_bars>0counted_bars--;
           
limit=Bars-counted_bars;

   
//
   //
   //
   //
   //
   
   
for(i=limiti>=0i--)
   {
      
double price iMA(NULL,0,1,0,MODE_SMA,OscPrice,i);
      
double high  High[ArrayMaximum(High,OscPeriod,i)];
      
double low   Low[ArrayMinimum(Low,OscPeriod,i)];
      
      
//
      //
      //
      //
      //

      
if (high!=low)
         
double raw 100.00*(price-low)/(high-low);
      else      
raw =   0.00;         
      
oscBuffer[i]= oscBuffer[i+1]*2.0/3.0 raw/3.0;      
   }
   return(
0);

But, take a look at the picture too : upper is "Oscar" lower is Ema(5) of stochastic(8), or to make it even simpler, on the bottom is Stochastic(8,5,1) with signal line set to exponential. So "Oscar" is simply a signal line of the stochastic
Attached Images
File Type: gif oscar.gif (20.5 KB, 76 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
  #1872 (permalink)  
Old 06-30-2009, 02:01 PM
smb1970's Avatar
Junior Member
 
Join Date: Jan 2009
Posts: 3
smb1970 is on a distinguished road
Thanks!

Thanks mladen, not only is that very useful, it's also very revealing!
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
  #1873 (permalink)  
Old 07-02-2009, 02:22 PM
Junior Member
 
Join Date: Jun 2009
Posts: 3
rortiz77 is on a distinguished road
Unhappy NewB in need of some help with coding :-(

Hi All,

I'm in need of some disparate help here. I've got some code that will look for an agreement between different indicators. Once they all agree I want a way for the trades to enter in the way I described it in the chart images. So far I can enter the 1st "Buy" trade but it doesn't enter just 1 trade....it's entering up to 8 trades. And then, if the market goes against me I enter a "contingency trade" where I'm buy/selling again despite that its going against me. I would greatly appreciate if someone could show me what the correct code should look like

Not sure if these images will show but just in case I also have them as attachments.



Here is my flawed code that is supposed to execute the trade...
while (execute_trade ==5)
{if ( OrdersTotal() == buy_trade1 ) //buy_trade1 = 1...this stops it after 1 order have been placed...but doesnt work yet
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
execute_trade=0;

if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("My ticket is: " , ticket);
{
buy1 = OrderOpenPrice(); //taking the 1st order's price and pushing it into this variable
// Comment("order #1 open price is ", OrderOpenPrice() + " " + buy1 + " less than " + (buy1-0.0030));
if (buy1 >= (buy1-0.0030))
{
//if ( OrdersTotal() <= buy_trade1 ) //this stops it after 1 order have been placed.
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
//execute_trade=0;
}


}
else
Print("OrderSelect returned the error of ",GetLastError());

}
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
  #1874 (permalink)  
Old 07-02-2009, 03:27 PM
Junior Member
 
Join Date: Jun 2009
Posts: 3
rortiz77 is on a distinguished road
Unhappy NewB in need of some help with coding

Hi All,

I'm in need of some disparate help here. I've got some code that will look for an agreement between different indicators. Once they all agree I want a way for the trades to enter in the way I described it in the chart images. So far I can enter the 1st "Buy" trade but it doesn't enter just 1 trade....it's entering up to 8 trades. And then, if the market goes against me I enter a "contingency trade" where I'm buy/selling again despite that its going against me. I would greatly appreciate if someone could show me what the correct code should look like

Not sure if these images will show but just in case I also have them as attachments.
Pic 1
Pic 2

Here is my flawed code that is supposed to execute the trade...
while (execute_trade ==5)
{if ( OrdersTotal() == buy_trade1 ) //buy_trade1 = 1...this stops it after 1 order have been placed...but doesnt work yet
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
execute_trade=0;

if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("My ticket is: " , ticket);
{
buy1 = OrderOpenPrice(); //taking the 1st order's price and pushing it into this variable
// Comment("order #1 open price is ", OrderOpenPrice() + " " + buy1 + " less than " + (buy1-0.0030));
if (buy1 >= (buy1-0.0030))
{
//if ( OrdersTotal() <= buy_trade1 ) //this stops it after 1 order have been placed.
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
//execute_trade=0;
}


}
else
Print("OrderSelect returned the error of ",GetLastError());

}
Attached Images
File Type: jpg the perfect buy and sell.jpg (117.6 KB, 101 views)
File Type: jpg Contingency Trades 2.jpg (155.3 KB, 91 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
  #1875 (permalink)  
Old 07-02-2009, 06:24 PM
SPACECHIMP's Avatar
Member
 
Join Date: Feb 2006
Location: West Michigan, USA.
Posts: 86
SPACECHIMP is on a distinguished road
int start()
{
int total,ord,i;

string symbol;

total = OrdersTotal();

for(i=0;i<total;i++)

{

OrderSelect(i,SELECT_BY_POS);

if(OrderSymbol() = Symbol())ord++;

}

if(ord>0) return (0); //Abort! A Position For This Pair is Already Open

//the rest of my program code

}

I've found in reality, I've had to use pauses for a couple seconds in the code due to brokers not instantly opening positions.
__________________
www.LiveTeamTrading.com
The FIRST LIVE Team trading Network Community for FOREX TRADERS! Ask me about Getting an Invite!
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
  #1876 (permalink)  
Old 07-02-2009, 06:27 PM
SPACECHIMP's Avatar
Member
 
Join Date: Feb 2006
Location: West Michigan, USA.
Posts: 86
SPACECHIMP is on a distinguished road
Want to open 1 POSITION in a direction but No more even if position hits TP.

Checking for open position won't work obviously.

Example-
I don't want another 'BUY' to execute if i had a buy open and it hit the TP. I want it to wait until the MA's cross down and open a SELL with a TP and repeat the whole thing over again.

There's probably an easy way to do this buy my brain is fried or something

THANK YOU
__________________
www.LiveTeamTrading.com
The FIRST LIVE Team trading Network Community for FOREX TRADERS! Ask me about Getting an Invite!
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
  #1877 (permalink)  
Old 07-02-2009, 07:40 PM
Junior Member
 
Join Date: Jun 2009
Posts: 3
rortiz77 is on a distinguished road
Thanks for the info...

Quote:
Originally Posted by SPACECHIMP View Post
int start()
{
int total,ord,i;

string symbol;

total = OrdersTotal();

for(i=0;i<total;i++)

{

OrderSelect(i,SELECT_BY_POS);

if(OrderSymbol() = Symbol())ord++;

}

if(ord>0) return (0); //Abort! A Position For This Pair is Already Open

//the rest of my program code

}

I've found in reality, I've had to use pauses for a couple seconds in the code due to brokers not instantly opening positions.
Thank you for taking your time to show me this code! I don't think my screen shots were sufficient to explain the logic of what I'm trying to achieve. Here's the explanation in witting...and just as an example I am using a "Buy" scenario. Eventually I would like it to do both "Buy" and "Sell"

Scenario 1: If your buy trade goes with you...
--Trade 1, T/P at 70 pips
--Trade 2, 30 pips appart from trade 1, T/P at 70 pips
--Trade 3, 30 pips away from trade 2, T/P at 70 pips
** 210 pips total

Scenario 2: If your buy trade goes against you...put in a trade every 60 pips for three trades and wait for the market to pull back in your direction
--trade 1 bad...enter new contingency buy trade at -60 pips from the price of trade 1.
--trade 2 bad...enter new contingency buy trade at -60 pips from the price of trade 2.
--trade 3 bad...enter no more trades
--wait for reversal signs...parabolic dot = bottom...if looks like its moving in our direction then enter a 4th buy
--wait 30 more positive pips then enter 5th buy trade...continue to enter buy trades (6, 7, 8 trade) until it reaches the level that the 3rd contingency trade was at....then wait for the original first 1, and follow the steps of scenario 1.

Is it possible to get the code for this logic? I would be greatly appreciative!!!
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
  #1878 (permalink)  
Old 07-03-2009, 01:52 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Quote:
Originally Posted by SPACECHIMP View Post
Want to open 1 POSITION in a direction but No more even if position hits TP.

Checking for open position won't work obviously.

Example-
I don't want another 'BUY' to execute if i had a buy open and it hit the TP. I want it to wait until the MA's cross down and open a SELL with a TP and repeat the whole thing over again.

There's probably an easy way to do this buy my brain is fried or something

THANK YOU
You need to check your order history to see if an order just closed on the current bar for profit.

Hope that helps.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
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
  #1879 (permalink)  
Old 07-03-2009, 02:09 PM
dr.house7's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Italy
Posts: 186
dr.house7 is on a distinguished road
Question RSI filter pete

Hello everyone...
i tried to create a simple ea for this indy (rsi filter pete) but after compile, when i launch a backtest nothing happen

i want only

1-buy on green or light green
2-and sell on red or light red

So i ask to some kindly people to help me on this

Thanks in advance
Attached Images
File Type: png rsi filter pete.png (26.4 KB, 73 views)
Attached Files
File Type: mq4 EA rsi filter pete.mq4 (9.6 KB, 11 views)
File Type: mq4 RSIFilter_pete.mq4 (3.4 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
  #1880 (permalink)  
Old 07-04-2009, 08:36 PM
Junior Member
 
Join Date: Jul 2009
Posts: 1
qu33nrock is on a distinguished road
MM for EA plz

i want add this condition to my ea
if loss in curent day = 100 ---> close al position, dont take any OP until tomorow

if loss in curent day < 100 ---> may take any OP

anybody can help ???

this my EA

Code:
//+------------------------------------------------------------------+
/*
          EA Dengan sinyal dari signal ma
*/

extern double Lots = 0.01;





//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double a1,      //ma 10 tf 4h
          a2,      //ma 10 tf 1h
          a3,      //ma 10 tf 15m
          a4,      //ma 10 tf 5m
          
          j,      //yesterday low price 
          k,      //yesterday high price
          
          b1,     //ma 30 tf 4h
          b2,     //ma 30 tf 1h
          b3,     //ma 30 tf 15m
          b4;     //ma 30 tf 5m
          
   int cnt, ticket, total;

   if(Bars<100)
     {
      Print("bars less than 100");
      return(0);  
     }

// to simplify the coding and speed up access
// data are put into internal variables
   a1 = iMA(NULL,240,10,0,MODE_EMA,PRICE_CLOSE,0);
   a2 = iMA(NULL,60,10,0,MODE_EMA,PRICE_CLOSE,0);
   a3 = iMA(NULL,15,10,0,MODE_EMA,PRICE_CLOSE,0);
   a4 = iMA(NULL,5,10,0,MODE_EMA,PRICE_CLOSE,0);
   
   b1 = iMA(NULL,240,30,0,MODE_EMA,PRICE_CLOSE,0);
   b2 = iMA(NULL,60,30,0,MODE_EMA,PRICE_CLOSE,0);
   b3 = iMA(NULL,15,30,0,MODE_EMA,PRICE_CLOSE,0);
   b4 = iMA(NULL,5,30,0,MODE_EMA,PRICE_CLOSE,0);  
   
   j = iLow(NULL,60,2);
   k = iHigh(NULL,60,2);

   total=OrdersTotal();
   if(total<1) 
     {
      // no opened orders identified
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);  
        }
      // check for long position (BUY) possibility
      if(a1>b1&&
         a2>b2&&
         a3>b3&&
         a4>b4+10*Point)
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"macd sample",16384,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
           }
         else Print("Error opening BUY order : ",GetLastError()); 
         return(0); 
        }
      // check for short position (SELL) possibility
      if(a1<b1&&
         a2<b2&&
         a3<b3&&
         a4<b4-10*Point)
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"macd sample",16384,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
           }
         else Print("Error opening SELL order : ",GetLastError()); 
         return(0); 
        }
      return(0);
     }
   // it is important to enter the market correctly, 
   // but it is more important to exit it correctly...   
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
            // should it be closed?
            if(Bid>OrderOpenPrice()+100*Point)//if profit > 100
               {
                 OrderModify(OrderTicket(),OrderOpenPrice(),j,0,0,Green);
                 return(0);
               }
               if(Bid<OrderOpenPrice()-150*Point)//stop loss
               {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                 return(0); // exit
               }
                        
           }
         else // go to short position
           {
            // should it be closed?
            if(Ask<OrderOpenPrice()-100*Point)//if profit > 100
               {
                 OrderModify(OrderTicket(),OrderOpenPrice(),k,0,0,Green);
                 return(0);
               }
            if(Ask>OrderOpenPrice()+150*Point)//stop loss
               {
                 OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
               return(0); // exit
               }
           
            
           }
        }
     }
   return(0);
  }
// the end.
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 12:52 AM.



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