New to programming is this correct/am I on the right track?

 

I am trying to get an EA to activate buys and sells to the following conditions:

if stoch crosses 90 then condition A

if condition A + stoch crosses 50 then sell order plus delete condition A

if stoch crosses 10 then condition B

if condition B + stoch crosses 50 then buy order plus delete condition B

I wonder if I am on the right track with the code below as I am very new to programming:

int start()                                            // Special function 'start'
  {  


 if ((iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,1,MODE_MAIN,0)<10)) // Operator 'if' with a condition
     {
      A=1;          // stochastic crosses 10 then A is marked
     }

{
  double MyPoint=Point;
  if(Digits==3 || Digits==5) MyPoint=Point*10;
  
  double TheStopLoss=0;
  double TheTakeProfit=0;
  if( TotalOrdersCount()==0 ) 

  {
     int result=0;
     if((iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,1,MODE_MAIN,0)>50)) AND A=1 // Here is your open buy 

rule

     {
        result=OrderSend(Symbol(),OP_BUY,AdvancedMM(),Ask,Slippage,0,0,MagicNumber,0,Blue);
        if(result>0)

        {
         TheStopLoss=0;
         TheTakeProfit=0;
         if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
         if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
         OrderSelect(result,SELECT_BY_TICKET);
         OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble

(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
        }
A=0
        return(0);
     }

Many thanks for reading/insults etc...

 
pighead:

I am trying to get an EA to activate buys and sells to the following conditions:

if stoch crosses 90 then condition A

if condition A + stoch crosses 50 then sell order plus delete condition A

if stoch crosses 10 then condition B

if condition B + stoch crosses 50 then buy order plus delete condition B

I wonder if I am on the right track with the code below as I am very new to programming:

Read this and implement checking function return values and error reporting:  What are Function return values ? How do I use them ?
 
pighead: I wonder if I am on the right track with the code below as I am very new to programming:
 if ((iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,1,MODE_MAIN,0)<10)) // Operator 'if' with a condition
      A=1;          // stochastic crosses 10 then A is marked
:
     if((iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,1,MODE_MAIN,0)>50)) AND A=1 // Here is your open buy 
:
A=0
Write self documenting A, 0, 1 are meaningless. Don't write things more than once. (You'll be checking if they're the same and if they differ you'll wonder if they should.)
#define OP_NONE = -1
int eTradeDirection = OP_NONE; // Buy, sell or waiting.
:
double stoch = iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,1,MODE_MAIN,0);
 if(stoch<10) eTradeDirection = OP_BUY;
:
     if(stoch >50 &&  eTradeDirection = OP_BUY) // time to open
:
eTradeDirection = OP_NONE; // Opened, Determine direction for next one
Reason: