I Need Debugging For My Personal Source Code EA

指定

here's the code,

+------------------------------------------------------------------+

//|                                                         kama.mq4 |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//|                 Heikin/Kaufman Strategy Expert Advisor           |
//|                        By OpenAI (ChatGPT)                       |
//+------------------------------------------------------------------+

// Inputs
input int Length = 5;
input double Fastend = 2.5;
input int Slowend = 20;
input int test = 0;
input int sloma = 20;

// Indicator buffers
double nAMABuffer[];
double fmaBuffer[];
double smaBuffer[];
double ha_closeBuffer[];
double mha_closeBuffer[];

// External variables
extern double LotSize = 0.01;  // Trading lot size
extern int StopLoss = 50;      // Stop loss in pips
extern int TakeProfit = 100;   // Take profit in pips

// Trading parameters
int ticket = -1;
int slippage = 3;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[])
  {
   int start = prev_calculated > 0 ? prev_calculated - 1 : 0;

   ArrayResize(nAMABuffer, rates_total);
   ArrayResize(fmaBuffer, rates_total);
   ArrayResize(smaBuffer, rates_total);
   ArrayResize(ha_closeBuffer, rates_total);
   ArrayResize(mha_closeBuffer, rates_total);

   double nfastend = 2 / (Fastend + 1);
   double nslowend = 2 / (Slowend + 1);

   for(int i = start; i < rates_total; i++)
     {
      double xPrice = (high[i] + low[i] + close[i]) / 3;
      double xvnoise = MathAbs(xPrice - xPrice[test]);
      double nsignal = MathAbs(xPrice - xPrice[i - Length]);
      double nnoise = 0;

      for(int j = i - Length + 1; j <= i; j++)
        {
         double xv = MathAbs((high[j] + low[j] + close[j]) / 3 - (high[j - 1] + low[j - 1] + close[j - 1]) / 3);
         nnoise += xv;
        }

      double nefratio = nnoise != 0 ? nsignal / nnoise : 0;
      double nsmooth = MathPow(nefratio * (nfastend - nslowend) + nslowend, 2);
      nAMABuffer[i] = i > 0 ? nAMABuffer[i - 1] + nsmooth * (xPrice - nAMABuffer[i - 1]) : xPrice;

      int ha_t = iCustom(NULL, 0, "Heikin Ashi", 0, i);
      ha_closeBuffer[i] = iCustom(NULL, 0, "Heikin Ashi", 2, i, ha_t);
      mha_closeBuffer[i] = iCustom(NULL, res1, "Heikin Ashi", 1, i, ha_t);

      if(i >= test)
        {
         fmaBuffer[i] = iMAOnArray(mha_closeBuffer, rates_total, 1, 0, test, i);
        }
      if(i >= sloma)
        {
         smaBuffer[i] = iMAOnArray(ha_closeBuffer, rates_total, sloma, 0, MODE_EMA, i);
        }
     }
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0, fmaBuffer);
   SetIndexBuffer(1, smaBuffer);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexLabel(0, "MA");
   SetIndexLabel(1, "SMA");

   double emptyBufferArray[];
  
     {
      int totalBars = ArraySize(open); // Retrieve the size of the 'open' array
      int start = prev_calculated > 0 ? prev_calculated - 1 : 0;

      // Rest of your code...

      for(int i = start; i < totalBars; i++)
        {
         // Processing for each bar
        }

      // Rest of your code...
     }

   SetIndexBuffer(2, emptyBufferArray, INDICATOR_DATA);

   double emptyBufferArray2[];
   ArrayResize(emptyBufferArray2, rates_total);
   SetIndexBuffer(3, emptyBufferArray2, INDICATOR_DATA);

   SetIndexStyle(2, DRAW_ARROW);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(2, SYMBOL_ARROWUP);
   SetIndexArrow(3, SYMBOL_ARROWDOWN);
   SetIndexEmptyValue(2, 0);
   SetIndexEmptyValue(3, 0);

   return INIT_SUCCEEDED;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ArrayFree(nAMABuffer);
   ArrayFree(fmaBuffer);
   ArrayFree(smaBuffer);
   ArrayFree(ha_closeBuffer);
   ArrayFree(mha_closeBuffer);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(ticket == -1 && OrdersTotal() == 0)
     {
      int rates_total = RatesTotal();
      int start = MathMax(0, rates_total - 1 - 1000);

      for(int i = start; i < rates_total; i++)
        {
         if(fmaBuffer[i - 1] > smaBuffer[i - 1] && fmaBuffer[i] < smaBuffer[i])
           {
            ObjectCreate("CrossUnder", OBJ_TRIANGLE, 0, Time[i], High[i], 0);
            ObjectSet("CrossUnder", OBJPROP_STYLE, STYLE_SOLID);
            ObjectSet("CrossUnder", OBJPROP_WIDTH, 1);
            ObjectSet("CrossUnder", OBJPROP_BACK, Red);
            ObjectSetText("CrossUnder", "S", 8, "Arial", Red);
           }
        }

      if(fmaBuffer[rates_total - 2] > smaBuffer[rates_total - 2] && fmaBuffer[rates_total - 1] < smaBuffer[rates_total - 1])
        {
         ticket = OrderSend(Symbol(), OP_BUY, LotSize, Ask, slippage, Ask - StopLoss * Point, Ask + TakeProfit * Point);
         if(ticket < 0)
            Print("Error opening buy order:", GetLastError());
        }
      else

        {
         if(ticket == -1 && OrdersTotal() == 0)
           {
            int crossUnderBar = -1;


              {
               if(fmaBuffer[i - 1] > smaBuffer[i - 1] && fmaBuffer[i] < smaBuffer[i])
                 {
                  crossUnderBar = i;
                 
                 }
              }

            if(crossUnderBar != -1)
              {
               double crossUnderPrice = Low[crossUnderBar];
               ObjectCreate("CrossUnder", OBJ_TRIANGLE, 0, Time[crossUnderBar], crossUnderPrice, 0);
               ObjectSet("CrossUnder", OBJPROP_STYLE, STYLE_SOLID);
               ObjectSet("CrossUnder", OBJPROP_WIDTH, 1);
               ObjectSet("CrossUnder", OBJPROP_BACK, Red);
               ObjectSetText("CrossUnder", "S", 8, "Arial", Red);
              }

            // Rest of your code...
           }

         // Rest of your code...
        }

        {
         ticket = OrderSend(Symbol(), OP_SELL, LotSize, Bid, slippage, Bid + StopLoss * Point, Bid - TakeProfit * Point);
         if(ticket < 0)
            Print("Error opening sell order:", GetLastError());
        }
     }

   if(ticket >= 0)
     {
      if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
        {
         if(OrderType() == OP_BUY && Bid - OrderStopLoss() > TakeProfit * Point)
           {
            if(OrderModify(ticket, OrderOpenPrice(), Bid - TakeProfit * Point, OrderTakeProfit(), 0, Green))
              {
               ticket = -1;
              }
            else
              {
               Print("Error modifying buy order:", GetLastError());
              }
           }
         else
            if(OrderType() == OP_SELL && OrderStopLoss() - Ask > TakeProfit * Point)
              {
               if(OrderModify(ticket, OrderOpenPrice(), Ask + TakeProfit * Point, OrderTakeProfit(), 0, Green))
                 {
                  ticket = -1;
                 }
               else
                 {
                  Print("Error modifying sell order:", GetLastError());
                 }
              }
        }
      else
        {
         Print("Error selecting order:", GetLastError());
         ticket = -1;
        }
     }
  }
