Open new Order in other direction with Limit

 

Hi,

I startet a few days ago with a new EA and i cant get it to work as i wish (I'm new to programming )

What i want it to do is : It should open a new Order in the other direction if the "normal" Long- Shortorder is at a specific point in loss, and close the new one when the "normal" Long- Shortorder is in profit.


What i tried to make this work is:

   //Pending Long Signale (Short Save)

   {

   if(NeuePeriodeBegonnen == True)

      {   

        if(ShortOrder>=1) 

         //PenLongOrder Open

         if(OrderSelect(ShortOrder,SELECT_BY_TICKET)==true)

            

               if((OrderOpenPrice()>(Ask+(Limit/100)))==true)

                  {

                     PenLongSignal = true;

                  }

            

               else if((OrderOpenPrice()<(Ask+(Limit/100)))==true)

                  {

                     PenLongSignal = false;

                  }

            

      } 

   else PenLongSignal = false;

   }   

   //Pending Short Signale (Long Save)

   {

   if(NeuePeriodeBegonnen == True)

      { 

         if(LongOrder>=1)  

         //PenLongOrder Open

         if(OrderSelect(LongOrder,SELECT_BY_TICKET)==true)

            

               if((OrderOpenPrice()<(Bid-(Limit/100)))==true)

                  {

                     PenShortSignal = true;

                  }

            

               else if((OrderOpenPrice()>(Bid-(Limit/100)))==true)

                  {

                     PenShortSignal = false;

                  }

            

      } 

   else PenShortSignal = false;      

   } 

//-------------------------------------------------------------------------------------  

//                SIGNALE UMSETZEN

//------------------------------------------------------------------------------------- 

  

   //Pending Long Signale Umsetzen

   if(PenLongSignal == true)

         {

            PenLongOrder = OrderSend(Symbol(),OP_BUY,Tradelots,Bid,10,0,0,"MAXing Long",Magicnumber,0,Green);                   

         }  

      //Pending Long Evtl Close

      if (PenLongSignal==false)

         {

            if(OrderSelect(PenLongOrder,SELECT_BY_TICKET)==true)

               {

                  bool PenLongOrderGetclosed = OrderClose(PenLongOrder,OrderLots(),Bid,10,Blue);

                  if (PenLongOrderGetclosed==true) PenLongOrder=0;

               }

         }         

   //Pending Short Signale Umsetzen

   if(PenShortSignal ==true)

         {

            PenShortOrder = OrderSend(Symbol(),OP_SELL,Tradelots,Ask,10,0,0,"MAXing Long",Magicnumber,0,Green);               

         } 

      //Pending Short Evtl Close

      if (PenShortSignal==false)

         {

            if(OrderSelect(PenShortOrder,SELECT_BY_TICKET)==true)

               {

                  bool PenShortOrderGetclosed = OrderClose(PenShortOrder,OrderLots(),Bid,10,Blue);

                  if (PenShortOrderGetclosed==true) PenShortOrder=0;

               }

         }

   


But it just opens the "normal" ones, and the "PenShortOrder" and "PenLongOrder" won't open


Regards, Dani1476.