You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would like to have your thoughts on this. Here's the code...
//+------------------------------------------------------------------+ //| Price Advisor.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #include <stdlib.mqh> int prev_err = 0; int state = 0; double range = 0; void PrintErrors(string message) { int err = GetLastError(); if (err != 0 && err != prev_err) { Print("Error: " + message + ": " + err + ": " + ErrorDescription(err)); } prev_err = err; } //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- // Monitor Open Positions... int total = OrdersTotal(); for (int i = 0; i < total; i++) { OrderSelect(i, SELECT_BY_POS); if (OrderSymbol() == Symbol()) { if (OrderProfit() > 2) { OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 3, Aqua); PrintErrors("Close Order: exeptable profit"); } } } // Determine if we already placed an order on this symbol... bool trading_on_symbol = false; total = OrdersTotal(); for (i = 0; i < total; i++) { OrderSelect(i, SELECT_BY_POS); if (OrderSymbol() == Symbol()) { trading_on_symbol = true; break; } } double stop_loss = 1200; double lots = 0.10; if (!trading_on_symbol && TimeDayOfWeek(CurTime()) < 4 && TimeDayOfWeek(CurTime()) > 0) { if (Symbol() == "USDCHF") range = 4; if (Symbol() == "GBPUSD") range = 8; if (Symbol() == "EURUSD") range = 4; if (Symbol() == "USDJPY") range = 1; if (Symbol() == "AUDUSD") range = 1; if (Symbol() == "USDCAD") range = 4; if (Symbol() == "EURCHF") range = 2; if (Symbol() == "EURGBP") range = 3; if (Symbol() == "EURJPY") range = 4; if (Symbol() == "EURAUD") range = 4; if (Symbol() == "GBPCHF") range = 1; if (Symbol() == "GBPJPY") range = 4; if ( Close[3] < Open[3] - range * Point && Close[2] < Open[2] - range * Point && Close[1] < Open[1] - range * Point) { OrderSend( Symbol(), OP_SELL, lots, Bid,1, Ask + stop_loss * Point, Bid - 8 * Point, NULL, 0, 0, Aqua); PrintErrors("OrderSend: Sell Order"); trading_on_symbol = true; } if ( Close[3] > Open[3] + range * Point && Close[2] > Open[2] + range * Point && Close[1] > Open[1] + range * Point) { OrderSend( Symbol(), OP_BUY, lots, Ask,1, Ask - stop_loss * Point, Ask + 8 * Point, NULL, 0, 0, Aqua); PrintErrors("OrderSend: Buy Order"); trading_on_symbol = true; } } //---- return(0); } //+------------------------------------------------------------------+