sar cycle stop help

 
This code always gets the "buy" signal on time.
I want it to act only once when the signal changes.
So when you "buy" the trade will open. When the transaction is completed with tp or sl, it is next to the "Need to wait for sell " signal to itself . When "seated", "sat" is turned back on.
such a cycle.

Can you please help me?



    
    
    #include <Trade \ Trade.mqh> 
    
    
    
CTrade ticareti; 
    

    
    
    
void Ontick () 
    
    
    
{ 
    
    
    
double Ask = NormalizeDouble (SymbolInfoDouble (_Symbol, SYMBOL_ASK), Rakamlar; 
    
    
    
double Bid = NormalizeDouble (SymbolInfoDouble (_Symbol, SYMBOL_BID), Digits; 
    

    
    
    
dize sinyali = ""; 
    

    
    
    
Mqlrates PriceArray []; 
    

    
    
    
ArraySetAsSeries (PriceArray, true); 
    

    
    
    
int Veri = CopyRates (_Symbol, _Period, 0,3, PriceArray); 
    

    
    
    
çift ​​mySARArray []; 
    

    
    
    
int SARDefinition = iSAR (_Sembol, _Dönem, 0,02,0,2); 
    

    
    
    
ArraySetAsSeries (mySARArray, true); 
    

    
    
    
Copybuffer (SARDefinition, 0,0,3, mySARArray); 
    

    
    
    
çift ​​LastSARValue = NormalizeDouble (mySARArray [1], 5); 
    

    
    
    
eğer (LastSARValue <PriceArray [1] .low) 
    
    
    
{ 
    
    
    
signal = "satın al"; 
    
    
    
} 
    

    
    
    
eğer (LastSARValue> PriceArray [1] .high) 
    
    
    
{ 
    
    
    
signal = "sat"; 
    
    
    
} 
    

    
    
    
if (signal == "sat" && PositionTotal () <1 
    
    
    
trade.Sell (0.01, NULL, Bid, (Bid + 200 * _Point), (Bid-150 * _Point), NULL); 
    

    
    
    
if (signal == "satın al" && PositionTotal () <1 
    
    
    
trade.Buy (0.01, NULL, Ask, (Sor + 200 * _Point), (Ask-150 * _Point), NULL); 
    

    
    
    
Yorum ("Sinyal:", sinyal); 
    
    
    
} 
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
To obtain the current market information there are several functions: SymbolInfoInteger(), SymbolInfoDouble() and SymbolInfoString(). The first parameter is the symbol name, the values of the second function parameter can be one of the identifiers of ENUM_SYMBOL_INFO_INTEGER, ENUM_SYMBOL_INFO_DOUBLE and ENUM_SYMBOL_INFO_STRING. Some symbols...
 
  1. Please use the styler in the editor: Ctrl+,
  2. Please use Alt+S (or the button </>) when posting code here.
  3. If your code doesn't do, what you want just use the debugger (Ctrl+F5) and track the relevant variables - it's a lot fast then waiting for posts here and it helps you learning :)
Reason: