help with takeprofit and EA crash

 

I am in every way new to programming . However am really great at math and when I was introduce to trading I got caught to building an EA and with no former skills I took 2 days to put together a simple strategy that has worked for me but as an EA robot it would be more efficient by remove the emotion of greed.  

parts already completed w/description;
-parameter for opening: 

locate and identify the seven latest candles including the currents opened.
Identify the highs and lows. 
calculate the average highs and lows of the five earlier of the seven.
calculate the average price range of the five earlier candles.
add the average price range to the average highs and also to the average lows.

- "current" Parameter for profit : trial by 3 times the minimum stoploss value. 

-Parameter for loss : The minimum stoploss value.


Parts not yet Developed ; Parameters for closing "need help"

-Optimized parameter for profit : after TP is breached TP is activated into a Trailstop by minimum trail value.

-Parameter to close without loss: close at profit equal ZERO if the price activates order and tries to retreat before TP trail is activated. "multiple of orders will result in zero profits but that's why the EA is making the decisions".

-Stop EA from opening the same order instantaneously until terminal crashes.

 

I will share my code if necessary.  


 

The five earlier candles;

 Are they the most recent five within the seven?

Or are they the five oldest candles within the seven

Or are they the five candles before the seven? 

 
I can help you if you want to talk to me by private message, one advice if you think you have to buy wait for a better price ;)
 
Thanks for the advice on prices .