|
|||
|
|||||||
| Notices |
| 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 |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|||
|
hi
thanks very much all friends , specific Roger09 I want expert (automatic trade) ForexFreedomBars . when square 5m , 15m ,30m ,1H is Red , send order SELL by 10-20 TP when square 5m , 15m ,30m ,1H is Blue , send order BUY by 10-20 TP (TP, SL , lot, maxtrade) ability have to change please help me . //+------------------------------------------------------------------+ //| #The Forex Freedom Bars //| //+------------------------------------------------------------------+ #property copyright "Programmed by Eli hayun" #property indicator_separate_window #property indicator_minimum -0.5 //#property indicator_maximum 5 #property indicator_buffers 8 #property indicator_color1 Red #property indicator_color2 DodgerBlue #property indicator_color3 Red #property indicator_color4 DodgerBlue #property indicator_color5 Red #property indicator_color6 DodgerBlue #property indicator_color7 Red #property indicator_color8 DodgerBlue //---- buffers double buf4_up[]; double buf4_down[]; double buf3_up[]; double buf3_down[]; double buf2_up[]; double buf2_down[]; double buf1_up[]; double buf1_down[]; extern double Gap = 1; // Gap between the lines of bars extern int Period_1 = PERIOD_M5;//M15 extern int Period_2 = PERIOD_M15;//M30 extern int Period_3 = PERIOD_M30;//H1 extern int Period_4 = PERIOD_H1;//H4 extern int cci_1 = 2;//50 extern int cci_2 = 2;//14 extern int cci_3 = 2; extern int cci_4 = 2; extern int StopLoss=100; extern int TakeProfit=100; extern double Lots=0.1; extern bool AutoDisplay = false; string shortname = ""; bool firstTime = true; int UniqueNum = 228; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetAutoDisplay(); shortname = "# Forex Freedom("+Period_1+","+Period_2+","+Period_3+","+P eriod_4+")"; firstTime = true; IndicatorShortName(shortname); //---- indicators SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,110); SetIndexBuffer(0,buf4_up); SetIndexEmptyValue(0,0.0); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,110); SetIndexBuffer(1,buf4_down); SetIndexEmptyValue(1,0.0); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,110); SetIndexBuffer(2,buf3_up); SetIndexEmptyValue(2,0.0); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,110); SetIndexBuffer(3,buf3_down); SetIndexEmptyValue(3,0.0); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,110); SetIndexBuffer(4,buf2_up); SetIndexEmptyValue(4,0.0); SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5,110); SetIndexBuffer(5,buf2_down); SetIndexEmptyValue(5,0.0); SetIndexStyle(6,DRAW_ARROW); SetIndexArrow(6,110); SetIndexBuffer(6,buf1_up); SetIndexEmptyValue(6,0.0); SetIndexStyle(7,DRAW_ARROW); SetIndexArrow(7,110); SetIndexBuffer(7,buf1_down); SetIndexEmptyValue(7,0.0); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- SetAutoDisplay(); shortname = "# Forex Freedom("+Period_1+","+Period_2+","+Period_3+","+P eriod_4+")"; firstTime = true; //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int i=0, y5m=0, y1h=0, y30m=0, y15m=0, yy; int limit=Bars-counted_bars; datetime TimeArray_1H[], TimeArray_30M[], TimeArray_15M[], TimeArray_5M[]; //---- if (firstTime || NewBar()) { firstTime = false; int win = UniqueNum; // WindowFind(shortname); double dif = Time[0] - Time[1]; for (int ii=ObjectsTotal()-1; ii>-1; ii--) { if (StringFind(ObjectName(ii),"FF_"+win+"_") >= 0) ObjectDelete(ObjectName(ii)); else ii=-1; } double shift = 0.2; for (ii=0; ii<4; ii++) { string txt = "??"; double gp; switch (ii) { case 0: txt = tf2txt(Period_1); gp = 1 + shift; break; case 1: txt = tf2txt(Period_2); gp = 1 + Gap + shift; break; case 2: txt = tf2txt(Period_3); gp = 1 + Gap*2 + shift; break; case 3: txt = tf2txt(Period_4); gp = 1 + Gap*3 + shift; break; } string name = "FF_"+win+"_"+ii+"_"+txt; ObjectCreate(name, OBJ_TEXT, WindowFind(shortname), iTime(NULL,0,0)+dif*3, gp); ObjectSetText(name, txt,8,"Arial", Silver); } } ArrayCopySeries(TimeArray_1H,MODE_TIME,Symbol(),Pe riod_4); ArrayCopySeries(TimeArray_30M,MODE_TIME,Symbol(),P eriod_3); ArrayCopySeries(TimeArray_15M,MODE_TIME,Symbol(),P eriod_2); ArrayCopySeries(TimeArray_5M,MODE_TIME,Symbol(),Pe riod_1); for(i=0, y5m=0, y1h=0, y30m=0, y15m=0;i<limit;i++) { if (Time[i]<TimeArray_5M[y5m]) y5m++; if (Time[i]<TimeArray_1H[y1h]) y1h++; if (Time[i]<TimeArray_30M[y30m]) y30m++; if (Time[i]<TimeArray_15M[y15m]) y15m++; int cci_n = cci_1; for (int tf = 0; tf < 4; tf++) { int prd; switch (tf) { case 0: prd = Period_1; cci_n = cci_1; yy = y5m; break; case 1: prd = Period_2; cci_n = cci_2; yy = y15m; break; case 2: prd = Period_3; cci_n = cci_3; yy = y30m; break; case 3: prd = Period_4; cci_n = cci_4; yy = y1h; break; } double cci = iCCI(NULL, prd, cci_n,PRICE_TYPICAL, yy); double dUp = EMPTY_VALUE; // iCustom(NULL, prd, "SuperTrend", false, 1, yy); double dDn = EMPTY_VALUE; //iCustom(NULL, prd, "SuperTrend", false, 0, yy); if (cci < 0) dUp = 1; else dDn = 1; switch (tf) { case 0: if (dUp == EMPTY_VALUE) buf1_down[i] = 1; else buf1_up[i] = 1; break; case 1: if (dUp == EMPTY_VALUE) buf2_down[i] = 1 + Gap * 1; else buf2_up[i] = 1 + Gap * 1; break; case 2: if (dUp == EMPTY_VALUE) buf3_down[i] = 1 + Gap * 2; else buf3_up[i] = 1 + Gap * 2; break; case 3: if (dUp == EMPTY_VALUE) buf4_down[i] = 1 + Gap * 3; else buf4_up[i] = 1 + Gap * 3; break; } if (NewBar()) { string sDir = ""; if (buf1_up[0] + buf2_up[0] + buf3_up[0] + buf4_up[0] == 4) sDir = "Up"; if (buf1_down[0] + buf2_down[0] + buf3_down[0] + buf4_down[0] == 4) sDir = "Down"; if (sDir != "") { PlaySound("alert1.wav"); Print("Forex freeway - Direction ",sDir); } } } } if (buf1_up[0] + buf2_up[0] + buf3_up[0] + buf4_up[0] == 4) OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss ,TakeProfit); else return(0); } //+------------------------------------------------------------------+ string tf2txt(int tf) { if (tf == PERIOD_M1) return("M1"); if (tf == PERIOD_M5) return("M5"); if (tf == PERIOD_M15) return("M15"); if (tf == PERIOD_M30) return("M30"); if (tf == PERIOD_H1) return("H1"); if (tf == PERIOD_H4) return("H4"); if (tf == PERIOD_D1) return("D1"); if (tf == PERIOD_W1) return("W1"); if (tf == PERIOD_MN1) return("MN1"); return("??"); } void SetValues(int p1, int p2, int p3, int p4) { Period_1 = p1; Period_2 = p2; Period_3 = p3; Period_4 = p4; } void SetAutoDisplay() { if (AutoDisplay) { switch (Period()) { case PERIOD_M1 : SetValues(PERIOD_M1, PERIOD_M5, PERIOD_M15,PERIOD_M30); break; case PERIOD_M5 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30,PERIOD_H1); break; case PERIOD_M15 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30,PERIOD_H1); break; case PERIOD_M30 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30, PERIOD_H1); break; case PERIOD_H1 : SetValues(PERIOD_M15, PERIOD_M30,PERIOD_H1, PERIOD_H4); break; case PERIOD_H4 : SetValues(PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1); break; case PERIOD_D1 : SetValues(PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1); break; case PERIOD_W1 : SetValues(PERIOD_H4, PERIOD_D1, PERIOD_W1,PERIOD_MN1); break; case PERIOD_MN1 : SetValues(PERIOD_H4, PERIOD_D1, PERIOD_W1,PERIOD_MN1); break; } } } bool NewBar() { static datetime dt = 0; if (Time[0] != dt) { dt = Time[0]; return(true); } return(false); } |
|
|||
|
You can not use indicator as a advisor, you have to use advisor with indicator, like this:
P.S. Don't forget put the indicator to indicator directory. |
|
|||
|
I have an EA built for the "Instant Execution" version of Metatrader4 and I need someone to change the code so it will work on a "Market Execution" version of Metatrader4. Please email me a quote or or any questions to phasna@gmail.com
Thanks Paul |
|
||||
|
Quote:
|
|
|||
|
Help me place trades in between the spreads!
Ok, spreads kill some pairs. but is theire away to place trades in the middle of a spreads. This way we can save pips and make more money. i have this code and can it be changed to modify the order to chart price not bid ask?
void PlaceBuyOrder() { double BuyOrders, Lots; double LowestBuy = 1000, HighestBuy; if (BarTime != Time[0]) { BarTime = Time[0]; TickPrice = 0; TradeAllowed = true; } RefreshRates(); for (Order = OrdersTotal() - 1; Order >= 0; Order--) { if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_BUY) { if (OrderOpenPrice() < LowestBuy) LowestBuy = OrderOpenPrice(); if (OrderOpenPrice() > HighestBuy) HighestBuy = OrderOpenPrice(); BuyOrders++; } } } if (TradeAllowed) { if (Ask >= HighestBuy + (TrendSpacing * Point)) { // if (Multiplier) if (Multiplier == 1) Lots = NormalizeDouble(LotSize * MathPow(LotIncrement, BuyOrders), 2); else Lots = NormalizeDouble(LotSize + (LotIncrement * BuyOrders), 2); } if (Ask <= LowestBuy - (Spacing * Point)) { // if (Multiplier) if (Multiplier == 1) Lots = NormalizeDouble(LotSize * CounterTrendMultiplier * MathPow(LotIncrement, BuyOrders), 2); else Lots = NormalizeDouble((LotSize * CounterTrendMultiplier) + (LotIncrement * BuyOrders), 2); } if (Lots == 0) { // if (Multiplier) if (Multiplier == 1) Lots = NormalizeDouble(LotSize, 2); else Lots = NormalizeDouble(LotSize, 2); } OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, TradeComment, Reference, Green); Error = GetLastError(); if (Error != 0) Write("Error opening BUY order: " + ErrorDescription(Error) + " (C" + Error + ") Ask:" + Ask + " Slippage:" + Slippage); else { TickPrice = Close[0]; TradeAllowed = false; } } } void PlaceSellOrder() { double SellOrders, Lots; double HighestSell, LowestSell = 1000; if (BarTime != Time[0]) { BarTime = Time[0]; TickPrice = 0; TradeAllowed = true; } RefreshRates(); for (Order = OrdersTotal() - 1; Order >= 0; Order--) { if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_SELL) { if (OrderOpenPrice() > HighestSell) HighestSell = OrderOpenPrice(); if (OrderOpenPrice() < LowestSell) LowestSell = OrderOpenPrice(); SellOrders++; } } } if (TradeAllowed) { if (Bid <= LowestSell - (TrendSpacing * Point)) { // if (Multiplier) if (Multiplier == 1) Lots = NormalizeDouble(LotSize * MathPow(LotIncrement, SellOrders), 2); else Lots = NormalizeDouble(LotSize + (LotIncrement * SellOrders), 2); } if (Bid >= HighestSell + (Spacing * Point)) { // if (Multiplier) if (Multiplier == 1) Lots = NormalizeDouble(LotSize * CounterTrendMultiplier * MathPow(LotIncrement, SellOrders), 2); else Lots = NormalizeDouble((LotSize * CounterTrendMultiplier) + (LotIncrement * SellOrders), 2); } if (Lots == 0) { // if (Multiplier) if (Multiplier == 1) Lots = NormalizeDouble(LotSize, 2); else Lots = NormalizeDouble(LotSize, 2); } OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, TradeComment, Reference, Red); Error = GetLastError(); if (Error != 0) Write("Error opening SELL order: " + ErrorDescription(Error) + " (D" + Error + ") Bid:" + Bid + " Slippage:" + Slippage); else { TickPrice = Close[0]; TradeAllowed = false; } } } Is this some that can be done? |
|
|||
|
HELP~just 1 error, use 3 Hours still can't find it out
I AM VERY WORRY , BECAUSE I CAN'T FIND how to correct the error belowcan anyone tell me where is the mistake? or help me to debug , i have attached the files, see buttom~ ~ '\end_of_program' - unbalanced left parenthesis C:\Program Files\ MetaTrader\experts\scripts\delete_pending_SAM.mq4 (38, 2) IT IS A SCRIPT FILE~ ~ //+------------------------------------------------------------------+ //| delete_pending.mq4 | //| Copyright ?2004, MetaQuotes Software Corp. | //+------------------------------------------------------------------+ #property copyright "Copyright ?2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property show_inputs bool result; extern double OverSymbolDel = 1; //0:FASLE ; 1: TRUE //+------------------------------------------------------------------+ //| script "delete pending order" | //+------------------------------------------------------------------+ int start() { for (int number=0; (number <= OrdersTotal()+1); number++ ) {for (int times=0;( times <= OrdersTotal()+1); times++ ) {if (OrderSelect(number,SELECT_BY_POS,MODE_TRADES) ) {if((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ) break; if ((OverSymbolDel ==0)&& (Symbol()==OrderSymbol() ) delPending(); if (OverSymbolDel ==1) delPending(); } else Print("Error when Order Select ", GetLastError() ) ; } } } //+------------------------------------------------------------------+ void delPending() {OrderPrint(); int ticket =OrderTicket(); result=OrderDelete(ticket); if (result==False) Print("Error when delete Order ", GetLastError() ); } Last edited by chiwing; 01-09-2009 at 05:53 PM. |
|
|||
|
To chiwing
Try this: Code:
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property show_inputs
bool result;
extern double OverSymbolDel = 1; //0:FASLE ; 1: TRUE
//+------------------------------------------------------------------+
//| script "delete pending order" |
//+------------------------------------------------------------------+
int start()
{
for (int number=OrdersTotal()-1; number >= 0; number--)
{
OrderSelect(number,SELECT_BY_POS,MODE_TRADES);
if((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ) continue;
if (OverSymbolDel ==0&& Symbol()==OrderSymbol() ) delPending();
if (OverSymbolDel ==1) delPending();
}
}
//+------------------------------------------------------------------+
void delPending()
{
OrderPrint();
int ticket =OrderTicket();
result=OrderDelete(ticket);
if (!result) Print("Error when delete Order ", GetLastError() );
}
Last edited by Roger09; 01-09-2009 at 08:11 PM. |
![]() |
| Bookmarks |
| Tags |
| #include, candle time, CHinGsMAroonCLK, coders guru, conditionally, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop |
| Thread Tools | |
| Display Modes | |
|
|
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 |