| New signals service! | |
|
|||||||
| 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 |
|
![]() |
|
|
LinkBack (2) | Thread Tools | Display Modes |
|
|||
|
noLagMACD
Can anyone tell me what is wrong with this piece of code. I am trying to incorporate a noLagMACD into Makegrid193. It compiles and runs, just doesn't change the settings of myWantLongs and myWantShorts at all, so there are no orders generated.
if(UseMACDNoLag) { int limit=Bars; myWantLongs = false; myWantShorts = false; for(i=0; i<limit; i++) { FastEMABuffer[i]=iMA(NULL,PERIOD_M5,emaFast,0,MODE_EMA,PRICE_CLOSE ,i); SlowEMABuffer[i]=iMA(NULL,PERIOD_M5,emaSlow,0,MODE_EMA,PRICE_CLOSE ,i); } for(i=0; i<limit; i++) { EMA=iMAOnArray(FastEMABuffer,0,emaFast,0,MODE_EMA, i); ZeroLagEMAp=FastEMABuffer[i]+FastEMABuffer[i]-EMA; EMA=iMAOnArray(SlowEMABuffer,0,emaSlow,0,MODE_EMA, i); ZeroLagEMAq=SlowEMABuffer[i]+SlowEMABuffer[i]-EMA; MACDBuffer[i]=ZeroLagEMAp - ZeroLagEMAq; } double tester1, tester2, tester3; tester1 = MACDBuffer[0]; tester2 = MACDBuffer[1]; tester3 = MACDBuffer[2]; if( (tester1 > 0.0) && (tester2 <= 0.0) ) // cross up { CloseAllPendingOrders(); if(CloseOpenPositions == true) { ClosePendingOrdersAndPositions(); } if(wantLongs==true) { myWantLongs = true; } myWantShorts = false; } if( (tester1 < 0.0) && (tester2 >= 0.0) ) // cross down { CloseAllPendingOrders(); if(CloseOpenPositions == true) { ClosePendingOrdersAndPositions(); } if(wantShorts==true) { myWantShorts = true; } myWantLongs = false; } if( (tester1 > 0.0) && (tester2 > 0.0) && (tester3 > 0.0) && (wantLongs==true) ) // is well above zero { myWantLongs = true; } if( (tester1 < 0.0) && (tester2 < 0.0) && (tester3 < 0.0) && (wantShorts==true) ) // is well below zero { myWantShorts = true; } } |
|
|||
|
Don't worry
I discovered Time[] and iComplex and that mess I posted before became this.
if(UseMACDNoLag) { if(newbar != Time[0]) { newbar=Time[0]; myWantLongs = false; myWantShorts = false; MACD_Main = iCustom(NULL, 0, "ZeroLag MACD", FastEMA, SlowEMA, SignalEMA, 0, 1); if(MACD_Main > 0) { if(!MACDup) { if(CloseOpenPositions == true) { ClosePendingOrdersAndPositions(); } else { CloseAllPendingOrders(); } } MACDup = true; myWantShorts = false; if(wantLongs==true) { myWantLongs = true; } } if(MACD_Main < 0) { if(MACDup) { if(CloseOpenPositions == true) { ClosePendingOrdersAndPositions(); } else { CloseAllPendingOrders(); } } MACDup = false; myWantLongs = false; if(wantShorts==true) { myWantShorts = true; } } } } This is so much fun!!! If I get good results with this EA I'll post it. |
|
||||
|
Quote:
Code:
}
OrderSend(Symbol(),
OP_BUYSTOP,
lots,
pivotLevelGoesHere,
slippage,
pivotLevelGoesHere-(stop_long*Point),
pivotLevelGoesHere+(take_profit*Point),
NULL,
magic,
0,
FireBrick);
OrderSend(Symbol(),
OP_SELLSTOP,
lots,
anotherPivotLevelGoesHere,
slippage,
anotherPivotLevelGoesHere+(stop_short*Point),
anotherPivotLevelGoesHere-(take_profit*Point),
NULL,
magic,
0,
FireBrick);
clear_to_send = false;
}
__________________
"Don't work harder, work smarter." -- my Java professor Coder for Hire: http://www.firecell-fx.com |
|
|||
|
elliot wave indicator
does anyone have an elliot wave indicator that draws and labels each wave? i have seen the ew oscillator and another one but they dont do the trick. maybe even a harmonic pattern indicator that draws and labels each pattern???
|
|
||||
|
Quote:
![]() http://www.forexmt4.com/ Quote:
__________________
"Don't work harder, work smarter." -- my Java professor Coder for Hire: http://www.firecell-fx.com |
|
||||
|
ok i figured out the pivot calculation. Thanks for your assistance.
The problem I face now is that when it correctly opens the pending order in the correct price locations it continues to open pending orders over and over every time the price action moves 1 pip. I have looked and will continue to research why this is happening but wanted to see if you could give me a hint or help if you see a logic error I am doing. As always thanks for your time. Code:
extern int look_price_hour = 1; // Change for your time zone (my is +1 Hour). Should be 9AM London time.
extern int look_price_min = 35; // Offset in minutes when to look on price.
extern int close_hour = 12; // Close all orders after this hour
bool use_close_hour = true; // set it to false to ignore close_hour
int take_profit = 20;
extern int Currency_Spread = 4;
int open_long = 21;
int open_short = 21;
int stop_long = 30;
int stop_short = 30;
extern int slippage = 0;// Put what your brooker requires
extern double lots = 0.20; // Position size
extern int magic = 123;
bool clear_to_send = true;
void ReportStrategy()
{
int totalorders = HistoryTotal();
double StrategyProfit = 0.0;
double StrategyProfitOpen = 0.0;
int StrategyOrders = 0;
int StrategyOrdersOpen = 0;
for(int j=0; j<totalorders;j++)
{ if(OrderSelect(j, SELECT_BY_POS, MODE_HISTORY) &&
(OrderMagicNumber() == magic))
{
if((OrderType() == OP_BUY) ||
(OrderType() == OP_SELL))
{
StrategyOrders++;
StrategyProfit += OrderProfit();
}
}
}
totalorders = OrdersTotal();
for(j=0; j<totalorders;j++)
{ if(OrderSelect(j, SELECT_BY_POS, MODE_TRADES) &&
(OrderMagicNumber() == magic))
{
if((OrderType() == OP_BUY) ||
(OrderType() == OP_SELL))
{
StrategyOrdersOpen++;
StrategyProfitOpen += OrderProfit();
}
}
}
Comment("Daily20Pip EA Executed ", StrategyOrders,"+",StrategyOrdersOpen, " trades with ", StrategyProfit,"+",
StrategyProfitOpen," = ",StrategyProfit+StrategyProfitOpen," of profit\n",
"Server hour: ", TimeHour(CurTime()), " Local hour: ", TimeHour(LocalTime()));
return;
}
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
ReportStrategy();
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
ReportStrategy();
if(Hour() >= close_hour &&
use_close_hour){
// we are after closing time
int totalorders = OrdersTotal();
for(int j=0;j<totalorders;j++){
OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber() == magic){
if(OrderType() == OP_BUY)
OrderClose(OrderTicket(), OrderLots(), Bid, 0, Red);
if(OrderType() == OP_SELL)
OrderClose(OrderTicket(), OrderLots(), Ask, 0, Red);
if(OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)
OrderDelete(OrderTicket());
}
}
return(0);
}
if(Hour() == look_price_hour &&
Minute() >= look_price_min &&
clear_to_send){
// Probably I need to close any old positions first:
totalorders = OrdersTotal();
for(j=0;j<totalorders;j++){
OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber() == magic){
if(OrderType() == OP_BUY)
OrderClose(OrderTicket(), OrderLots(), Bid, 0, Red);
if(OrderType() == OP_SELL)
OrderClose(OrderTicket(), OrderLots(), Ask, 0, Red);
if(OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)
OrderDelete(OrderTicket());
}
}
}
double PIVOT;
PIVOT = (iHigh(NULL,PERIOD_D1,1) + iLow(NULL,PERIOD_D1,1) + iClose(NULL,PERIOD_D1,1))/3;
// Send orders:
OrderSend(Symbol(),
OP_BUYSTOP,
lots,
PIVOT+(open_long+Currency_Spread)*Point, // Spread included
slippage,
PIVOT+((open_long+Currency_Spread)-stop_long)*Point,
PIVOT+((open_long+Currency_Spread)+take_profit)*Point,
NULL,
magic,
0,
FireBrick);
OrderSend(Symbol(),
OP_SELLSTOP,
lots,
PIVOT-open_short*Point,
slippage,
PIVOT-(open_short-stop_short)*Point,
PIVOT-(open_short+take_profit)*Point,
NULL,
magic,
0,
FireBrick);
clear_to_send = false; // mark that orders are sent
if(!clear_to_send){ // there are active orders
int long_ticket = -1;
int short_ticket = -1;
bool no_active_order = true;
totalorders = OrdersTotal();
for(j=0;j<totalorders;j++){
OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber() == magic){
if(OrderType() == OP_BUYSTOP)
long_ticket = OrderTicket();
if(OrderType() == OP_SELLSTOP)
short_ticket = OrderTicket();
if(OrderType() == OP_BUY ||
OrderType() == OP_SELL) // Active order
no_active_order = false; }
}
if(short_ticket == -1 && long_ticket != -1)
OrderDelete(long_ticket);
if(long_ticket == -1 && short_ticket != -1)
OrderDelete(short_ticket);
if(long_ticket == -1 && short_ticket == -1 && no_active_order &&
Hour() != look_price_hour && Minute() >= look_price_min)
clear_to_send = true;
if(Hour() == (look_price_hour-1) &&
MathAbs(Minute() - look_price_min) < 10)
clear_to_send = true;
}
//----
return(0);
}
__________________
Proverbs [James] Faith in Jesus helps me to see the invisible, believe the incredible and receive the impossible! He makes all things new in my life. Last edited by proverbs; 06-15-2007 at 04:30 AM. |
|
||||
|
Regarding my previous post,
It looks like the "clear_to_send = false;" is not switching after the pending order. Any ideas? This happened once i make the pivot my point of reference for pending orders. If I can not solve this logic then I guess I will try and figure out how to reference a piviot from an indicator and call to it from the EA. not sure if that is posible but i see those as my options. Any advice or assistance is appriciated.
__________________
Proverbs [James] Faith in Jesus helps me to see the invisible, believe the incredible and receive the impossible! He makes all things new in my life. Last edited by proverbs; 06-15-2007 at 06:57 AM. |
|
||||
|
Code:
extern int look_price_hour = 1; // Change for your time zone (my is +1 Hour). Should be 9AM London time.
extern int look_price_min = 35; // Offset in minutes when to look on price.
extern int close_hour = 12; // Close all orders after this hour
bool use_close_hour = true; // set it to false to ignore close_hour
int take_profit = 20;
extern int Currency_Spread = 4;
int open_long = 21;
int open_short = 21;
int stop_long = 30;
int stop_short = 30;
extern int slippage = 0;// Put what your brooker requires
extern double lots = 0.20; // Position size
extern int magic = 123;
bool clear_to_send = true;
void ReportStrategy()
{
int totalorders = HistoryTotal();
double StrategyProfit = 0.0;
double StrategyProfitOpen = 0.0;
int StrategyOrders = 0;
int StrategyOrdersOpen = 0;
for(int j=0; j<totalorders;j++)
{ if(OrderSelect(j, SELECT_BY_POS, MODE_HISTORY) &&
(OrderMagicNumber() == magic))
{
if((OrderType() == OP_BUY) ||
(OrderType() == OP_SELL))
{
StrategyOrders++;
StrategyProfit += OrderProfit();
}
}
}
totalorders = OrdersTotal();
for(j=0; j<totalorders;j++)
{ if(OrderSelect(j, SELECT_BY_POS, MODE_TRADES) &&
(OrderMagicNumber() == magic))
{
if((OrderType() == OP_BUY) ||
(OrderType() == OP_SELL))
{
StrategyOrdersOpen++;
StrategyProfitOpen += OrderProfit();
}
}
}
Comment("Daily20Pip EA Executed ", StrategyOrders,"+",StrategyOrdersOpen, " trades with ", StrategyProfit,"+",
StrategyProfitOpen," = ",StrategyProfit+StrategyProfitOpen," of profit\n",
"Server hour: ", TimeHour(CurTime()), " Local hour: ", TimeHour(LocalTime()));
return;
}
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
ReportStrategy();
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
ReportStrategy();
if(Hour() >= close_hour &&
use_close_hour){
// we are after closing time
int totalorders = OrdersTotal();
for(int j=0;j<totalorders;j++){
OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber() == magic){
if(OrderType() == OP_BUY)
OrderClose(OrderTicket(), OrderLots(), Bid, 0, Red);
if(OrderType() == OP_SELL)
OrderClose(OrderTicket(), OrderLots(), Ask, 0, Red);
if(OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)
OrderDelete(OrderTicket());
}
}
return(0);
}
if(Hour() == look_price_hour &&
Minute() >= look_price_min &&
clear_to_send){
// Probably I need to close any old positions first:
totalorders = OrdersTotal();
for(j=0;j<totalorders;j++){
OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber() == magic){
if(OrderType() == OP_BUY)
OrderClose(OrderTicket(), OrderLots(), Bid, 0, Red);
if(OrderType() == OP_SELL)
OrderClose(OrderTicket(), OrderLots(), Ask, 0, Red);
if(OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)
OrderDelete(OrderTicket());
}
}
}
double PIVOT;
PIVOT = (iHigh(NULL,PERIOD_D1,1) + iLow(NULL,PERIOD_D1,1) + iClose(NULL,PERIOD_D1,1))/3;
// Send orders:
if (clear_to_send){
OrderSend(Symbol(),
OP_BUYSTOP,
lots,
PIVOT+(open_long+Currency_Spread)*Point, // Spread included
slippage,
PIVOT+((open_long+Currency_Spread)-stop_long)*Point,
PIVOT+((open_long+Currency_Spread)+take_profit)*Point,
NULL,
magic,
0,
FireBrick);
OrderSend(Symbol(),
OP_SELLSTOP,
lots,
PIVOT-open_short*Point,
slippage,
PIVOT-(open_short-stop_short)*Point,
PIVOT-(open_short+take_profit)*Point,
NULL,
magic,
0,
FireBrick);
clear_to_send = false; // mark that orders are sent
}
if(!clear_to_send){ // there are active orders
int long_ticket = -1;
int short_ticket = -1;
bool no_active_order = true;
totalorders = OrdersTotal();
for(j=0;j<totalorders;j++){
OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber() == magic){
if(OrderType() == OP_BUYSTOP)
long_ticket = OrderTicket();
if(OrderType() == OP_SELLSTOP)
short_ticket = OrderTicket();
if(OrderType() == OP_BUY ||
OrderType() == OP_SELL) // Active order
no_active_order = false; }
}
if(short_ticket == -1 && long_ticket != -1)
OrderDelete(long_ticket);
if(long_ticket == -1 && short_ticket != -1)
OrderDelete(short_ticket);
if(long_ticket == -1 && short_ticket == -1 && no_active_order &&
Hour() != look_price_hour && Minute() >= look_price_min)
clear_to_send = true;
if(Hour() == (look_price_hour-1) &&
MathAbs(Minute() - look_price_min) < 10)
clear_to_send = true;
}
//----
return(0);
}
__________________
"Don't work harder, work smarter." -- my Java professor Coder for Hire: http://www.firecell-fx.com |
|
|||
|
I am trying to code a very basic money management technique into an EA i am coding. Basically, I want to have the EA automatically scale my lot size by some adjustable factor based on my account balance. For example, if I enter a value of 1, the EA would perform calculation and determine a lot size of 5 lots with an account balance of 5,000.00 (in other words, 1 lot for every 1000.00 balance).
Well anyway, my problem has been how to round the the calculted value to the nearest decimal place. I've copied the EA code below to show you how I have tried to accomplish this. Well, I have yet to get it to work. So I beg your assistance and hope you can point out what I may be doing wrong, or what i need to do to get this to work. I hope i've explained it clearly enough for you to understand what i want to accomplish. Thanks in advance for any help Last edited by waaustin; 06-21-2007 at 04:10 PM. |
![]() |
| Bookmarks |
| Tags |
| histogram, forex, ZUP_v1.mq4 |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
|
||||
| Posted By | For | Type | Date | |
| OzFx System:) - Page 639 | This thread | Refback | 06-21-2008 10:53 PM | |
| Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart | This thread | Refback | 12-08-2007 12:46 PM | |