//+------------------------------------------------------------------+

反馈

1
开发者 1
等级
(584)
项目
915
46%
仲裁
31
39% / 29%
逾期
93
10%
工作中
2
开发者 2
等级
(57)
项目
72
22%
仲裁
13
46% / 15%
逾期
5
7%
空闲
3
开发者 3
等级
(566)
项目
639
41%
仲裁
21
57% / 29%
逾期
45
7%
已载入
4
开发者 4
等级
(6)
项目
10
50%
仲裁
6
17% / 50%
逾期
3
30%
工作中
5
开发者 5
等级
(136)
项目
195
81%
仲裁
17
29% / 47%
逾期
10
5%
已载入
6
开发者 6
等级
(10)
项目
15
27%
仲裁
3
67% / 33%
逾期
0
空闲
7
开发者 7
等级
(63)
项目
75
55%
仲裁
0
逾期
0
空闲
8
开发者 8
等级
(52)
项目
96
24%
仲裁
9
22% / 22%
逾期
12
13%
工作中
9
开发者 9
等级
(145)
项目
162
41%
仲裁
5
0% / 80%
逾期
8
5%
工作中
10
开发者 10
等级
(48)
项目
53
8%
仲裁
18
17% / 39%
逾期
3
6%
繁忙
相似订单
Hello there, I would like help with creating a Tradovate Indicator/Script to help ease my trade. Tradovate is based on JavaScript so knowing it is a must. I would like to create a click to trade script. Basically using my keyboard and a click of the mouse (left click). Example, when I hold SHIFT (or whatever keyboard key the user desires) and move the mouse, a line would show indicating a buy order. Wherever the
Attached is the sample of what I need. It is a robot that does not require mt5 or mt4. API has been generated from Deriv already but I don't have the skills required to create the app. Kindly notify me if you can create such for me. Thank you
Hey, im looking for a person who can create an my very own version of pineconnector, which should have all the option of pineconnector and it should be user-friendly without any complications
HI, I'm looking for an experienced person who can add buy/sell indications and Alerts on existing Pinescript along with little modification of the script and the script should connect to MT5 platform using pineconnector MT5 platform should excute trade instantly as based on the alerts/indications on tradingview script
I want the trade to trigger anytime it sees the opportunity on all time frames, sl tp should be automated and all trades should be trigger anytime on cpi news and etc
I need you to convert my tradingview pinescript to mt4, I have just $10 for it now, But i am going to give you more work later on cause i still have more work i am going to need you to work on for me, and i will be paying with crypto, Thank You
Hello how are you doing? Can you help me with a projects connecting trend lines to pivot points on a wave, for trendlines, color detention, and dynamic visualization? I have a project I’d like you to look at. I need a pine script code to capture the different Trendline colors that cross both above and below horizontal lines on the wave indicator
Hi, I want a custom indicator to be coded based on 2 default Indicators. Add alerts for signals and news filter alerts to be sent through metaquotes id, email and phone. Popup alerts for pc/laptop as well. I would like it to have a display panel that logs the trade history and a buy/sell button with risk % based on balance and equity, fixed lots and some other features
I need an expert in the development of a fully automated trading robot For MetaTrader. The Trading Robot must be "Web based" so it can be accessed or used through a website, You can view a screenshot here; https://www.awesomescreenshot.com/image/48030918?key=79b0ff91455d862746e9b649341f4cdb Why do i need? Simple Enough, This is what i need from my Trading Robot EA. The Trading Robot can only be accessed through a
Hello I'm in possesion of a straightforward MT% Expert AdvisorThat I want to convert into DXTrade. Are you able to do this conversion? Kindly let me know if the fil atached will be enough

项目信息

预算
40+ USD
开发人员
36 USD