Hi I generated simple EA code in MQl4 to display arrows (up and down) at MA Crossover. Parameters for MAs (Fast and Slow) are set in menu as are arrow specifications (width, color, etc.).
For reasons that baffle me, my code compiles without error but doesn't seem to work: Arrows are not drawn on chart when MAs cross.
Any advice as to what I did wrong?
Thanks
// get values for Fast, Slow & Base MAs for the current and past candledouble FastMA = iMA(NULL,0,FAST_MA_Period,FAST_MA_Shift,FAST_MA_Method,FAST_MA_Price,0); // 0 = current candledouble prevFastMA = iMA(NULL,0,FAST_MA_Period,FAST_MA_Shift,FAST_MA_Method,FAST_MA_Price,1); // 1 = last closed candle double ConMA = iMA(NULL,0,CON_MA_Period,CON_MA_Shift,CON_MA_Method,CON_MA_Price,0); // 0 = current candledouble prevConMA = iMA(NULL,0,CON_MA_Period,CON_MA_Shift,CON_MA_Method,CON_MA_Price,1); // 1 = last closed candle double SlowMA = iMA(NULL,0,SLOW_MA_Period,SLOW_MA_Shift,SLOW_MA_Method,SLOW_MA_Price,0); // 0 = current candledouble prevSlowMA = iMA(NULL,0,SLOW_MA_Period,SLOW_MA_Shift,SLOW_MA_Method,SLOW_MA_Price,1); // 1 = last closed candleif (drawArrows==true) { // defined in menu settings// Check for a crossover (fastMA above slowMA) and draw up arrowif(prevFastMA < prevSlowMA && FastMA > SlowMA)
{
Comment ("Buy Signal");
// Draw an up arrow at the current candledouble arrowPrice = High[1] + (High[0] - Low[0]) * 0.1; // Adjust arrow positionObjectCreate(0, "UpArrow", OBJ_ARROW, 0, 0, 0);
ObjectSetInteger(0, "UpArrow", OBJPROP_SELECTABLE, true);
ObjectSetInteger(0, "UpArrow", OBJPROP_SELECTED, true);
ObjectSetInteger(0, "UpArrow", OBJPROP_COLOR, uparrowClr);
ObjectSetInteger(0, "UpArrow", OBJPROP_ARROWCODE, 233);
ObjectSetInteger(0, "UpArrow", OBJPROP_WIDTH, arrowWidth);
ObjectSetInteger(0, "UpArrow", OBJPROP_STYLE, arrowStyle);
ObjectSetDouble (0, "UpArrow", OBJPROP_PRICE1, arrowPrice);
}
// Check for a crossunder (fastMA below slowMA) and draw down arrowif(prevFastMA > prevSlowMA && FastMA < SlowMA)
{
Comment ("Sell Signal");
// Draw a down arrow at the current candledouble arrowPrice = Low[1] - (High[0] - Low[0]) * 0.1; // Adjust arrow positionObjectCreate(0, "DownArrow", OBJ_ARROW, 0, 0, 0);
ObjectSetInteger(0, "DownArrow", OBJPROP_SELECTABLE, true);
ObjectSetInteger(0, "DownArrow", OBJPROP_SELECTED, true);
ObjectSetInteger(0, "DownArrow", OBJPROP_COLOR, dwarrowClr);
ObjectSetInteger(0, "DownArrow", OBJPROP_ARROWCODE, 234);
ObjectSetInteger(0, "DownArrow", OBJPROP_WIDTH, arrowWidth);
ObjectSetInteger(0, "DownArrow", OBJPROP_STYLE, arrowStyle);
ObjectSetDouble (0, "DownArrow", OBJPROP_PRICE1, arrowPrice);
}
}
Hi I generated simple EA code in MQl4 to display arrows (up and down) at MA Crossover. Parameters for MAs (Fast and Slow) are set in menu as are
arrow specifications (width, color, etc.).
For reasons that baffle me, my code compiles without error but doesn't seem to work: Arrows are not drawn on chart when MAs cross.
Any advice as to what I did wrong?
Thanks