'MODE_UPPER' - internal stack overflow - simplify the program, please Question.

 

Hello MQL4 community,

While coding MMA_Volume II I ran into some problems that need solutions.

MMA_Volume II original code is only about two thousand five hundred lines of code, which is relatively small compared to where it stands now in regard to code length. It now stands at about sixteen thousand lines of code.

Yeah, I know, Wow! ;) but really its much more simple than you would think. The dilemma is that I'm trying to keep all blocks of code "updated" in precedence from top to bottom. What makes this task difficult is that these

blocks depend on other blocks, creating complications. OK, now that I have provided a vivid background of what is in progress, I will continue to the heart of the topic. Obviously, I understand that I need to simplify the code, but it

is essential that these blocks stay updated in precedence. If I remove specific code from specific blocks throughout the program, then these blocks will not update and in result, the EA will not execute the program as

intended.

1. Is there a way to fix this "internal stack overflow" error without simplifying the code?

2. Do coders have any thoughts as to a solution OR do any coders have any experience with this error?

Thank you.

 
Are you using recursion ?  you have added 13,000 lines of code . . . to do what ?
 

RaptorUK,

I added thirteen thousand lines of code to do what two thousand five hundred lines of code was not doing. :)

I suppose the best way of doing this is to provide both EA's code so you can have an understanding of what is going on. Once you have this understanding, you can better advise me of what to do.

Thank you for your response.

 
WhooDoo22:

RaptorUK,

I added thirteen thousand lines of code to do what two thousand five hundred lines of code was not doing. :)

I suppose the best way of doing this is to provide both EA's code so you can have an understanding of what is going on. Once you have this understanding, you can better advise me of what to do.

Thank you for your response.

I still don't understand what your code is doing . . .  but there is clear scope for reducing the line count . . .  for example:

 {
      bid_order_profit1[0]=0; bid_order_profit1[1]=0; bid_order_profit1[2]=0; bid_order_profit1[3]=0; bid_order_profit1[4]=0;      
      bid_order_profit1[5]=0; bid_order_profit1[6]=0; bid_order_profit1[7]=0; bid_order_profit1[8]=0; bid_order_profit1[9]=0;     
      bid_order_profit1[10]=0; bid_order_profit1[11]=0; bid_order_profit1[12]=0; bid_order_profit1[13]=0; bid_order_profit1[14]=0;
     
      bid_order_profit2[0]=0; bid_order_profit2[1]=0; bid_order_profit2[2]=0; bid_order_profit2[3]=0; bid_order_profit2[4]=0;
      bid_order_profit2[5]=0; bid_order_profit2[6]=0; bid_order_profit2[7]=0; bid_order_profit2[8]=0; bid_order_profit2[9]=0;
      bid_order_profit2[10]=0; bid_order_profit2[11]=0; bid_order_profit2[12]=0; bid_order_profit2[13]=0; bid_order_profit2[14]=0;
      
      bid_order_profit3[0]=0; bid_order_profit3[1]=0; bid_order_profit3[2]=0; bid_order_profit3[3]=0; bid_order_profit3[4]=0;
      bid_order_profit3[5]=0; bid_order_profit3[6]=0; bid_order_profit3[7]=0;
     }

// can be done like this . . .

   {
   ArrayInitialize(bid_order_profit1, 0.0);
   ArrayInitialize(bid_order_profit2, 0.0);
   ArrayInitialize(bid_order_profit3, 0.0);
   }
 
You are have lots and lost of double equality checks . . . these will often go wrong,  have you read:  Can price != price ?
 

Have you seen this statement in the Documentation ?

 

 "Two unnormalized floating-point numbers cannot be linked by == or != operations. That is why it is necessary to subtract one from another, and the normalized outcome needs to be compared to null."

 
     {i=OrderSend(Symbol(),OP_SELL,0.08,Bid,30,Bid+5000*Point,Bid-99999*Point,"",77777,0,Red); 
      BarsCount=Bars; GO=true; sell_order_last=true;}}}}}}}}}}}
This will always fail which you would find out had you checked What are Function return values ? How do I use them ? - MQL4 forum
 

RaptorUK,

"I still don't understand what your code is doing"

The logic of what this code is (supposedly) doing is below...

1. sma 1 (price) crosses above smma 200 (slow ima).

2. the current value of where smma 200 is located on the chart is saved to an array. [value A.]

3. price travels it's merry way above the slow ima until it finally decides to cross back below the slow ima.

4. the current value of where smma 200 is located on the chart is saved to an array. [value B.]

5. OK, [value A.] is now subtracted from [value B.] to equal the "result".

6. If the result is larger than the sum of the spread + iEnvelopes = (7 pips), then a Boolean decision is made to signal an OrderSend() function.


The cluster of array numbers -

"bid_order_profit1", "bid_order_profit2", and "bid_order_profit3"

are OrderClose() values which are saved to these "bid_order_profit" variables when partial order closes are made.

The purpose of saving OrderProfit() values is to discern if the net profit of all partial order closes equal a win or loss.

If the total net profit of the orders equal a loss, then a Boolean decision is made to signal a specific allowance of orders to be made when price moves around the iEnvelopes indicator.

If the allowance of orders to be made when price moves around the iEnvelopes indicator after a net loss has just been made, then the EA gives the program 4 or so (complex) chances to breakout above below iEnvelopes area.

If all 4 or so chances result in loss, then the program will halt all orders and will begin hunting for a 7 pip movement of slow ima once again to signal orders as originally stated at the top of this message.


If the total net profit of the orders equal a win, then a Boolean decision is NOT triggered and OrderSend functions are allowed when price crosses above/below slow ima.


I can explain more, but I believe this covers the gist of it.

Thank you.

 

WHRoeder,

Thank you for your response and the link. I believe a little reading wouldn't hurt me. ;)

Thank you.

 
WhooDoo22:

RaptorUK,

"I still don't understand what your code is doing"

The logic of what this code is (supposedly) doing is below...

1. sma 1 (price) crosses above smma 200 (slow ima).

<SNIP>


OK,  thanks for the explanation . . .  I see a lot,  perhaps 80 - 90% of repetition in your code,  I'm sure you could get it down to 2 or 3000 lines,  perhaps even less.  Technical Indicators aren't my thing though so I won't try to give any specific help.
 

RaptorUK,

Pretty sick nasty (good) results in back-tester, even without the iEnvelopes and "result" filters. It seems to be a solid strategy that has held its own from as far back in history as strategy tester would let it run.

The reason why it works is because the market is always trending up/down. All trends contain smaller ranges. If the majority of the trend and its ranges are captured, there is no telling how many pips can be returned.

It's just pure genius. I kinda just want to upload it to the code base so that all these "strategies" can be stopped and all can trade profitably in FOREX. FOREX is a HUGE market and can't be dominated. There is nothing to worry

about.

What was it that you wrote earlier, "Are you using recursion ?" Yes.

Thank you.

Reason: