Question: When compiling its gives error message 'Ask' - undeclared identifier RoyalCakeTradingStrategy.mq5 68 57, how do I fix this error? //+------------------------------------------------------------------+ //| RoyalCakeTrading | //| Copyright
When compiling its gives error message 'Ask' - undeclared identifier RoyalCakeTradingStrategy.mq5 68 57, how do I fix this error?
//+------------------------------------------------------------------+ //| RoyalCakeTrading | //| Copyright 2023, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00"
// Indicator Inputs input int ema_period = 9; input int smma_period_1 = 21; input int smma_period_2 = 50; input int ema_period_long = 200;
// Strategy Inputs input bool trading_enabled = true; input int stop_loss = 40; input int short_stop_loss = 35; input int take_profit = 50; input int trailing_stop_loss = 40;
// Strategy Variables bool long_entry = false; double long_stop_price = 0.0; double range_start = 0.0; bool short_entry = false; double short_stop_price = 0.0;
// Initialize the indicators int OnInit() { return(INIT_SUCCEEDED); }
// Enter and exit trades on each tick void OnTick() { double ema_9 = iMA (_Symbol, Period(), ema_period, 0, MODE_EMA, PRICE_CLOSE); double smma_21 = iMA(_Symbol, PERIOD_CURRENT, smma_period_1, 0, MODE_SMA, PRICE_CLOSE); double smma_50 = iMA(_Symbol, PERIOD_CURRENT, smma_period_2, 0, MODE_SMA, PRICE_CLOSE); double ema_200 = iMA(_Symbol, PERIOD_CURRENT, ema_period_long, 0, MODE_EMA, PRICE_CLOSE);
if(trading_enabled) { double high_15min = iHigh(_Symbol, PERIOD_M15, 1); double low_15min = iLow(_Symbol, PERIOD_M15, 1); double close_15min = iClose(_Symbol, PERIOD_M15, 1); double high_5min = iHigh(_Symbol, PERIOD_M5, 1); double low_5min = iLow(_Symbol, PERIOD_M5, 1); double close_5min = iClose(_Symbol, PERIOD_M5, 1); double high_1min = iHigh(_Symbol, PERIOD_M1, 1); double low_1min = iLow(_Symbol, PERIOD_M1, 1); double close_1min = iClose(_Symbol, PERIOD_M1, 1);
// Enter the long position if conditions are met if(close_1min > ema_9 && close_1min < ema_9 && smma_21 > smma_50 && smma_50 > ema_200 && !long_entry) { if(high_15min > ema_9 && low_15min > ema_9 && close_15min > smma_21) { if(high_5min > ema_9 && low_5min > ema_9 && close_5min > smma_21) { if(high_1min > ema_9 && low_1min > ema_9 && close_1min > smma_21) { long_entry = true; long_stop_price = low_1min - stop_loss * _Point; OrderSend(_Symbol, OP_BUY, 0.1, Ask, 3, long_stop_price, Ask + take_profit * _Point, "Long Trade", MagicNumber, 0, Blue); } } } }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
