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
評価
(135)
プロジェクト
195
81%
仲裁
18
28% / 44%
期限切れ
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%
多忙
類似した注文
THE DEVELOPER MUST NOT HAVE ANY PENDING JOBS TIME IS OF THE ESSENCE I ALREADY HAVE SORUCE CODE, ADD ENTRIES AND CONDITIONS TO CODE I NEED THIS DONE BY TODAY OR TOMORROW MORNING THE LATEST The MT4 EA will work simultaneously on multi pairs the broker has to offer. The opening procedure will begin as follows: In this example I will use a BUY order. The same for SELL order. When the EA is dragged/ double clicked/ added
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 someone to help me convert my tradingview pinescript to mt4, I only got $20 for this and I am gonna be giving you more works ahead, Also I will be paying with cryptocurrency cause my PayPal os not working here, Don't know why
I need someone to help me convert my tradingview pinescript to mt4, my budget for this project is $20 and I need this done fast in two days, Also, I am going to need you to be able to build a new indicator because that's the nest project, But I need to know if you can do this first , Thank you
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, I am in need of an expert to help me convert my tradingview pinescript to mt4, I will attach the file, But for now, I only got $15 for this project and the only payment method I can use right now is crypto, I will send it to you through crypto, Also I need someone that is ready to work because I still have lot of projects I will need him to do for me
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

プロジェクト情報

予算
40+ USD
開発者用
36 USD