- Calculating Lots to 0.0 decimal places HELP please.
- Help for a Newbie
- please assist me to set the stoploss
Yvan Tarong:
Point (* 2
Point (* 2
send code through CODE button
Yvan Tarong:
request.tp = bid - stopLossPips * Point (* 2; // Set your take profit
request.tp = bid - stopLossPips * Point (* 2; // Set your take profit
I replied on error on your code.
put an extra parentheses end of Point( like Point()
Here is my parameter for this EA. I hope someone with a good heart to help me finish this work:
li.li1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px 'Helvetica Neue'} ol.ol1 {list-style-type: decimal}- Pair: EURUSD
- Timeframe: 30mins
- Using the MACD indicator
- Entry Order (Buy and Sell) execution at the open of the current candle based on these conditions:
- Set Buy Order after the first Rising Histogram (from previous falling histogram)
- Set Sell Order after the first Falling Histogram (from previous rising histogram)
- Execute Stop Loss parameter at the 5 pips lower (for buy order) from lowest price or 5 pips higher (for sell order) from highest price,
- Execute Take Profit parameter based on 90% of previous candle (of the first rising histogram for buy order, and of the first falling histogram for sell order) body size (open and close price)
- Risk 2% of capital per trade
Hi Sir,
Thank you for taking time to check my code. But unfortunately, I still got the same error. :(
// Define input parameters input int fastEMA = 12; input int slowEMA = 26; input int signalEMA = 9; input double lotSize = 0.1; input double riskPercentage = 2.0; // Percentage of capital risk per trade input int slippage = 3; // Define variables double macdCurrent, signalCurrent, macdPrevious, signalPrevious; double macdHistogramCurrent, macdHistogramPrevious; int ticket; // Define MACD parameters int OnTick() { // Define MACD arrays double macdCurrent[]; double signalCurrent[]; double macdPrevious[]; double signalPrevious[]; // Calculate MACD values ArraySetAsSeries(macdCurrent, true); ArraySetAsSeries(signalCurrent, true); ArraySetAsSeries(macdPrevious, true); ArraySetAsSeries(signalPrevious, true); int calculateBars = 1; // The number of bars to calculate MACD for CopyBuffer(_Symbol, _Period, fastEMA, calculateBars, 0, macdCurrent); CopyBuffer(_Symbol, _Period, slowEMA, calculateBars, 0, macdPrevious); CopyBuffer(_Symbol, _Period, signalEMA, calculateBars, 0, signalCurrent); CopyBuffer(_Symbol, _Period, signalEMA, calculateBars, 0, signalPrevious); // Calculate MACD Histogram values macdHistogramCurrent = macdCurrent[0] - signalCurrent[0]; macdHistogramPrevious = macdPrevious[0] - signalPrevious[0]; // Get Bid and Ask prices double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID); double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); // Calculate risk based on 90% of the previous candle body size and 2% of capital double capital = AccountFreeMarginCheck(_Symbol, OP_BUY, lotSize); double riskAmount = NormalizeDouble(capital * riskPercentage / 100.0, Digits); double candleBodySize = MathAbs(iClose(_Symbol, _Period, 1) - iOpen(_Symbol, _Period, 1)); int stopLossPips = int(candleBodySize * 0.90 / Point); // Check for the first rising MACD Histogram from the previous falling histogram if (macdHistogramCurrent > 0 && macdHistogramPrevious <= 0) { // Place Buy order MqlTradeRequest request = {0}; MqlTradeResult result = {0}; request.action = TRADE_ACTION_DEAL_BUY; request.symbol = _Symbol; request.volume = lotSize; request.type = ORDER_BUY; request.price = ask; // Use ask price for Buy orders request.sl = ask - stopLossPips * Point; // Set your stop loss request.tp = ask + stopLossPips * Point (* 2; // Set your take profit request.deviation = slippage); if (OrderSend(request, result)) { // Order was successful // Additional logic can be added here } } // Check for the first falling MACD Histogram from the previous rising histogram if (macdHistogramCurrent < 0 && macdHistogramPrevious >= 0) { // Place Sell order MqlTradeRequest request = {0}; MqlTradeResult result = {0}; request.action = TRADE_ACTION_DEAL_SELL; request.symbol = _Symbol; request.volume = lotSize; request.type = ORDER_SELL; request.price = bid; // Use bid price for Sell orders request.sl = bid + stopLossPips * Point; // Set your stop loss request.tp = bid - stopLossPips * Point (* 2; // Set your take profit request.deviation = slippage; if (OrderSend(request, result)) { // Order was successful // Additional logic can be added here } return(0);}
Mahdi Ebrahimzadeh #:
I replied on error on your code.
put an extra parentheses end of Point( like Point()
Yvan Tarong #:
Hi Sir,
Thank you for taking time to check my code. But unfortunately, I still got the same error. :(
request.price = ask; // Use ask price for Buy orders request.sl = ask - stopLossPips * Point; // Set your stop loss request.tp = ask + stopLossPips * Point (* 2; // Set your take profit request.deviation = slippage);
You need to change this to:
request.price = ask; // Use ask price for Buy orders request.sl = ask - stopLossPips * _Point; // Set your stop loss request.tp = ask + stopLossPips * _Point * 2; // Set your take profit request.deviation = slippage);
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