Invalid Stops.

 
hlw guys can anyone help me with invalid stops. The value for stops is comming in negative.
    double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
    bid = NormalizeDouble(bid,_Digits);

    double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
    ask = NormalizeDouble(ask,_Digits);
    
         double tpBuy = ask+ TpPoints ;
         tpBuy= NormalizeDouble(tpBuy,_Digits);
         double slBuy = ask- SlPoints ;
         slBuy= NormalizeDouble(slBuy,_Digits);
        
         double tpSell = bid - TpPoints ;
         tpSell= NormalizeDouble(tpSell,_Digits);
         double slSell = bid + SlPoints;
         slSell = NormalizeDouble(slBuy,_Digits);
     
    if(!isPreviousDayHighTriggred && bid  >=  high  ){
      Print(__FUNCTION__,"> Price hits previous day high...");
      
      
      
      
       if(IsBreakout) trade.Buy(Lots,_Symbol,ask,slBuy,tpBuy);
       else trade.Sell(Lots,_Symbol,bid,slSell,tpSell);
       
       if(trade.ResultOrder() > 0) {
         isPreviousDayHighTriggred = true;
       }
    }
    
    if( !isPreviousDayLowTriggred &&  bid  <= low ){
      Print(__FUNCTION__,"> Price hits previous day high...");
       
       if(IsBreakout)trade.Sell(Lots,_Symbol,bid,slSell,tpSell);
       else trade.Buy(Lots,_Symbol,ask,slBuy,tpBuy);
       
       if(trade.ResultOrder() > 0){
         isPreviousDayLowTriggred = true;
       }
    }
  
 

Your code is insufficient.

But you can check your code with the debugger - it's a lot faster that waiting here for someone:

    https://www.metatrader5.com/en/metaeditor/help/development/debug
    https://www.mql5.com/en/articles/654
    https://www.mql5.com/en/articles/35
    https://www.mql5.com/en/articles/2041
    https://www.mql5.com/en/articles/272
    https://www.mql5.com/en/articles/150

Code debugging - Developing programs - MetaEditor Help
Code debugging - Developing programs - MetaEditor Help
  • www.metatrader5.com
MetaEditor has a built-in debugger allowing you to check a program execution step by step (by individual functions). Place breakpoints in the code...
Reason: